One-click install
npx skills add https://github.com/nexxeln/git-hunk --skill git-hunk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-hunk
Source: https://github.com/nexxeln/git-hunk/tree/main
Command: npx skills add https://github.com/nexxeln/git-hunk --skill git-hunk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

git-hunk removes the friction of selecting partial changes by letting you inspect and stage precise diff hunks non-interactively, which is especially useful for AI agents and automated workflows.

Core Features & Use Cases

  • Atomic staging & commit previews: Stage or commit exactly selected hunks/changes with --dry-run previews to reduce mistakes.
  • Agent-safe selectors: Prefer stable change_key selectors over snapshot-bound change_id, with validate to recover when snapshots go stale.
  • Resolve file+line hints: Use resolve to map a file and line range to the recommended selectors, then apply them via stage, unstage, or commit.

Quick Start

Tell the AI: "Run git-hunk scan --mode stage --json, then git-hunk resolve --mode stage --snapshot <snapshot-id> --path <file> --start <line> --end <line> and finally git-hunk stage --snapshot <snapshot-id> --change-key <change-key>."

Frequently Asked Questions about git-hunk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stage specific git diff hunks without using interactive patch mode?

To stage specific git diff hunks without interactive patch mode, you use non-interactive CLI commands to scan worktree changes and stage exact line ranges via durable selectors. This enables agent-driven workflows by outputting stable JSON for integration.

Can I preview changes before staging partial git diffs?

Yes, you can preview changes before staging partial git diffs using a dry-run flag. This allows you to review atomic staging and commit constructions to reduce mistakes before applying exact selections to the index.

What is the best way to automate atomic git commits for an AI agent?

Automating atomic git commits for an AI agent requires resolving file and line hints into stable selectors, then applying them to stage and commit exact diff hunks. This non-interactive approach uses snapshot validation and JSON outputs for reliable integration.

Why do my snapshot-bound change IDs fail when staging git hunks?

Snapshot-bound change IDs fail when staging git hunks because snapshots become stale during agent-driven workflows. You should use stable change key selectors instead, running a validate operation to recover and remap selectors when snapshot IDs expire.

How do I map a file and line range to a git change selector?

To map a file and line range to a git change selector, run a resolve command against your staging snapshot. This identifies the recommended stable change key, which you can then apply via stage, unstage, or commit operations.