skills/rename-branch/SKILL.md
This skill should be used when the user asks to "rename branch", "change branch name", "update branch name based on changes", or wants to create a meaningful branch name based on the changes.
npx skillsauth add pitzcarraldo/skills rename-branchInstall 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.
This skill intelligently analyzes the differences between the current branch and the base branch (typically origin/main), then generates and applies a descriptive branch name following conventional commit conventions. The generated name uses kebab-case and accurately reflects the nature of the changes.
<type>/<description>
| Prefix | Purpose | Examples |
|--------|---------|----------|
| feat/ | New features | feat/user-auth, feat/dark-mode |
| fix/ | Bug fixes | fix/null-pointer, fix/memory-leak |
| docs/ | Documentation | docs/api-guide, docs/setup |
| style/ | Formatting | style/prettier, style/lint-rules |
| refactor/ | Code restructuring | refactor/extract-utils, refactor/simplify-logic |
| perf/ | Performance | perf/cache-queries, perf/lazy-load |
| test/ | Testing | test/unit-coverage, test/e2e-auth |
| build/ | Build system | build/webpack-config, build/deps |
| ci/ | CI/CD | ci/github-actions, ci/deploy |
| chore/ | Maintenance | chore/cleanup, chore/update-deps |
Good examples:
feat/oauth-login ✓fix/race-condition ✓docs/quick-start ✓Bad examples:
feat/AddOAuthLogin ✗ (not kebab-case)fix/fixed-the-race-condition-in-auth ✗ (too long, past tense)docs/documentation-updates ✗ (redundant)Check if we're in a valid git repository:
git rev-parse --git-dir 2>&1
Expected output:
.git or path to git directoryCheck current branch:
git branch --show-current
If detached HEAD state:
Error: Cannot rename branch - currently in detached HEAD state
You are not on any branch. To create a new branch from current state:
git checkout -b <branch-name>
If on protected branch (main/master/develop):
Warning: You are on the protected branch '[branch-name]'
Creating new branches from protected branches is recommended:
git checkout -b <new-branch-name>
Proceed with rename anyway? [y/n]
Attempt to find the base branch in order of preference:
# Try origin/main
git rev-parse --verify origin/main 2>/dev/null
# If not found, try origin/master
git rev-parse --verify origin/master 2>/dev/null
# If not found, try local main
git rev-parse --verify main 2>/dev/null
# If not found, try local master
git rev-parse --verify master 2>/dev/null
Store the first successful result as BASE_BRANCH
If no base branch found:
Error: Cannot determine base branch
None of the following branches exist:
- origin/main
- origin/master
- main
- master
Please specify the base branch manually or create one.
Fetch comprehensive change information:
# Summary of changed files
git diff $BASE_BRANCH...HEAD --stat
# Detailed line-by-line changes
git diff $BASE_BRANCH...HEAD
# Commit messages on this branch
git log $BASE_BRANCH..HEAD --oneline
# Number of commits
git rev-list --count $BASE_BRANCH..HEAD
If no changes detected:
No changes detected between current branch and $BASE_BRANCH
This branch is either:
- Fully merged into $BASE_BRANCH
- Has no commits
- Is synchronized with $BASE_BRANCH
No rename needed.
Parse the data to extract:
Apply pattern matching logic:
# Documentation changes
if files match: *.md, docs/*, README*
→ type: docs
# Test files
if files match: *test.*, *spec.*, __tests__/*, tests/*
→ type: test
# CI/CD configurations
if files match: .github/workflows/*, .gitlab-ci.yml, Jenkinsfile
→ type: ci
# Build configurations
if files match: package.json, Gemfile, requirements.txt, *.config.js
→ type: build
# Style/formatting
if files match: .prettierrc, .eslintrc, .editorconfig
→ type: style
# Analyze diff and commit messages for keywords
# New features (keyword presence in diffs/commits)
if contains: "add", "implement", "create", "new"
→ type: feat
# Bug fixes
if contains: "fix", "bug", "issue", "resolve", "correct"
→ type: fix
# Refactoring
if contains: "refactor", "restructure", "extract", "move", "rename"
→ type: refactor
# Performance
if contains: "optimize", "performance", "faster", "cache", "speed"
→ type: perf
# Default fallback
if no clear pattern:
→ type: chore
If changes span multiple types:
Extract meaningful description from changes:
Identify primary module/component:
# From file paths: src/auth/login.ts → "auth"
# From multiple files in same dir → use directory name
Extract action from commits:
# From commit messages like "Add OAuth support"
# Extract: "oauth-support"
Combine module + action:
# If module: "auth", action: "oauth"
# Result: "auth-oauth"
# If action already includes module context
# Result: just use action
Sanitize description:
# Convert to lowercase
description=$(echo "$description" | tr '[:upper:]' '[:lower:]')
# Replace spaces/underscores with hyphens
description=$(echo "$description" | tr ' _' '-')
# Remove special characters
description=$(echo "$description" | sed 's/[^a-z0-9-]//g')
# Remove consecutive hyphens
description=$(echo "$description" | sed 's/--*/-/g')
# Trim to 20 characters
description=${description:0:20}
# Remove trailing hyphen if present
description=${description%-}
Examples of description generation:
| Commits | Files | Generated Description |
|---------|-------|----------------------|
| "Add OAuth login" | src/auth/oauth.ts | oauth-login |
| "Fix null pointer in payment" | src/payment/process.ts | payment-null-ptr |
| "Update API docs" | docs/api.md | api-docs |
| "Refactor validation utils" | src/utils/validation.ts | validation-utils |
| "Optimize database queries" | src/db/query.ts | db-queries |
Combine type and description:
new_branch="${type}/${description}"
Validate the name:
# Check length (should be reasonable, typically < 50 chars total)
if [ ${#new_branch} -gt 50 ]; then
# Truncate description further
fi
# Check for existing branch with same name
if git show-ref --verify --quiet "refs/heads/$new_branch"; then
# Append number: feat/user-auth-2
suffix=2
while git show-ref --verify --quiet "refs/heads/${new_branch}-${suffix}"; do
((suffix++))
done
new_branch="${new_branch}-${suffix}"
fi
Compare with existing name:
current_branch=$(git branch --show-current)
# If already follows convention and is accurate
if [[ "$current_branch" =~ ^(feat|fix|docs|style|refactor|perf|test|build|ci|chore)/ ]]; then
# Extract current description
current_desc=${current_branch#*/}
# Check similarity with generated description
if [ "$current_desc" == "$description" ]; then
echo "Current branch name is already appropriate: $current_branch"
echo "No rename needed."
exit 0
fi
fi
Perform the rename operation:
old_branch=$(git branch --show-current)
# Rename the branch
git branch -m "$old_branch" "$new_branch"
Verify the rename:
# Check new branch name
if [ "$(git branch --show-current)" == "$new_branch" ]; then
echo "✓ Branch renamed successfully"
else
echo "✗ Branch rename failed"
exit 1
fi
Show summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Branch Renamed Successfully
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Old name: [old_branch]
New name: [new_branch]
Reason: [Brief explanation of type and description choice]
Changes analyzed:
- [X] files modified
- [Y] insertions, [Z] deletions
- [N] commits
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
If branch was previously pushed to remote:
⚠ Remote Branch Update Required
This branch was previously pushed to remote as '[old_branch]'.
To update the remote:
1. Push the new branch:
git push -u origin [new_branch]
2. Delete the old remote branch:
git push origin --delete [old_branch]
3. (Optional) Update any open pull requests to point to new branch
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Check if branch has remote tracking:
# Check for remote tracking branch
if git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null; then
# Remote tracking exists, show update instructions
fi
Scenario:
feature-branchCommands executed:
git diff origin/main...HEAD --stat
# Output: src/auth/oauth.ts | 120 +++++++
# src/auth/login.ts | 45 +++
git log origin/main..HEAD --oneline
# Output: a1b2c3d Add OAuth authentication
# b2c3d4e Implement login flow
Analysis:
feat (new functionality)authoauth-loginoauth-login (16 chars)Result:
Old: feature-branch
New: feat/oauth-login
Reason: Detected new authentication feature in auth module
Scenario:
bugfixCommands executed:
git diff origin/main...HEAD --stat
# Output: src/payment/process.ts | 8 ++--
git log origin/main..HEAD --oneline
# Output: c3d4e5f Fix null pointer in payment processor
Analysis:
fix (bug fix keywords)paymentnull-pointerpayment-null-ptr (17 chars)Result:
Old: bugfix
New: fix/payment-null-ptr
Reason: Detected bug fix in payment processing module
Scenario:
update-docsCommands executed:
git diff origin/main...HEAD --stat
# Output: docs/api/v2.md | 200 +++++++++++++
# docs/guides/auth.md | 50 ++++
git log origin/main..HEAD --oneline
# Output: d4e5f6a Update API v2 documentation
# e5f6g7h Add authentication guide
Analysis:
docs (documentation files)api-v2api-v2-guide (12 chars)Result:
Old: update-docs
New: docs/api-v2-guide
Reason: Detected documentation updates for API v2
Scenario:
cleanupCommands executed:
git diff origin/main...HEAD --stat
# Output: src/utils/validation.ts | 150 ++++++++++++++
# src/components/Form.tsx | 80 ++------
git log origin/main..HEAD --oneline
# Output: f6g7h8i Extract validation to utility module
# g7h8i9j Simplify form component
Analysis:
refactor (code restructuring)validationextract-validationvalidation-utils (16 chars)Result:
Old: cleanup
New: refactor/validation-utils
Reason: Detected refactoring of validation logic into utils
Scenario:
various-updatesCommands executed:
git diff origin/main...HEAD --stat
# Output: src/auth/oauth.ts | 120 +++++++ (new file)
# src/payment/fix.ts | 8 +- (bug fix)
# docs/readme.md | 10 + (docs)
git log origin/main..HEAD --oneline
# Output: h8i9j0k Add OAuth authentication (major)
# i9j0k1l Fix payment bug (minor)
# j0k1l2m Update readme (minor)
Analysis:
feat (most significant change)oauth from largest changeoauth-auth (10 chars)Result:
Old: various-updates
New: feat/oauth-auth
Reason: Primary change is new OAuth authentication feature
(Also includes minor bug fix and doc update)
| Tool | Purpose | Check Command |
|------|---------|---------------|
| Git | Version control | git --version |
| Bash | Shell scripting | bash --version |
git diff ... syntax)No special configuration required, but recommended:
# Set default branch name (optional)
git config --global init.defaultBranch main
Error: Not a git repository
git initError: Detached HEAD state
git checkout -b <name>Error: Cannot determine base branch
Error: No changes detected
Error: Branch name already exists
feat/auth-2)Error: Invalid ref format
Allow user to specify different base branch:
# Compare against different branch
git diff custom-base...HEAD --stat
Confirm before renaming:
Generated branch name: feat/oauth-login
Current: feature-branch
New: feat/oauth-login
Proceed with rename? [y/n]
Show what would happen without actually renaming:
# Simulate rename
echo "Would rename: $old_branch → $new_branch"
# Skip actual git branch -m command
Automatically update remote tracking after rename:
git branch -m "$old_branch" "$new_branch"
git push origin -u "$new_branch"
git push origin --delete "$old_branch"
development
Review a tech spec document written in the team's Notion template format (Summary, Background, Goals, Non-Goals, Plan, Measuring Impact, Security/Privacy/Risks, Other Considerations, Milestones, Open Questions). Use when the user asks to "테크 스펙 리뷰", "tech spec 리뷰", "스펙 문서 리뷰", "이 스펙 봐줘", or provides a Notion/Google Docs/Markdown tech spec link or file and asks for feedback, critique, or readiness check before sharing with the team.
tools
Draft a daily standup from the current user's Slack, GitHub, Linear, and Google Calendar activity. Use when the user asks to create, prepare, or summarize a standup/status update from connected app activity; to collect a user's work for a date; or to verify whether Slack, GitHub, Linear, and Google Calendar connectors/MCP tools are available before drafting a standup.
development
List and resume previous coding agent sessions by loading their context into the current session. Use when the user wants to (1) see previous sessions for the current directory with summaries, (2) continue work from a previous session by loading its full conversation context, (3) recover work from an interrupted session, or (4) transfer context between sessions. Supports Claude Code and Codex sessions.
development
Pre-push CodeRabbit review-fix loop. Runs local CodeRabbit review, fixes valid issues, and repeats until clean so the branch passes CodeRabbit review on push with no additional comments. Use when the user says "review and fix", "review loop", or wants to ensure the branch is CodeRabbit-clean before pushing.