Finishing a Development Branch
obra/superpowers
Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.
Non-interactive hunk-level git staging, unstaging, discarding, undoing, fold, amend, squash, commit splitting, and commit reordering.
$ npx skills add raine/git-surgeon --skill git-surgeon -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install raine/git-surgeon git-surgeon --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/git-surgeon .claude/skills/git-surgeon && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .claude/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/raine/git-surgeon/tree/main/skills/git-surgeonType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add raine/git-surgeon --skill git-surgeon -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install raine/git-surgeon git-surgeon --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/git-surgeon .agents/skills/git-surgeon && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .agents/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add raine/git-surgeon --skill git-surgeon -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install raine/git-surgeon git-surgeon --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/git-surgeon .cursor/skills/git-surgeon && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .cursor/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/raine/git-surgeon.git --path skills/git-surgeon--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add raine/git-surgeon --skill git-surgeon -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install raine/git-surgeon git-surgeon --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/git-surgeon .gemini/skills/git-surgeon && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .gemini/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install raine/git-surgeon git-surgeonInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add raine/git-surgeon --skill git-surgeon -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/git-surgeon .github/skills/git-surgeon && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .github/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add raine/git-surgeon --skill git-surgeon -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install raine/git-surgeon git-surgeon --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/raine/git-surgeon.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/git-surgeon .opencode/skills/git-surgeon && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "git-surgeon" agent skill from https://github.com/raine/git-surgeon/tree/main/skills/git-surgeon into .opencode/skills/git-surgeon/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "git-surgeon", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
git-surgeonNon-interactive hunk-level git staging, unstaging, discarding, undoing, fold, amend, squash, commit splitting, and commit reordering.
Git Surgeon is an agent skill from raine/git-surgeon. Non-interactive hunk-level git staging, unstaging, discarding, undoing, fold, amend, squash, commit splitting, and commit reordering. Use when selectively staging, unstaging, discarding, reverting, squashing, splitting, or reordering individual diff hunks by ID instead of interactively.
Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Development, covering Git workflow. It works with Git. The repository describes itself as: Git primitives for autonomous coding agents. The licence is MIT.
5 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 798e80e. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
gitFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Git Surgeon loads about 2.3k tokens when it runs. Until then it costs about 75 tokens; SKILL.md has 738 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from raine/git-surgeon at commit 798e80e, republished under its MIT licence (© raine). 738 words, ~2,330 tokens.
.claude/skills/git-surgeon/SKILL.md (or your agent's skills folder).CLI for hunk-level git operations without interactive prompts. Useful for AI agents that need precise control over which changes to stage, unstage, discard, or undo.
# List unstaged hunks (shows ID, file, +/- counts, preview)
git-surgeon hunks
# List staged hunks
git-surgeon hunks --staged
# Filter to one file
git-surgeon hunks --file=src/main.rs
# List hunks from a specific commit
git-surgeon hunks --commit <HEAD/sha>
# Show all hunks with line numbers (for small commits needing line-range splits)
git-surgeon hunks --commit <sha> --full
# Show blame info (which commit introduced each line)
git-surgeon hunks --blame
git-surgeon hunks --blame --staged
git-surgeon hunks --blame --commit <sha>
# Show full diff for a hunk (lines are numbered for use with --lines)
git-surgeon show <id>
git-surgeon show <id> --commit HEAD
# Stage specific hunks
git-surgeon stage <id1> <id2> ...
# Stage only part of a hunk by line range
git-surgeon stage <id> --lines 5-30
# Stage and commit hunks in one step
git-surgeon commit <id1> <id2> ... -m "message"
# With inline line ranges
git-surgeon commit <id>:1-11 <id2> -m "message"
# Commit hunks directly to another branch (no checkout needed)
git-surgeon commit-to <branch> <id1> <id2> ... -m "message"
git-surgeon commit-to main <id>:1-11 <id2> -m "message"
# Unstage specific hunks
git-surgeon unstage <id1> <id2> ...
git-surgeon unstage <id> --lines 5-30
# Discard working tree changes for specific hunks
git-surgeon discard <id1> <id2> ...
git-surgeon discard <id> --lines 5-30
# Fold existing commits into an earlier commit (default: HEAD into target)
git-surgeon fold <target>
git-surgeon fold <target> --from <commit>
git-surgeon fold <target> --from <commit1> <commit2> <commit3>
# Fold staged changes into an earlier commit
git-surgeon amend <commit>
# Change commit message
git-surgeon reword HEAD -m "new message"
git-surgeon reword <commit> -m "new message"
git-surgeon reword HEAD -m "subject" -m "body"
# Squash ALL commits from <commit> through HEAD into one
git-surgeon squash HEAD~1 -m "combined feature"
git-surgeon squash HEAD~2 -m "Add user auth" -m "Implements JWT-based authentication."
git-surgeon squash <commit> -m "feature complete"
git-surgeon squash HEAD~3 --force -m "squash with merges"
git-surgeon squash HEAD~1 --no-preserve-author -m "use current author"
# Undo specific hunks from a commit (reverse-apply to working tree)
git-surgeon undo <id1> <id2> ... --from <commit>
git-surgeon undo <id> --from <commit> --lines 2-10
# Undo all changes to specific files from a commit
git-surgeon undo-file <file1> <file2> ... --from <commit>
# Split a commit into multiple commits by hunk selection
git-surgeon split HEAD \
--pick <id1> <id2> -m "first commit" \
--rest-message "remaining changes"
# Split with subject + body (multiple -m flags, like git commit)
git-surgeon split HEAD \
--pick <id1> -m "Add feature" -m "Detailed description here." \
--rest-message "Other changes" --rest-message "Body for rest."
# Split with line ranges (comma syntax or repeat ID for non-contiguous ranges)
git-surgeon split <commit> \
--pick <id>:1-11,20-30 <id2> -m "partial split"
# Move a commit after another commit
git-surgeon move <sha> --after <target-sha>
# Move a commit before another commit
git-surgeon move <sha> --before <target-sha>
# Move a commit to the end of the branch
git-surgeon move <sha> --to-end
# Update git-surgeon to the latest version
git-surgeon update
# Split into three+ commits
git-surgeon split HEAD \
--pick <id1> -m "first" \
--pick <id2> -m "second" \
--rest-message "rest"git-surgeon hunks to list hunks with their IDsgit-surgeon show <id> to inspect a hunk (lines are numbered)git-surgeon commit <id1> <id2> -m "message"git-surgeon stage <id1> <id2>, then git commitgit-surgeon commit <id>:5-30 -m "message"Use commit-to when working in a worktree and you need to commit changes to a
branch checked out elsewhere (e.g., main):
git-surgeon hunks to list hunksgit-surgeon commit-to main <id1> <id2> -m "message"| You have... | Use |
|---|---|
| Staged changes | git-surgeon amend <target> |
| One existing commit, defaulting to HEAD | git-surgeon fold <target> |
| One or more named commits | git-surgeon fold <target> --from <sha> |
fold folds one or more existing commits into an earlier one. The source(s)
(default: HEAD) are removed from history and their changes merge into the
target. Intermediate commits stay untouched. Dirty working tree is autostashed.
Refuses to run when the index already has staged changes.
git-surgeon fold <target> -- fold HEAD into target (most common)git-surgeon fold <target> --from <commit> -- fold a specific non-HEAD commitgit-surgeon fold <target> --from <c1> <c2> <c3> -- fold multiple commits in one passUse --blame to see which commit introduced the surrounding lines:
git-surgeon hunks --blameOutput shows commit hashes for each line:
a1b2c3d src/auth.rs (+2 -0)
8922b52 fn login(user: &str) {
8922b52 validate(user);
0000000 + log_attempt(user); # new line, not yet committed
0000000 + audit(user); # new line, not yet committed
8922b52 }The context lines show 8922b52 -- that's the commit where this function was
added. If your new lines belong with that change:
git-surgeon commit a1b2c3d -m "add login logging"
git-surgeon fold 8922b52amend folds staged changes into an earlier commit. For HEAD, amends directly;
for older commits, uses autosquash rebase. Unstaged changes are preserved. For
folding an existing commit instead, use fold.
git-surgeon stage <id1> <id2>git-surgeon amend <commit-sha>Squash collapses ALL commits from the target through HEAD into one, including
any unrelated commits in that range. Preview with git log <target>..HEAD --oneline first. If the range is mixed, use fold --from <c1> <c2> ... to
fold only named commits, or move --to-end the unrelated ones first.
git-surgeon squash HEAD~2 -m "combined"-m flags for subject + body: git-surgeon squash HEAD~1 -m "Subject" -m "Body paragraph"--force to squash ranges containing merge commits--no-preserve-author for current usergit-surgeon hunks --commit <sha> to list hunks in a commitgit-surgeon undo <id> --from <sha>git-surgeon undo-file src/main.rs --from <sha>git-surgeon hunks --commit <sha>--full to see all lines with line numbers in one callgit-surgeon split <sha> --pick <id1> -m "first" --rest-message "second"-m flags for subject + body: --pick <id> -m "Subject" -m "Body paragraph"id:range syntax for partial hunks: --pick <id>:5-20--pick <id>:2-6,34-37move reorders commits in history. Useful for grouping related changes or
moving a commit to a logical position after splitting.
git-surgeon move <sha> --after <target> -- place commit right after targetgit-surgeon move <sha> --before <target> -- place commit right before targetgit-surgeon move <sha> --to-end -- place commit at HEAD-2, -3 suffixeshunks to get fresh IDs© raine, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in skills/git-surgeon of raine/git-surgeon.
Open the folder on GitHubat commit 798e80e
Git Surgeon next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Git Surgeon this skillraine/git-surgeon | 171 | — | ~2.3k | Automated safety check: Pass | MIT | |
| Finishing a Development Branchobra/superpowers | 296k | 5 repos | ~1.9k | Automated safety check: Pass | MIT | |
| Code Design Rationale Investigatorcursor/plugins | 10k | 9 repos | ~2.6k | Automated safety check: Pass | None | |
| Contributor-First PR MergeHKUDS/OpenHarness | 16k | 1 repos | ~847 | Automated safety check: Pass | MIT | |
| Migrate Internal Package into GhostTryGhost/Ghost | 55k | — | ~3.8k | Automated safety check: Pass | MIT | |
| Create Pull Requestcline/cline | 70k | 1 repos | ~1.6k | Automated safety check: Pass | Apache-2.0 |
obra/superpowers
Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.
cursor/plugins
Digs into why code is shaped the way it is by checking git history, pull requests and connected tools in parallel, then reporting a cited read on the tradeoffs.
HKUDS/OpenHarness
Merges external GitHub pull requests while keeping the original author credited, and fixes conflicts after the merge instead of rewriting the contribution.
TryGhost/Ghost
Moves a package from another TryGhost repository into Ghost as an internal workspace package while keeping its Git history, with checkpoints for the steps that need an administrator.
cline/cline
Opens a GitHub pull request from your current branch with the gh CLI, after reviewing the commits and diff and gathering the details the PR needs.
tailcallhq/forgecode
Resolves Git merge conflicts with a plan-first workflow that keeps both sides' intent, regenerates lock files and backs up deleted-but-modified files.
Works with
Categories
Non-interactive hunk-level git staging, unstaging, discarding, undoing, fold, amend, squash, commit splitting, and commit reordering. Git Surgeon is an agent skill from raine/git-surgeon. Non-interactive hunk-level git staging, unstaging, discarding, undoing, fold, amend, squash, commit splitting, and commit reordering.
Git Surgeon fits situations like: selectively staging; reordering individual diff hunks by ID instead of interactively.
Run `npx skills add raine/git-surgeon --skill git-surgeon -a claude-code`. Or copy the skill folder (skills/git-surgeon in raine/git-surgeon) into .claude/skills/git-surgeon in your project. Claude Code loads it when a task matches its description.
Run `npx skills add raine/git-surgeon --skill git-surgeon -a codex`. Or copy the skill folder (skills/git-surgeon in raine/git-surgeon) into .agents/skills/git-surgeon in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add raine/git-surgeon --skill git-surgeon -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-surgeon, .gemini/skills/git-surgeon, .github/skills/git-surgeon and .opencode/skills/git-surgeon in your project.
Going by SKILL.md and its folder, Git Surgeon needs the command-line tools its instructions call (git).
SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Git Surgeon is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Git Surgeon: Finishing a Development Branch (obra/superpowers, 296k stars), Code Design Rationale Investigator (cursor/plugins, 10k stars), Contributor-First PR Merge (HKUDS/OpenHarness, 16k stars) and Migrate Internal Package into Ghost (TryGhost/Ghost, 55k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
raine (a GitHub user) maintains it in raine/git-surgeon, which has 171 GitHub stars. The repository was last updated on July 26, 2026.
Source: raine/git-surgeon on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.