Agent skill
rebase-main
Rebase the current branch onto an updated main branch. Use when main has been updated and you need to incorporate those changes into your feature branch.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/rebase-main
SKILL.md
Rebase onto Main
Rebase the current feature branch onto the latest main branch.
Usage
/rebase-main
Instructions
1. Check Current State
# Get current branch
git branch --show-current
# Check for uncommitted changes
git status --porcelain
If there are uncommitted changes, ask the user whether to:
- Stash them before rebasing
- Commit them first
- Abort the rebase
2. Fetch Latest Main
git fetch origin main
3. Check if Rebase is Needed
# See how many commits main is ahead
git rev-list --count HEAD..origin/main
If main is not ahead, inform the user the branch is already up to date.
4. Perform Rebase
git rebase origin/main
5. Handle Conflicts
If conflicts occur:
-
List the conflicting files:
bashgit diff --name-only --diff-filter=U -
For each conflicting file:
- Read the file to understand the conflict
- Resolve the conflict appropriately
- Stage the resolved file:
git add {file}
-
Continue the rebase:
bashgit rebase --continue -
If conflicts are too complex, offer to abort:
bashgit rebase --abort
6. Force Push (if branch was already pushed)
# Check if branch has upstream
git rev-parse --abbrev-ref @{upstream} 2>/dev/null
# If it does, force push with lease for safety
git push --force-with-lease
7. Report Result
Tell the user:
- How many commits were rebased
- Whether force push was needed
- Any conflicts that were resolved
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?