libgit2-core

Guides editing of Git::Libgit2 FFI bindings, opaque-handle ownership, and test isolation rules.

Updated May 24, 2026
One-click install
npx skills add https://github.com/Getty/p5-git-libgit2 --skill libgit2-core-getty
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: libgit2-core
Source: https://github.com/Getty/p5-git-libgit2/tree/main/.claude/skills/libgit2-core
Command: npx skills add https://github.com/Getty/p5-git-libgit2 --skill libgit2-core-getty

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Contributors to Git::Libgit2 repeatedly violate the same architectural rules: leaking opaque libgit2 handles, misdeclaring FFI out-params, and writing tests that silently read the user's ~/.gitconfig and pass locally but fail in CI. This Skill loads the project's core architecture contract into context before any editing begins. ## Core Features & Use Cases - Binding recipe: Defines the exact four-step workflow for adding a libgit2 binding — register the opaque type, add the _attach line, write the =func POD block, and add a smoke test. - Ownership and FFI rules: Documents the mandatory _new/_free pairing, the singleton FFI::Platypus instance, and known FFI gotchas such as opaque vs opaque* out-params and credential callback closure types. - Test isolation contract: Enforces GIT_CONFIG_GLOBAL/GIT_CONFIG_SYSTEM redirection to /dev/null and recursive prove -lr t/ runs. - Use Case: An agent asked to bind a new libgit2 function (e.g. git_blame) loads this Skill first, then follows the canonical recipe without re-deriving ownership or test conventions. ## Quick Start Load this Skill before making any change to the Git::Libgit2 distribution so the binding, ownership, and test-isolation rules are applied.

Frequently Asked Questions about libgit2-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new libgit2 binding in Git::Libgit2?

Register the opaque type in the ffi() block of lib/Git/Libgit2/FFI.pm, add the _attach line in the matching section of _attach_all(), write a =func POD block mentioning the matching *_free, and add a smoke test under t/ with gitconfig isolation.

What is the difference between Git::Libgit2 and Git::Native?

Git::Libgit2 is the low-level 1:1 FFI surface over libgit2's C API with opaque handles and return codes. Git::Native sits one layer up and provides Moo objects, RAII handle cleanup, and typed exceptions for idiomatic Perl use.

Why do Git::Libgit2 tests pass locally but fail in CI?

The usual cause is missing gitconfig isolation: tests must set GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM to /dev/null, otherwise libgit2 reads the user's ~/.gitconfig. Also use prove -lr t/ since plain prove -l skips subdirectory tests.

Does Git::Libgit2 free libgit2 handles automatically?

No. Every *_new or *_lookup call must be matched by the caller with the corresponding *_free; the module does not track lifetimes or warn on leaks. Automatic cleanup via Moo DESTROY lives in the Git::Native layer.

Which libgit2 versions does Git::Libgit2 support?

libgit2 1.5 is the minimum; all 236 bound functions exist in 1.5.1. Alien::Libgit2 decides whether to use a system libgit2 or the bundled build, and CI covers 1.5.1, 1.9.3, and 1.9.4.