git-agent
Commit, PR, release, exploration, and repository-search context for AI-assisted
Git work.
When installed, skills-mgr integrates
skill discovery and on-demand guidance reading into message-generation
workflows.
git-agent gathers Git evidence with typed Go code and uses the OpenAI Agents
SDK for agent execution. A sandboxed JavaScript tool composes bounded, read-only
repository operations, including concurrent calls with Promise.all. The
commit command is the only workflow that writes to Git, and it does that after
message generation by handing the final message to git commit. The SDK manages
model requests and conversation history; Git inspection and local search stay in Go.
TL;DR: use commit-msg when you want a grounded commit message on stdout, use
commit when you want the same message created as a Git commit, use
release-note for release Markdown, and use search when an agent needs fast
local implementation context. Use explore when that search needs read-tool
inspection and context-preserving questions.
Quick Start
# 1. Install
go install github.com/yusing/git-agent/cmd/git-agent@latest
# 2. Generate a commit message from staged changes
git-agent commit-msg
# 3. Or generate and create the commit
git-agent commit
By default, message-generation commands use ChatGPT/Codex auth from
~/.codex/auth.json. OPENAI_API_KEY is the fallback for OpenAI-compatible
provider auth when that file is absent.
Installation requires Go 1.27+; npm is not needed. Generation and exploration
require Node.js 22.12+ on PATH; the built binary embeds its JavaScript runtime.
Local Git and search operations remain in Go. Installation writes to
$(go env GOPATH)/bin by default; make sure that directory is on PATH.
Everyday Workflows
| Workflow |
Command |
Output |
| Staged commit message |
git-agent commit-msg |
Final commit message on stdout |
| Amend commit message |
git-agent commit-msg --amend |
Final amended commit message on stdout |
| Generate and commit |
git-agent commit |
Human trace, then Git commit output |
| Generate and amend |
git-agent commit --amend |
Human trace, then Git amend output |
| Squash PR message |
git-agent pr-message |
Squash merge message on stdout |
| Release body |
git-agent release-note <base> <release> |
Release Markdown on stdout |
| Version bump release body |
git-agent release-note patch |
Release Markdown for latest tag to HEAD |
| Agent-ready codebase exploration |
git-agent explore [--for <target>] <question...> |
Search ID and grounded items JSON |
| Continue an exploration |
git-agent explore --follow-up <search-id> <question...> |
New branch ID and grounded items JSON |
| Print search project identity |
git-agent project_id |
Stable project hash on stdout |
| Agent context search |
git-agent search --agent <query...> |
Brief results, plus progress endpoint when indexing |
| Configure index sync |
git-agent config index.remote <git-url> |
Save a dedicated Git remote for shared revision indexes |
| Push local indexes |
git-agent index sync |
Additively publish all completed local revision indexes |
| Migrate index storage |
git-agent index migrate --to v2 |
Deduplicate vectors into immutable content-addressed packs |
| Reclaim index storage |
git-agent index gc --dry-run |
Project local and optional shared-pack garbage-collection projection |
| List search indexes |
git-agent search --ls |
Local index summaries for the current project |
| List indexed files |
git-agent search --ls-files |
Tree of files stored in the selected index |
Why git-agent?
LLMs are useful for Git writing, but raw prompts miss repository facts easily:
staged scope, amend intent, recent message style, generated-heavy diffs,
submodule history, guidance files, release ranges, and stdout/stderr contracts.
git-agent front-loads those facts before the model writes:
- It inspects the repository with typed Git plumbing.
- It builds task-specific evidence for commit, PR, release, or search work.
- It exposes only narrow read-only tools when the model needs more context.
- It validates and shapes final output for the requested workflow.
Finish staging before starting a commit command. If HEAD or staged contents
change during message generation, the command stops; rerun it after your Git
changes are finished. Repository/index redirection variables such as
GIT_DIR and GIT_INDEX_FILE are not supported for commit commands. Ordinary
Git configuration, hooks, and signing still apply.
Commit generation reads related files and project guidance from the index,
not from unstaged or untracked work. Stage guidance changes too if you want
them to apply to the generated message. Normal commit messages follow your
explicit intent and related repository conventions; amend still uses the original message as its anchor. For example,
git-agent commit --hint "port rF30625" requests a port subject retaining
that reference, using the repository's sync/port notation. Related history can
supply a task-ID suffix; supply the ID yourself when the association is ambiguous.
For staged submodule updates, normal commit-msg and commit append a
deterministic local changelog block after model generation. If the staged
changes contain only submodule updates and no --hint, they skip the
LLM entirely and format the whole message locally. Supplying a prompt uses model
generation (and requires provider auth), while retaining the local changelog
block. Locally initialized nested submodules are expanded recursively, using repository-relative headings such as webui/wiki.
With --amend, the block is rebuilt from the amended commit's parent, so a
later submodule bump replaces the changelog left by the original commit.
What It Provides
| Surface |
What it does |
| Prepared Git context |
Staged paths, status, stats, diffs, amend base, branch diffs, release ranges, and recent style commits |
| Read-only model tools |
Bounded file, diff, and repository inspection tools for generation workflows |
| Guidance discovery |
AGENTS/CLAUDE-family project instructions scoped to the task paths |
| Skill delegation |
Prompt skill listing plus on-demand reading through skills-mgr |
| Commit execution |
Optional explicit git commit --file - or git commit --amend --file - after message generation |
| Release-note writing |
Release Markdown from explicit refs or patch, minor, and major shortcuts |
| Embedding search |
Local filesystem or committed-tree context search for agents and humans |
| Debug output |
Human console diagnostics with --debug; pprof with --pprof <addr> |
Explore
git-agent explore combines embedding search with the established read-only
codebase tools and returns synchronous JSON containing an opaque ID and
grounded items. Every item has a description and at least one repository
reference. Explore works from either a Git repository or an ordinary directory;
non-Git sessions use the current directory as their codebase and metadata
identity.
The current directory is the complete exploration boundary. When it is nested
inside a Git repository, the ancestor repository still supplies project identity
and Git metadata, but semantic results, guidance, agent paths, and read tools all
remain relative to—and confined beneath—the selected directory.
In a Git repository, explore can inspect bounded commit lists, HEAD patches,
revision ranges, and files at specified revisions. Commit lists and HEAD
metadata include only changes inside the current-directory boundary. Patch and
file results stay inside that boundary and use paths relative to that directory.
# Start a grounded codebase exploration
git-agent explore "where is release note evidence prepared?"
# {"id":"...","items":[{"description":"...","references":["path/to/file.go:10-20"]}]}
# Request priority Responses API processing
git-agent explore --fast "where is release note evidence prepared?"
# Focus the answer on diagnosis, change readiness, behavior, or ownership
git-agent explore --for diagnose "why is warm search discovery slow?"
git-agent explore --for change "what must change to avoid this lookup?"
git-agent explore --for behavior "what is the follow-up reset contract?"
git-agent explore --for owner "which package owns batch compatibility?"
# Include console trace and phase timing events on stderr
git-agent explore --debug "where is release note evidence prepared?"
# Continue that exact context; the result receives another independently usable ID
git-agent explore --follow-up <search-id> "which tests define its failure contract?"
# Keep the same context and change only the answer target
git-agent explore --follow-up <search-id> --for owner "which callers reach it?"
Concurrent initial calls with the same model, service tier, and query target
batch automatically. Concurrent follow-ups naming the same parent ID, model,
service tier, and query target become independent sibling branches. Three
follow-ups preserve context; the next invocation succeeds as a fresh search with
a reset allowance.
An initial batch and its context-preserving follow-ups are assigned one
prompt-cache key. The SDK manages transport, conversation history, and compaction.
ChatGPT/Codex authentication uses its Responses compaction protocol. Custom endpoints must
support the Responses API; compaction support depends on the provider.
--for diagnose, change, behavior, or owner uses one compact,
target-neutral system prompt and adds the selected use-case guidance as a
developer message; omission keeps the full universal prompt. A follow-up
inherits its active target unless --for selects another one. Switching target
values keeps the neutral system prompt and appends one replayable developer
message with the new guidance. Adding --for to a universal-prompt branch
replaces the system prompt, so that transition may miss the prefix cache.
Selecting the active target adds no duplicate.
A depth reset inherits the exhausted session's active target unless --for
selects another.
Follow-up IDs are bound to the workspace that created them and are rejected from
another --cwd, even when both directories share an ancestor Git repository.
Explore adds no internal timeout: it runs until completion or caller
cancellation. Progress stays on stderr and the result envelope stays on stdout.
Every completed Responses request also writes an llm.usage line to stderr with
input, cached-input, cache-write-input, and output token counts.
With --debug, Explore additionally streams its console trace and
explore.phase timing events to stderr. Every timing event includes the phase
duration and elapsed command time in milliseconds; provider and tool events
additionally identify their model step, and individual tool events name the
tool. Fresh searches report semantic synchronization, discovery, chunking, cache,
embedding,
persistence, query embedding, scoring, and replay subphases. Batch leaders
report collection, prompt setup, agent execution, answer processing, and
persistence; followers report their own coordination and result-wait time.
See the specification for the exact batching, persistence,
read-tool, reset, and failure contracts.
Explore records redacted batch and branch dispositions under
${XDG_STATE_HOME:-$HOME/.local/state}/git-agent/$(git-agent project_id)/explore.log.
Use git-agent project_id to print the same stable project hash used by search
metadata and this log path.
Search
git-agent search is embedding-backed implementation-location search. It does
not run the Responses API.
# Search current filesystem files; Git repositories share a root index
git-agent search "where is release note evidence prepared"
# Compact output for humans
git-agent search --format brief "where are search flags parsed"
# Agent mode: compact output plus progress probe when indexing
git-agent search --agent "where are search flags parsed"
# Search code only, excluding common tests
git-agent search --code --no-tests "commit amend validation"
# Index first, without running a query
git-agent search --index
# Search a committed tree instead of the working filesystem
git-agent search --rev HEAD~1 "guidance discovery"
# Search a cached remote repository
git-agent search --remote https://github.com/yusing/git-agent.git "search flags"
# List search indexes for this project
git-agent search --ls
# List cached remote repositories
git-agent search --ls-remotes
# List indexed files as a tree
git-agent search --ls-files
Search reads OPENAI_EMBEDDING_API_KEY