skills/coding/git-rebase-safety/SKILL.md
Master safe rebasing: when to use rebase vs merge, how to handle conflicts, and how to ensure history integrity. Use when user mentions rebasing, git rebase, rebase conflicts, rebase vs merge, or when they're unsure about rebasing strategy. Triggers especially when user says "should I rebase?", "rebase vs merge", "how to resolve rebase conflicts", or "is it safe to rebase?".
npx skillsauth add ImaginerLabs/skill-manager git-rebase-safetyInstall 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.
Git-rebase-safety is a behavioral specification skill that encapsulates the judgment of when to rebase, when to merge, and how to handle rebasing safely.
This skill embodies the expertise of developers who've experienced both the power and the pitfalls of rebasing and know how to use it without causing problems.
"Never rebase public history."
If a branch has been shared with others (pushed to remote, PR created), rebasing rewrites shared history and causes problems for everyone who has that history.
┌─────────────────────────────────────────────────────────────┐
│ REBASE SAFETY MATRIX │
│ │
│ ┌─────────────────┬─────────────────┬───────────────────┐ │
│ │ │ LOCAL ONLY │ SHARED/REMOTE │ │
│ ├─────────────────┼─────────────────┼───────────────────┤ │
│ │ YOUR OWN BRANCH │ ✅ SAFE │ ⚠️ RISKY │ │
│ │ │ (personal) │ (causes issues) │ │
│ ├─────────────────┼─────────────────┼───────────────────┤ │
│ │ OTHERS' BRANCH │ ⚠️ CAUTION │ ❌ DANGEROUS │ │
│ │ │ (coordinate) │ (never do this) │ │
│ └─────────────────┴─────────────────┴───────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─ Is this branch local only?
│ └─ NO → Use MERGE
│ └─ YES → Continue
│
└─ Is this branch shared with others?
└─ YES → Use MERGE
└─ NO → Continue
│
└─ Do you prefer clean linear history?
└─ YES → Use REBASE
└─ NO → Use MERGE
| Situation | Recommendation | Why | |-----------|---------------|-----| | Local feature branch | ✅ Rebase | Clean, personal history | | Updating feature branch with main | ✅ Rebase | Keep feature isolated | | Cleaning up commits before PR | ✅ Rebase (interactive) | Improve reviewability | | Maintaining feature branch sync | ✅ Rebase | Avoid merge bubbles | | Personal experimental branches | ✅ Rebase | Full control |
| Situation | Recommendation | Why | |-----------|---------------|-----| | Branch is shared (pushed/PR) | ⚠️ Merge | Don't rewrite shared history | | Merging release branch | ⚠️ Merge | Need version markers | | Team prefers merge commits | ⚠️ Merge | Team convention | | Complex conflict resolution | ⚠️ Merge | Single merge commit easier | | Public branches | ❌ Never Rebase | Rewrites shared history |
PRE-REBASE SAFETY CHECKLIST
============================
□ Is this branch local only?
□ Has this branch been pushed to remote?
□ Has a PR been created from this branch?
□ Have others checked out this branch?
□ Is this branch shared with teammates?
If ALL NO → REBASE is safe
If ANY YES → Use MERGE instead
## Risk Analysis
| Factor | Risk Level | Action |
|--------|-----------|--------|
| Branch never pushed | LOW | Rebase freely |
| Branch pushed but no PR | MEDIUM | Coordinate with team |
| PR already reviewed | HIGH | Use merge |
| Team uses this branch | CRITICAL | Never rebase |
Risk Score: [LOW/MEDIUM/HIGH/CRITICAL]
Recommendation: [REBASE/MERGE]
# Update your feature branch with main
git checkout feature/PROJ-123
git fetch origin
git rebase origin/main
# If conflicts occur → resolve then continue
git rebase --continue
# If you want to abort
git rebase --abort
# Clean up last N commits
git rebase -i HEAD~3
# Commands in interactive mode:
# pick = use commit as-is
# squash = combine with previous (keep changes)
# fixup = combine, discard commit message
# reword = change commit message
# drop = remove commit entirely
# Example: cleanup 3 commits
pick abc1234 Add user authentication
fixup def5678 Fix typo
fixup ghi9012 WIP
# Result: 1 clean commit
┌─────────────────────────────────────────────────────────────┐
│ CONFLICT RESOLUTION │
│ │
│ 1. REBASE STOPS AT CONFLICTING COMMIT │
│ └─ "CONFLICT: src/auth.ts" │
│ │
│ 2. IDENTIFY CONFLICTING FILES │
│ └─ git status shows "both modified" │
│ │
│ 3. EDIT CONFLICTING FILES │
│ └─ Keep desired changes │
│ └─ Remove conflict markers <<< === >>> │
│ │
│ 4. STAGE RESOLVED FILES │
│ └─ git add <resolved-file> │
│ │
│ 5. CONTINUE OR ABORT │
│ └─ git rebase --continue (if resolved) │
│ └─ git rebase --abort (if messed up) │
└─────────────────────────────────────────────────────────────┘
DON'T:
DO:
# View both versions
git show :1:filename # common ancestor
git show :2:filename # ours (current branch)
git show :3:filename # theirs (incoming branch)
POST-REBASE CHECKLIST
======================
□ Run tests to ensure functionality preserved
□ Verify no unexpected changes in git log
□ If pushed before, force push with care:
└─ git push --force-with-lease (safer than --force)
□ Notify team if shared branch was affected
□ Verify all commits are intact
# SAFE: force push with lease
git push --force-with-lease origin feature/PROJ-123
# What --force-with-lease does:
# - Refuses to push if remote has commits you don't have
# - Prevents accidentally overwriting others' work
# NEVER use plain --force
git push --force # DON'T DO THIS
Analysis:
- Feature branch exists
- Main has new commits
- Branch not shared
Options:
A) git merge main
└─ Creates merge commit
└─ Preserves exact history
B) git rebase main
└─ Clean linear history
└─ No merge commit
Recommendation: REBASE (cleaner for feature branches)
# Interactive rebase to squash/fixup
git rebase -i HEAD~5
# Change 'pick' to 'fixup' for commits to combine
# Change 'pick' to 'reword' to edit messages
# Change 'pick' to 'drop' to remove commits
Analysis:
- Conflict occurred during rebase
- 5 files affected
- Complex changes
Options:
A) Continue and resolve
└─ Takes time but resolves cleanly
└─ Preserves rebased history
B) Abort and merge instead
└─ Faster
└─ Creates merge commit
└─ May be easier for complex conflicts
Recommendation:
- If you understand both sides → Resolve
- If confused/uncomfortable → Abort and merge
INCIDENT: Pushed branch rebased, team affected
IMMEDIATE ACTION:
1. Notify team immediately
2. Don't push further changes
3. Help team recover:
└─ git pull (creates duplicate commits)
└─ Or: reset to pre-rebase state
PREVENTION:
1. Always check if branch is shared
2. Use --force-with-lease
3. Prefer merge for shared branches
REBASE DECISION CHECKLIST
==========================
□ Where will this branch be used?
└─ Local only → REBASE allowed
└─ Shared/remote → Use MERGE
□ What is your team's convention?
└─ Rebase workflow → Follow it
└─ Merge workflow → Use MERGE
□ How complex are the changes?
└─ Simple → REBASE fine
└─ Complex → Consider MERGE
□ Do you need to preserve exact history?
└─ Yes → MERGE
└─ No → REBASE
RECOMMENDATION: [REBASE / MERGE]
# Daily: sync with trunk
git checkout main
git pull
git checkout feature/PROJ-123
git rebase main
# Feature complete: PR
git push --force-with-lease
# Before creating PR, clean up commits
git rebase -i HEAD~5
# Squash: combine related commits
# Reword: improve commit messages
# Drop: remove unnecessary commits
Every rebase rewrites commits. This is fine locally, dangerous on shared history.
Merge commits show exactly when integration happened and what both branches contained.
Linear history with rebase makes git log and git bisect easier.
If your team uses merge, use merge. Consistency matters more than purity.
If you're unsure about rebasing, merge is the safer choice.
git-branch-strategy — Branch creation affects rebase strategygit-commit — Interactive rebase affects commit organizationgit-merge-resolution — Alternative to rebasinggit-history-rewrite — More advanced history manipulationpre-commit-review — Review process after rebasedevelopment
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.