From 52aef8b07d8b18f7caa2e9f3951159563aeee610 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 8 Feb 2026 23:34:57 +0000 Subject: [PATCH] feat(claude/commands): add rebase command Automate rebasing onto upstream default branch with auto-stash, conflict resolution, and clean abort/restore on low confidence. Co-Authored-By: Claude Opus 4.6 --- claude/commands/rebase.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 claude/commands/rebase.md diff --git a/claude/commands/rebase.md b/claude/commands/rebase.md new file mode 100644 index 0000000..3770599 --- /dev/null +++ b/claude/commands/rebase.md @@ -0,0 +1,33 @@ +--- +allowed-tools: Bash(git fetch:*), Bash(git rebase:*), Bash(git stash:*), Bash(git diff:*), Bash(git log:*), Bash(git add:*), Read, Edit +description: Rebase current branch onto upstream main/master +--- + +## Context + +- Current branch: !`git branch --show-current` +- Default branch: !`git remote show origin | sed -n 's/.*HEAD branch: //p'` +- Uncommitted changes: !`git status --short` + +## Your Task + +Rebase the current branch onto the upstream default branch (main or master). + +1. If there are uncommitted changes, stash them first with + `git stash push -m "auto-stash before rebase"`. +2. Fetch the latest from origin: `git fetch origin`. +3. Rebase onto the default branch using the value from context above: + `git rebase origin/`. +4. If the rebase succeeds and changes were stashed in step 1, run + `git stash pop`. +5. Show the result with `git log --oneline -10`. + +If the rebase fails due to conflicts, attempt to resolve them yourself. +If you have low confidence in the resolution, abort the rebase with +`git rebase --abort`, restore any stashed changes with `git stash pop`, +and ask the user to resolve manually — leaving the working tree as it +was found. + +You have the capability to call multiple tools in a single response. Do not +use any other tools or do anything else. Do not send any other text or +messages besides these tool calls.