git-hunk
The missing half of git add.
git add -p is interactive. Your agents can't use it.
The problem
Partial staging is interactive-only
The only built-in way to stage individual hunks is git add -p — an interactive prompt that blocks automation.
Interactive staging
$ git add -p
@@ -42,6 +42,8 @@
+ if (flags.verbose) {
+ log.info("enabled");
+ }
(1/3) Stage this hunk [y,n,q,a,d,e,?]? █ - ✗ Requires a human at the keyboard
- ✗ Blocks CI/CD pipelines
- ✗ Non-deterministic hunk ordering
- ✗ Unusable by LLM agents
Hash-based staging
$ git hunk list --oneline
a3f7c21 src/main.zig 42-49 if (flags.verbose) {…
b82e0f4 src/parse.zig 15-28 fn parseArgs(alloc: …
c91d3a8 src/args.zig 8-8 const quiet: bool = …
$ git hunk add a3f7c21
staged a3f7c21 → a3f7c21 src/main.zig - ✓ Fully non-interactive
- ✓ Stable SHA-1 content hashes
- ✓ Deterministic across runs
- ✓ Machine-readable output
How it works
Enumerate. Select. Stage.
Three commands. No prompts. No interaction.
Enumerate
$ git hunk list See every hunk with a stable content hash. Same content always produces the same hash.
Select
$ git hunk diff a3f7 Inspect any hunk by its hash prefix. Review the full diff before staging.
Stage
$ git hunk add a3f7 Stage by hash — deterministic and scriptable. Remaining hunk hashes stay stable.
The key insight
Hashes that don't break
When you stage a hunk, the remaining hashes stay the same. This is what makes scripted multi-step workflows reliable.
Before staging
a3f7c21 src/main.zig 42-49 if (flags.verbose) {…
b82e0f4 src/parse.zig 15-28 fn parseArgs(alloc: …
c91d3a8 src/args.zig 8-8 const quiet: bool = …
$ git hunk add a3f7c21
After staging
b82e0f4 src/parse.zig 15-28 fn parseArgs(alloc: … ← same hash
c91d3a8 src/args.zig 8-8 const quiet: bool = … ← same hash How it works
SHA1( file_path + '\0' + stable_line + '\0' + diff_lines )
Hashes use the immutable side's line numbers. Staging one hunk can't shift another hunk's anchor point, so hashes remain stable across operations.
Built for
Stage hunks by hash, not by prompt
LLM Agents
Agents can't drive interactive prompts. git-hunk gives them deterministic hashes to enumerate, select, and stage programmatically.
--porcelain Scripts & CI
Deterministic staging in pipelines. Use count as a guard and check to validate hashes before staging.
--exclusive Humans
No more y/n/q/a/d/e/? guessing. See all hunks at once, inspect any hunk by hash, stage exactly what you want.
--oneline Commands
Everything you need
list
Enumerate hunks with stable content hashes
git hunk list --onelinegit hunk list --stagedgit hunk list --porcelaindiff
Inspect a hunk's full diff before staging
git hunk diff a3f7git hunk diff a3f7:3-5count
Count available hunks — bare integer for scripting
git hunk countInstall
Get started
brew install shhac/tap/git-hunk npx skills add shhac/git-hunk curl -L https://github.com/shhac/git-hunk/releases/latest/download/git-hunk-macos-universal.tar.gz | tar xz git clone https://github.com/shhac/git-hunk.git && cd git-hunk && zig build -Doptimize=ReleaseFast Demo