git-hunk
git-hunk is a small Rust CLI for non-interactive hunk staging.
It is meant for AI agents and other tooling that need an agent-safe replacement for git add -p so they can make atomic commits from Bash.
Recent agent-focused additions include:
- compact
scanoutput with semantic metadata and short previews commit --dry-runusing the real selection path without mutating the reporesolvefor turningfile + line hintinto recommended selectors- stable
change_keyidentities that survive unrelated rescans - structured error categories, retryability flags, and git command details
Install
Install from crates.io after the first publish:
Install directly from GitHub at any time:
After the first GitHub release exists, install the latest binary with:
|
Install a specific version:
| GIT_HUNK_VERSION=0.1.2
The installer currently supports:
- macOS
aarch64 - macOS
x86_64 - Linux
x86_64
Commands
scanlists selectable hunks and change blocks and returns asnapshot_idshowprints a hunk,change_id, orchange_keywith line numbersresolverecommendschange_id,change_key, and hunk selectors from a file+line hintstagestages selected hunks,change_ids,change_keys, or line rangesunstageremoves selected hunks,change_ids,change_keys, or line ranges from the indexcommitstages a selection and commits it in one step, or previews it with--dry-run
Build
Release
On every push to main, GitHub Actions runs tests, publishes a new crates.io version when Cargo.toml has an unpublished version, and creates a matching GitHub release with binary archives.
Example
Notes
- Mutating commands require a fresh
snapshot_id change_keyis stable across unrelated rescans;change_idis snapshot-bound- Rescan after every successful
stage,unstage, orcommit - Unsupported paths like conflicts, renames, and binary diffs are reported instead of forced through
See SKILL.md for the agent workflow and selector syntax.