plugins/scm-utils/skills/rebase/SKILL.md
Rebase a feature branch onto its base branch to produce a linear commit history. Use when the user asks to "rebase my branch", "rebase onto main", "rebase PR
npx skillsauth add nsheaps/ai-mktpl rebaseInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Rebase a feature branch onto its base branch to produce a clean, linear commit history.
Current branch: !git branch --show-current 2>/dev/null || echo "(not in a git repo)"
Working tree status: !git status --porcelain 2>/dev/null | head -5; COUNT=$(git status --porcelain 2>/dev/null | wc -l); [ "$COUNT" -gt 5 ] && echo "... and $((COUNT - 5)) more" || true
PR info for current branch:
!gh pr view --json baseRefName,headRefName,number,title,state 2>/dev/null || echo "(no PR found or gh not authenticated)"
This skill rebases a feature branch on top of its base branch instead of merging. Use rebase when:
Key difference from update-branch: The update-branch skill uses git merge (preserves history, no force push needed). This skill uses git rebase (rewrites history, requires force push).
Default behavior (no arguments): Use the current directory, get the current branch via git branch --show-current, find the associated PR via gh pr list --head <branch>, and rebase onto the PR's base branch.
Determine the target branch from the provided input. Accept any of:
| Input Type | Example | Resolution |
| ----------- | -------------------------------------- | ------------------------------------------------------- |
| No input | (empty) | Current directory → current branch → find PR → rebase |
| PR number | 123, #123 | gh pr view 123 --json headRefName,baseRefName |
| PR URL | https://github.com/org/repo/pull/123 | Parse number, use gh pr view |
| Branch name | feature/my-branch | Use directly, find PR with gh pr list --head <branch> |
| Directory | /path/to/repo | cd there, get current branch, find PR |
Critical: Always query the PR to determine the base branch. Never assume main or master.
# Get branch info from PR
gh pr view <number> --json headRefName,baseRefName,number,url
# Find PR for a branch
gh pr list --head <branch-name> --json number,baseRefName --limit 1
Execute these steps in order:
Ensure the working tree is clean before rebasing:
git status --porcelain
If there are uncommitted changes, stop and ask the user whether to stash, commit, or abort. A rebase with a dirty working tree will fail.
git fetch --all --prune
BASE_BRANCH=$(gh pr view <number> --json baseRefName --jq '.baseRefName')
If no PR exists for the branch, ask the user what the base branch should be.
git checkout <feature-branch>
Before rebasing, incorporate any remote changes to the feature branch:
git pull origin <feature-branch> --rebase
git rebase origin/$BASE_BRANCH
If conflicts occur, see Conflict Resolution.
Since rebase rewrites history, a force push is required. Always use --force-with-lease to prevent overwriting others' work:
git push --force-with-lease origin <feature-branch>
NEVER use --force — --force-with-lease will fail safely if the remote has commits you haven't seen.
Confirm the remote branch is updated:
gh pr view <number> --json commits,mergeable,mergeStateStatus
Rebase applies commits one at a time, so conflicts must be resolved per-commit.
When a conflict occurs mid-rebase:
# See which files conflict
git diff --name-only --diff-filter=U
# After resolving conflicts in a file
git add <file>
# Continue the rebase
git rebase --continue
To abort and return to the pre-rebase state:
git rebase --abort
Resolve directly when the conflict is clearly one of:
For conflicts requiring analysis, delegate to specialized agents:
Use Explore agent with haiku model to understand:
Use Plan agent to determine:
Execute the resolution — the executing agent owns the final resolution.
Stage and continue:
git add <resolved-files>
git rebase --continue
Verify the resolution — run tests or builds after the full rebase completes.
For detailed conflict patterns, see the update-branch skill's references/conflict-resolution.md.
Only modify the requested branch:
Force push safely:
--force-with-lease (never bare --force)--force-with-lease fails if the remote has unexpected commits, preventing data loss--force-with-lease fails, fetch and inspect before retryingConfirm before force pushing shared branches:
git log --format='%an' origin/<branch> | sort -u), warn the user that rebase will rewrite their collaborators' historygit pull --rebase or reset their local branch after the force pushPreserve all commits:
git log --oneline origin/$BASE_BRANCH..<feature-branch> before and afterWhen NOT to rebase:
update-branch skill instead)When reporting completion, be explicit about what happened:
Do say: "Rebased feature branch onto main — force pushed with lease to update remote"
Don't say: "Branch updated" (ambiguous — could be merge or rebase)
| Error | Resolution |
| ----------------------------- | ---------------------------------------------------------- |
| No PR found for branch | Ask user for base branch, or create PR first |
| Dirty working tree | Ask user to stash or commit first |
| Rebase conflicts | Resolve per-commit, then git rebase --continue |
| --force-with-lease rejected | Fetch, inspect new remote commits, ask user how to proceed |
| Rebase produces empty commits | Use git rebase --skip for truly empty commits |
| Authentication failure | Ensure gh and git are authenticated |
This skill works identically in CI and local environments:
git directly for all operationsuser.name and user.email appropriatelytools
Manually reproduce what the github-app plugin's SessionStart hook does to make a GitHub App installation token usable in the current session — materialize the PEM, generate the token, isolate GH_CONFIG_DIR, write the runtime env file, and wire CLAUDE_ENV_FILE so every Bash call sees GH_TOKEN/GITHUB_TOKEN. Use when the hook did not run, the token is missing from the environment, or a shell/teammate needs the token wired up by hand. <example>GH_TOKEN isn't set even though github-app is configured</example> <example>the github-app SessionStart hook didn't run, set up the token manually</example> <example>wire the github app token into CLAUDE_ENV_FILE</example> <example>gh keeps falling back to the wrong account, isolate GH_CONFIG_DIR</example>
tools
Manually configure the GitHub App bot git identity the way the github-app plugin's SessionStart hook does — resolve the app slug and bot user ID, build the <slug>[bot] name and noreply email, set GIT_AUTHOR_*/GIT_COMMITTER_* env vars, and write an isolated GIT_CONFIG_GLOBAL with the gh auth git-credential helper. Use when commits are attributed to the wrong account, "Author identity unknown" appears, or git identity must be set up by hand. <example>my commits are showing up as the handler, not the bot</example> <example>git says Author identity unknown after the github-app hook ran</example> <example>configure the github app bot git identity manually</example> <example>set up the gh credential helper for git push</example>
tools
Manages spec files for requirements capture and validation
tools
# Bash Chaining Alternatives This skill teaches you how to work around the bash command chaining restriction enforced by this plugin. ## Why Chaining is Blocked The `bash-command-rejection` plugin blocks these operators: | Operator | Name | Why Blocked | | -------- | ---------- | ----------------------------------------------------------------------------------- | | `&&` | AND chain | Runs cmd2 only if cmd1 su