Git-surgeon – Hunk-level Git primitives for AI agents
Gives AI agents surgical Git control—solves destructive workarounds in autonomous coding workflows.

Stable hunk hashing solves real LLM/CI automation gap—git add -p is genuinely unusable for agents.
DevOps engineers, LLM agent builders, CI/CD pipeline authors who need deterministic Git workflows
git-hunk is the non-interactive alternative. It gives every hunk a stable SHA-1 content hash, then lets you stage by hash:
$ git hunk list --oneline
a3f7c21 src/main.zig 42-49 if (flags.verbose) {…
b82e0f4 src/parse.zig 15-28 fn parseArgs(alloc: …
$ git hunk add a3f7c21staged a3f7c21 → a3f7c21 src/main.zig
The key design choice: hashes are computed from the immutable side's line numbers, so staging one hunk never changes another hunk's hash. This makes multi-step scripted workflows reliable — you can enumerate hunks, make decisions, then stage them without the targets shifting underneath you.Other things it does: line-range selection (a3f7:3-5,8), --porcelain output for machine consumption, count for CI guards, check --exclusive for hash validation, stash individual hunks, and restore to selectively discard changes.
Single static binary, written in Zig, zero runtime dependencies beyond git itself. Install via brew install shhac/tap/git-hunk.
I built this because I was trying to run AI agents in parallel, and stuck to file-level editing they'd fight eachother over what changes they wanted to put into commits. Now I can have multiple agents work in parallel and commit cleanly without needing worktrees.
Gives AI agents surgical Git control—solves destructive workarounds in autonomous coding workflows.
Finally gives AI agents git add -p without the interactivity problem.
Content-based anchors let AI agents stage hunks without interactive prompts.
Git add -p but with line-level control inside hunks and batch operations across files.
Finally, a GUI for git rebase -i that handles hunk splitting without the terminal dance.
GitHub alternative from scratch, but lacks features, traction, and clear moat vs established forks.