agentleFS
CarpeWuCarpeWu/claude-git-skills/skills/git-branch/SKILL.md

git-branch

Skill0 starsChanged 10 months agoMITView on GitHub

Creates Git branches following naming conventions. Use when creating feature, bugfix, hotfix, or release branches, or when the user asks to create a new branch.

  • Commits and pushes

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Git Branch

按规范创建 Git 分支

Context

  • 当前分支: !git branch --show-current
  • 本地分支列表: !git branch
  • 远程分支列表: !git branch -r | head -20
  • 工作区状态: !git status --short

Branch Conventions

类型前缀来源分支合并目标用途
功能feature/developdevelop新功能开发
修复bugfix/developdevelop非紧急 bug 修复
热修复hotfix/mainmain + develop生产紧急修复
发布release/developmain + develop版本发布准备

命名规则:

  • 格式:<type>/<简短描述>
  • 使用小写字母和连字符
  • 长度建议 ≤ 50 字符
  • 示例:feature/user-authentication、bugfix/login-validation

Workflow

Step 1: 解析输入

检查用户是否提供了参数:

情况 A:有参数 - 解析 <type> <description> 格式

情况 B:无参数 - 交互式询问:

🌿 创建新分支

请选择分支类型:
  1. feature  - 新功能
  2. bugfix   - Bug 修复
  3. hotfix   - 紧急修复
  4. release  - 版本发布

请输入编号或类型名称:

然后询问分支描述。


Step 2: 前置检查

📋 前置检查:
├─ [✓/✗] 分支名称有效
├─ [✓/✗] 分支不存在(本地)
├─ [✓/✗] 分支不存在(远程)
├─ [✓/✗] 来源分支存在
└─ [✓/!] 工作区状态(干净/有未提交变更)

如果有未提交变更:

⚠️ 检测到未提交的变更:
   M src/api/user.py

请选择:
  1. stash - 暂存变更后继续
  2. cancel - 取消操作,先处理变更

如果分支已存在:

⚠️ 分支已存在: feature/user-auth

请选择:
  1. switch - 切换到该分支
  2. rename - 使用新名称
  3. cancel - 取消操作

Step 3: 展示预览

╭─────────────────────────────────────────────────────╮
│  🌿 创建分支预览                                    │
╰─────────────────────────────────────────────────────╯

📝 分支信息:
   名称: feature/user-authentication
   类型: feature(新功能)
   来源: develop

📋 将执行的操作:
   1. git fetch origin develop
   2. git checkout develop
   3. git pull origin develop
   4. git checkout -b feature/user-authentication

❓ 是否继续?
   • 输入 "ok" → 执行创建
   • 输入 "push" → 创建并推送到远程
   • 输入 "cancel" → 取消

Step 4: 执行创建

根据用户确认执行:

# 基础流程
git fetch origin develop
git checkout develop
git pull origin develop
git checkout -b feature/user-authentication

# 如果用户选择 push
git push -u origin feature/user-authentication

成功输出:

✅ 分支创建成功!

🌿 feature/user-authentication
├─ 本地: ✓ 已创建
├─ 远程: ✓ 已推送 (或 ✗ 未推送)
└─ 当前: ✓ 已切换

💡 下一步:
   • 开始开发...
   • 完成后提交代码

Error Handling

情况处理
来源分支不存在❌ 分支 develop 不存在\n💡 请先创建或拉取该分支
网络问题❌ 无法连接远程仓库\n💡 请检查网络或 git remote 配置
命名不规范自动修正:user auth → user-auth

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.