Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计未展示

rename-branch重命名分支

Agent Skill

rename-branch 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

599

周安装

24

GitHub Stars

公开资料未说明

下载量

194
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:rename-branch(重命名分支)
来源仓库:https://github.com/pitzcarraldo/skills
仓库路径:skills/rename-branch
安装命令:
npx skills add pitzcarraldo/skills --skill "rename-branch"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add pitzcarraldo/skills --skill "rename-branch"

简介

rename-branch 用于查找、检索和筛选相关信息,适合在开发环境中快速定位分支管理相关内容。

  • 适用于需要根据关键词、任务场景或来源线索进行信息检索的场景。
  • 通过 npx skills add pitzcarraldo/skills --skill "rename-branch" 安装使用。
  • 建议确认权限范围和维护状态,注意是否触发联网或文件读写操作。
  • 可结合来源仓库和原始 README 进一步核验具体用法和功能细节。

SKILL.md

name
rename-branch
description
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.
metadata
short-description
Rename branch based on changes
user-invocable
true

Branch Rename Skill

Overview

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.

Naming Convention

Format

<type>/<description>

Branch Type Prefixes

PrefixPurposeExamples
feat/New featuresfeat/user-auth, feat/dark-mode
fix/Bug fixesfix/null-pointer, fix/memory-leak
docs/Documentationdocs/api-guide, docs/setup
style/Formattingstyle/prettier, style/lint-rules
refactor/Code restructuringrefactor/extract-utils, refactor/simplify-logic
perf/Performanceperf/cache-queries, perf/lazy-load
test/Testingtest/unit-coverage, test/e2e-auth
build/Build systembuild/webpack-config, build/deps
ci/CI/CDci/github-actions, ci/deploy
chore/Maintenancechore/cleanup, chore/update-deps

Description Guidelines

  • Kebab-case: lowercase words separated by hyphens
  • Length: 20 characters or less (excluding prefix)
  • Imperative mood: "add" not "added", "fix" not "fixed"
  • Specific: Clearly describes the primary change
  • Concise: No unnecessary words

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)

Workflow

1. Verify Git Repository Status

Check if we're in a valid git repository:

git rev-parse --git-dir 2>&1

Expected output:

  • Success: .git or path to git directory
  • Failure: "not a git repository" error

Check 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]

2. Identify Base Branch

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.

3. Analyze Changes

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:

  • List of modified files with paths
  • Number of insertions and deletions
  • Commit messages for context
  • File patterns (identify directories/modules)

4. Determine Branch Type

Apply pattern matching logic:

File-based Detection

# 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

Content-based Detection

# 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

Multiple Types

If changes span multiple types:

  1. Count file changes per type
  2. Select the type with most changes
  3. If tie, prioritize: feat > fix > refactor > others

5. Generate Description

Extract meaningful description from changes:

  1. Identify primary module/component:
   # From file paths: src/auth/login.ts → "auth"
   # From multiple files in same dir → use directory name
  1. Extract action from commits:
   # From commit messages like "Add OAuth support"
   # Extract: "oauth-support"
  1. Combine module + action:
   # If module: "auth", action: "oauth"
   # Result: "auth-oauth"

   # If action already includes module context
   # Result: just use action
  1. 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:

CommitsFilesGenerated Description
"Add OAuth login"src/auth/oauth.tsoauth-login
"Fix null pointer in payment"src/payment/process.tspayment-null-ptr
"Update API docs"docs/api.mdapi-docs
"Refactor validation utils"src/utils/validation.tsvalidation-utils
"Optimize database queries"src/db/query.tsdb-queries

6. Construct New Branch Name

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

7. Check Current Branch Name

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

8. Rename Branch

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

9. Display Results and Instructions

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

Examples

Example 1: Feature Addition

Scenario:

  • Current branch: feature-branch
  • Changes: Added user authentication with OAuth

Commands 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:

  • Type: feat (new functionality)
  • Primary module: auth
  • Action: oauth-login
  • Description: oauth-login (16 chars)

Result:

Old: feature-branch
New: feat/oauth-login

Reason: Detected new authentication feature in auth module

Example 2: Bug Fix

Scenario:

  • Current branch: bugfix
  • Changes: Fixed null pointer exception in payment processing

Commands 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:

  • Type: fix (bug fix keywords)
  • Primary module: payment
  • Issue: null-pointer
  • Description: payment-null-ptr (17 chars)

Result:

Old: bugfix
New: fix/payment-null-ptr

Reason: Detected bug fix in payment processing module

Example 3: Documentation

Scenario:

  • Current branch: update-docs
  • Changes: Updated API documentation

Commands 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:

  • Type: docs (documentation files)
  • Focus: api-v2
  • Description: api-v2-guide (12 chars)

Result:

Old: update-docs
New: docs/api-v2-guide

Reason: Detected documentation updates for API v2

Example 4: Refactoring

Scenario:

  • Current branch: cleanup
  • Changes: Extracted validation logic into utilities

Commands 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:

  • Type: refactor (code restructuring)
  • Module: validation
  • Action: extract-validation
  • Description: validation-utils (16 chars)

Result:

Old: cleanup
New: refactor/validation-utils

Reason: Detected refactoring of validation logic into utils

Example 5: Multiple Change Types

Scenario:

  • Current branch: various-updates
  • Changes: Added feature, fixed bugs, updated docs

Commands 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:

  • Mixed types: feat (120 lines), fix (8 lines), docs (10 lines)
  • Primary type: feat (most significant change)
  • Focus: oauth from largest change
  • Description: oauth-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)

Technical Requirements

Required Tools

ToolPurposeCheck Command
GitVersion controlgit --version
BashShell scriptingbash --version

Minimum Versions

  • Git: 2.0 or higher (for git diff ... syntax)
  • Bash: 4.0 or higher

Git Configuration

No special configuration required, but recommended:

# Set default branch name (optional)
git config --global init.defaultBranch main

Best Practices

  1. Run before pushing: Rename branches early before pushing to remote
  2. One focus per branch: Branches with mixed purposes are harder to name
  3. Keep descriptions clear: Prioritize clarity over brevity
  4. Follow team conventions: Adjust type prefixes if team uses different standards
  5. Update PR titles: If PR exists, update title to match new branch name
  6. Communicate changes: Inform team members if renaming shared branches

Limitations

  1. Single branch focus: Best results when branch has one primary purpose
  2. 20-character limit: Very long descriptions get truncated
  3. English descriptions: Generated names are in English
  4. No semantic analysis: Cannot understand complex business logic
  5. Pattern-based: Relies on file patterns and keywords
  6. Local operation: Does not automatically update remote branches

Error Handling

Common Errors and Solutions

Error: Not a git repository

  • Cause: Current directory is not a git repository
  • Solution: Navigate to git repository or run git init

Error: Detached HEAD state

  • Cause: Not on any branch (e.g., checked out specific commit)
  • Solution: Create new branch with git checkout -b <name>

Error: Cannot determine base branch

  • Cause: No main/master branch exists
  • Solution: Create base branch or specify manually

Error: No changes detected

  • Cause: Branch is synchronized with base or has no commits
  • Solution: No action needed, branch is up to date

Error: Branch name already exists

  • Cause: Generated name conflicts with existing branch
  • Solution: Tool automatically appends number (e.g., feat/auth-2)

Error: Invalid ref format

  • Cause: Generated name contains invalid characters
  • Solution: Tool sanitizes automatically, but check for edge cases

Advanced Features

Custom Base Branch

Allow user to specify different base branch:

# Compare against different branch
git diff custom-base...HEAD --stat

Interactive Mode

Confirm before renaming:

Generated branch name: feat/oauth-login

Current: feature-branch
New:     feat/oauth-login

Proceed with rename? [y/n]

Dry Run Mode

Show what would happen without actually renaming:

# Simulate rename
echo "Would rename: $old_branch → $new_branch"
# Skip actual git branch -m command

Preserve Remote Connection

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"

References

  • Git Branch Documentation: https://git-scm.com/docs/git-branch
  • Conventional Commits: https://www.conventionalcommits.org/
  • Git Best Practices: https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project

Notes

  • Branch renaming is a local operation by default
  • Remote branches must be updated separately if already pushed
  • Pull requests may need manual update after branch rename
  • Team members should be notified of branch name changes
  • Consider branch protection rules when renaming
  • Some CI/CD systems may be configured for specific branch names

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.28%
按下载量换算53

windsurf

21.52%
按下载量换算42

trae

16.95%
按下载量换算33

OpenCode

12.69%
按下载量换算25

Codex

7.28%
按下载量换算14

Antigravity

3.58%
按下载量换算7

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills