git-rebase — Claude Code skill: rebase a branch and resolve conflicts
Walks an agent through a rebase and settles conflicts commit by commit, leaving unrelated work alone. Useful when a branch has fallen behind its base.
npx skills add pedronauck/skills --skill git-rebase -a claude-codeWhat git-rebase does
The skill runs in steps. The agent checks status, the current branch and the target, sees whether a rebase is already running, and keeps uncommitted edits where they are. No auto-stash, no reset, no checkout; when the tree is messy, it works in a separate checkout.
Before rewriting anything valuable, the agent notes HEAD and makes a backup ref with scripts/pre-rebase-backup.sh. A plain rebase onto the requested target is the norm. Squashing or reordering happens only on your request, not because the branch has many commits. Each conflict gets its own pass: during a rebase ours means the target plus the commits already replayed, theirs is the one being replayed now. The agent reads the changed APIs instead of taking a side wholesale, so the security and compatibility contracts survive.
Publishing a rewritten branch happens only if you already allowed it, and it goes through --force-with-lease. Should that lease fail, the agent inspects the new remote commits rather than switching to an unconditional force. Merge-commit flows, cherry-picking and repository setup are outside its scope.
What it helps with
- Move a branch onto a newer base without losing either side
- Work through a conflict between the replayed commit and earlier ones
- Take a backup ref before history is rewritten
- Push a rewritten branch without clobbering others' commits
- Check the resulting diff and test the affected behaviour
Example prompts for the agent
- Rebase this branch onto
mainand handle conflicts one at a time - Move
feature/authontoorigin/mainand keep my uncommitted edits - Push the branch after the rebase using
--force-with-lease
How to install git-rebase
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill git-rebase -a claude-code2Manually: put the files in place
~/.claude/skills/git-rebase/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/git-rebase/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill git-rebase -a codex2Manually: put the files in place
.agents/skills/git-rebase/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill git-rebase -a cursor2Manually: put the files in place
.cursor/skills/git-rebase/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install pedronauck/skills git-rebase2Manually: put the files in place
.github/skills/git-rebase/SKILL.md1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill git-rebase -a gemini-cli2Platform CLI
gemini skills install https://github.com/pedronauck/skills --path skills/mine/git-rebaseManually: put the files in place
.devin/skills/git-rebase/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add pedronauck/skills --skill git-rebase -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about git-rebase
How do I install git-rebase in Claude Code?
Run npx skills add pedronauck/skills --skill git-rebase -a claude-code. The skill file lands at ~/.claude/skills/git-rebase/SKILL.md.
What does git-rebase do?
It carries out a rebase onto the target you give it and resolves conflicts as commits are replayed, keeping both sides' intent. It also takes a backup ref and checks the final diff.
How is it different from plain git rebase?
The agent tracks which side is ours and which is theirs during replay, then fixes the affected behaviour rather than accepting one side. A rewritten branch is pushed only with your permission, via --force-with-lease.