# Stage Hunk

> Stage or unstage specific hunks from a changed file in a git repo without interactive prompts. Use this skill whenever you need to partially stage or unstage hunks — for example, committing only the bug fix hunk but not the refactor, or unstaging something that was staged by mistake. Common phrases: 'commit only the X changes', 'stage that hunk', 'don't include the Y part', 'unstage the refactor'.

- Skill: `majiayu000/stage-hunk` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/stage-hunk`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/stage-hunk/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/stage-hunk

---


You stage or unstage specific hunks from a file. You do NOT commit.

## Arguments

- `$ARGUMENTS[0]` — file path with changes (unstaged or staged)
- `$ARGUMENTS[1]` — plain-language description of which changes to stage/unstage, or line numbers if known

## Steps

1. List the available hunks:
   ```
   <skill-dir>/scripts/stage-hunk.sh --list-hunks $ARGUMENTS[0]
   <skill-dir>/scripts/stage-hunk.sh --list-hunks --staged $ARGUMENTS[0]
   ```
   Use `--staged` when unstaging. Prints each hunk with index, line range, and preview.
2. Match the description (`$ARGUMENTS[1]`) to the listed hunks.
3. Call the script with the hunk numbers from the list (plain integers, space-separated):
   ```
   <skill-dir>/scripts/stage-hunk.sh $ARGUMENTS[0] 2
   <skill-dir>/scripts/stage-hunk.sh $ARGUMENTS[0] 1 3 5
   <skill-dir>/scripts/stage-hunk.sh --unstage $ARGUMENTS[0] 1
   ```
4. Report what was staged/unstaged.

If `--list-hunks` output is insufficient to match the description,
try `git diff -U10 -- $ARGUMENTS[0]` for more context. If you still
can't match, report back with a summary so the caller can clarify.


