Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add CarpeWu/skills --skill "git-branch"
Install specific skill from multi-skill repository
# Description
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.
# SKILL.md
name: git-branch
description: 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.
Git Branch
按规范创建 Git 分支
Context
- 当前分支: !
git branch --show-current - 本地分支列表: !
git branch - 远程分支列表: !
git branch -r | head -20 - 工作区状态: !
git status --short
Branch Conventions
| 类型 | 前缀 | 来源分支 | 合并目标 | 用途 |
|---|---|---|---|---|
| 功能 | feature/ |
develop | develop | 新功能开发 |
| 修复 | bugfix/ |
develop | develop | 非紧急 bug 修复 |
| 热修复 | hotfix/ |
main | main + develop | 生产紧急修复 |
| 发布 | release/ |
develop | main + 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 |
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.