跳到正文
Skillpedia
部署与云(DevOps)48k · #4278

create-branch

它能做什么

在你的代码项目中创建一个新的“分支”,用来组织你的工作。它会根据你正在做的事情和命名规范,推荐一个分支名称。

适用场景

  • ✓当你想开始开发一个新功能时。
  • ✓当你需要修复 bug,并希望把修复工作单独隔离出来时。
  • ✓当你开始新的工作,但不确定该怎么给分支命名时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/create-branch/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/create-branch/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想创建一个分支,给会话页面添加搜索栏。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会先尝试确定你的用户名,然后查看你在代码中修改了什么,或者询问你打算做什么。根据这些信息,它会按照特定的格式推荐一个分支名称。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Create Branch

Create a git branch with the correct type prefix and a descriptive name following Sentry conventions.

When to Use

  • You need to create a new git branch that follows the repository's naming convention.
  • You are starting a new piece of work from the default branch and need help classifying it as feat, fix, docs, or another branch type.
  • You want the branch name proposed from either the task description or the current local diff.

Step 1: Get the Username Prefix

Run gh api user --jq .login to get the GitHub username.

If the command fails (e.g. not authenticated), ask the user for their preferred prefix.

Step 2: Determine the Branch Description

If $ARGUMENTS is provided, use it as the description of the work.

If no arguments, check for local changes:

git diff
git diff --cached
git status --short
  • Changes exist: read the diff content to understand what the work is about and generate a description.
  • No changes: ask the user what they are about to work on.

Step 3: Classify the Type

Pick the type from this table based on the description:

Type Use when
feat New user-facing functionality
fix Broken behavior now works
ref Same behavior, different structure
chore Deps, config, version bumps, updating existing tooling — no new logic
perf Same behavior, faster
style CSS, formatting, visual-only
docs Documentation only
test Tests only
ci CI/CD config
build Build system
meta Repo metadata changes
license License changes

When unsure: feat for new things (including new scripts, skills, or tools), ref for restructuring existing things, chore only when updating/maintaining something that already exists.

Step 4: Generate and Propose

Build the branch name as <username>/<type>/<short-description>.

Rules for <short-description>:

  • Kebab-case, lowercase
  • 3 to 6 words, concise but clear
  • Describe the change, not file names
  • Only use ASCII letters, digits, and hyphens — no spaces, dots, colons, tildes, or other git-forbidden characters

Present it to the user and ask if they want to use it, modify it, or change the type.

Examples

Work description Branch name
Dropdown menu not closing on outside click priscila/fix/dropdown-not-closing-on-blur
Adding search to conversations page priscila/feat/add-search-to-conversations
Restructuring drawer components priscila/ref/simplify-drawer-components
Updating test fixtures priscila/chore/update-test-fixtures
Bumping @sentry/react to latest version priscila/chore/bump-sentry-react
Adding a new agent skill priscila/feat/add-create-branch-skill

Step 5: Create the Branch

Once confirmed, detect the current and default branch:

git branch --show-current
git remote | grep -qx origin && echo origin || git remote | head -1
git symbolic-ref refs/remotes/<remote>/HEAD 2>/dev/null | sed 's|refs/remotes/<remote>/||' | tr -d '[:space:]'

If symbolic-ref fails, fall back to git branch --list main master: use the one that exists; if both or neither exist, ask the user.

If git branch --show-current is empty (detached HEAD), show the current commit (git rev-parse --short HEAD) and ask whether to branch from it or switch to the default branch first.

…

常见问题

什么是代码“分支”?

可以把分支想象成项目的一份独立副本,你可以在上面修改而不影响主版本。它很适合用来做实验或开发新功能。

分支名称为什么重要?

好的名称能让人快速了解这个分支的用途,方便与他人协作,也有助于整理项目。

“feat”“fix”这类类型是什么意思?

它们是标明分支用途的标签:“feat”表示新功能,“fix”表示修复 bug,“docs”表示文档等。这有助于整理工作。

详情

作者的原始描述

Create a git branch following Sentry naming conventions. Use when asked to "create a branch", "new branch", "start a branch", "make a branch", "switch to a new branch", or when starting new work on the default branch.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4278
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能