git-surgeon

Perform hunk-level Git operations including staging, unstaging, discarding, and commit splitting.

4|3|Updated Jul 14, 2025
One-click install
npx skills add https://github.com/luan/dot-claude --skill git-surgeon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-surgeon
Source: https://github.com/luan/dot-claude/tree/main/skills/git-surgeon
Command: npx skills add https://github.com/luan/dot-claude --skill git-surgeon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides granular control over Git operations at the hunk level, allowing for precise staging, unstaging, discarding, and even splitting of commits without affecting entire files.

Core Features & Use Cases

  • Hunk-level Staging/Unstaging: Selectively stage or unstage specific hunks of changes within a file.
  • Discarding Changes: Discard specific hunks from your working directory.
  • Commit Splitting & Rewording: Split existing commits into new ones or reword them with fine-grained control.
  • Undoing Changes: Undo specific hunks from a given commit, reverting them to the working tree.
  • Use Case: You've made several unrelated changes in one file and only want to commit a subset of them. git-surgeon allows you to precisely select and stage only the desired hunks for your commit.

Quick Start

Use git-surgeon to stage hunks with IDs 123 and 456.

Frequently Asked Questions about git-surgeon

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

FAQPage Schema
How do I stage specific git hunks instead of entire files?

To stage specific git hunks, select them by their hunk ID for non-interactive staging. This allows you to commit precise subsets of changes within a single file without staging the entire file.

Can I split an existing git commit into smaller commits by hunk?

Yes, you can split existing git commits by using hunk-level manipulation. This allows you to break down a single commit into multiple new commits with precise control over which code changes go where.

What is the best way to discard specific hunks from my git working directory?

The best way to discard specific git hunks is by using hunk-level discarding. Instead of reverting an entire file, you target the exact hunk ID to remove only the unwanted changes while keeping the rest of your working directory intact.

Does hunk-level git manipulation work without interactive command-line prompts?

Yes, hunk-level git manipulation can be performed non-interactively. By operating directly on git repository data structures and using hunk IDs, you bypass interactive prompts for automated version history management.

How do I undo specific code changes from a previous git commit?

To undo specific code changes from a git commit, you can undo specific hunks from that commit. This reverts only the targeted hunks back to your working tree, leaving the rest of the commit's changes intact.

Do I need the Git command-line interface to perform hunk-level commit operations?

Yes, you need the Git command-line interface to perform hunk-level commit operations. The process operates directly on git repository data structures and requires the command-line environment to function.