Stamp Copilot CLI session metadata onto your git history and pull requests, so every commit and PR can be traced back to the agent session (and model) that produced it.
Scope: GitAgentify currently targets GitHub Copilot (the
copilotCLI and its agents). It keys off Copilot's environment variables (COPILOT_CLI,COPILOT_AGENT_SESSION_ID,COPILOT_CLI_BINARY_VERSION,AGENCY_LOG_SESSION_DIR) and its.github/instructions/mechanism. Support for other coding agents may be added later.
GitAgentify installs two cooperating pieces into a repo:
-
A
prepare-commit-msggit hook that adds structured trailers to every Copilot-authored commit:Copilot-Session-Id: 1594c4f7-f162-425b-b4ac-c0b533b6ccae Copilot-Model: claude-opus-4.8 Copilot-CLI-Version: 1.0.62The hook only fires when
COPILOT_CLI=1, skips merge/squash commits, is idempotent, and chains to any existing.git/hooks/prepare-commit-msg.local. -
A repo-scoped Copilot instructions file (
.github/instructions/gitagentify/copilot-pr-metadata.instructions.md) plus thegitagentify pr-descriptiongenerator. Together they tell the agent to attach a code-authored metadata block (models, session ids, CLI version, files explored) to the top of every PR description it creates or updates.
pipx install git+https://github.com/ozzafar/gitagentify
# or: pip install git+https://github.com/ozzafar/gitagentify
cd your-repo
gitagentify activatepipx install git+https://github.com/ozzafar/gitagentify
# or: pip install git+https://github.com/ozzafar/gitagentifyRun inside the repository you want to enable:
cd your-repo
gitagentify activateThis writes everything into two dedicated gitagentify folders:
.gitagentify/prepare-commit-msg+.gitagentify/.gitattributes(the commit hook),.github/instructions/gitagentify/copilot-pr-metadata.instructions.md(the PR instructions),
and wires the hook with git config --local core.hooksPath .gitagentify.
Scope guarantee: activation is strictly per-clone. GitAgentify only ever writes the repository-local git config (
git config --local ...), which lives in this clone's.git/config. It never writes--globalor--systemconfig, so activating in one repo never affects any other repo or clone. Becausecore.hooksPathis per-clone and not committed, each teammate runsgitagentify activateonce in their own clone.
Commit the installed files so teammates get the hook + instructions:
git add .gitagentify .github/instructions/gitagentify/copilot-pr-metadata.instructions.md
git commit -m "Add gitagentify Copilot session metadata"| Command | Description |
|---|---|
gitagentify activate |
Install the hook + instructions into the current repo and wire the hook for this clone only. |
gitagentify deactivate |
Unset the local core.hooksPath wiring. --purge also deletes the installed files. |
gitagentify status |
Show activation status and which files are installed. |
gitagentify pr-description |
Print the PR session-metadata block to stdout (what the agent attaches to a PR). |
gitagentify pr-description computes the block deterministically - it trusts nothing from the agent:
- Models - union of every distinct
Copilot-Modelcommit trailer on the branch and every model recorded in the current session log (so a model is not lost when commits are squashed). - CLI version - the
Copilot-CLI-Versiontrailer (falls back to$COPILOT_CLI_BINARY_VERSION). - Session Ids - every distinct
Copilot-Session-Idtrailer plus the current session id, each rendered as a copy-clickablecopilot --resume=<id>line. - Files explored - files the current session viewed/edited/created (from the session log only; intentionally not persisted to commit trailers).
The block is delimited by paired markers so the agent can replace it idempotently on every update:
<!-- copilot-session-metadata:start -->
...
<!-- copilot-session-metadata:end -->
- Python 3.8+
- git
- bash (for the commit hook; present via Git for Windows on Windows)
gitagentify deactivate --purgeThis project is licensed under the MIT License.