by mattzcarey
better git cli for agents
# Add to your Claude Code skills
git clone https://github.com/mattzcarey/zagia better git interface for agents
fork, prompt and guardrailscurl -fsSL zagi.sh/install | sh
This downloads the binary and sets up git as an alias to zagi. Restart your shell after installation.
git clone https://github.com/mattzcarey/zagi.git
cd zagi
zig build -Doptimize=ReleaseFast
./zig-out/bin/zagi alias # set up the alias
Use git as normal:
git status # compact status
git log # concise commit history
git diff # minimal diff format
git add . # confirms what was staged
git commit -m "x" # shows commit stats
Any commands or flags not yet implemented in zagi pass through to git. zagi also comes with its own set of features for managing code written by agents.
zagi ships with a wrapper around worktrees called fork:
# Create named forks for different approaches your agent could take
git fork nodejs-based
git fork bun-based
# Work in each fork
cd .forks/nodejs-based
# ... make changes, commit ...
cd .forks/bun-based
# ... make changes, commit ...
# Compare results, then pick the winner
cd ../..
git fork # list forks with commit counts
git fork --pick bun-based # merge fork into base (keeps both histories)
git fork --promote bun-based # replace base with fork (discards base commits)
# Clean up
git fork --delete-all
Agent mode is automatically enabled when running inside AI tools (Claude Code, OpenCode, Cursor, Windsurf, VS Code). You can also enable it manually:
export ZAGI_AGENT=my-agent
This enables:
git commit requires --prompt to record the user request that created the commitreset --hard, checkout ., clean -f, push --force) to prevent data lossgit commit -m "Add feature" --prompt "Add a logout button to the header"
git log --prompts # view prompts
git log --agent # view which AI agent made commits
git log --session # view full session transcript (with pagination)
Metadata is stored in git notes (refs/notes/agent, refs/notes/prompt, refs/notes/session) which are local by default and don't affect commit history.
| Variable | Description | Default | Valid values |
|----------|-------------|---------|--------------|
| ZAGI_AGENT | Manually enable agent mode. Auto-detected from CLAUDECODE, OPENCODE, or IDE environment. | (auto) | Any string enables agent mode. For executors: claude, opencode |
| ZAGI_AGENT_CMD | Custom executor command ov...