Create Branch

作者 getsentryd18b7aa8ba87无许可证1K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库5天前更新

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.

AI 生成的概览

按照 Sentry 命名规范创建 git 分支,并根据当前工作推导分支类型和描述。

功能
该技能引导智能体创建符合 Sentry 风格的分支名,格式为 type/short-description。它会根据用户提供的参数或本地 git 变更确定工作描述,对分支类型(feat、fix、ref、chore 等)进行分类,并在不询问的情况下选择基础分支。随后通过追加数字后缀避免重名,执行 git checkout -b,并报告最终分支名。
适用场景
当被要求创建、开始、新建或切换到新分支时,或在默认分支上开始新工作时使用。适用于遵循 Sentry 分支命名规范的代码仓库。
运行要求
需要 git 仓库以及智能体可用的 git 命令行工具。不包含脚本或凭据,仅为指令说明。

Create Branch

Create a git branch following Sentry naming conventions. Keep this workflow non-interactive unless the user explicitly asks to choose the name manually.

Workflow

  1. Resolve the work description:

    • If $ARGUMENTS is present, use it
    • Otherwise inspect:
      bash
      git diffgit diff --cachedgit status --short
    • If there are local changes, derive a short description from the diff
    • If there are no local changes, use a generic description like repo-maintenance, tooling-update, or work-in-progress
  2. Classify the branch type:

TypeUse when
featNew functionality
fixBroken behavior now works
refBehavior stays the same, structure changes
choreMaintenance of existing tooling/config
perfSame behavior, faster
styleVisual or formatting only
docsDocumentation only
testTests only
ciCI/CD config
buildBuild system
metaRepo metadata
licenseLicense changes

When unsure: use feat for new things, ref for restructuring, chore for maintenance.

  1. Generate <type>/<short-description>. Keep <short-description> kebab-case, ASCII-only, and ideally 3 to 6 words.

  2. Choose the base without prompting:

    bash
    git branch --show-currentgit remote | grep -qx origin && echo origin || git remote | head -1git symbolic-ref refs/remotes/<remote>/HEAD 2>/dev/null | sed 's|refs/remotes/<remote>/||' | tr -d '[:space:]'
    • If default branch detection fails, fall back to main, then master, then the current branch
    • If on a detached HEAD, branch from the current commit
    • If already on a non-default branch, branch from the current branch
    • Only switch to the default branch when the user explicitly asks
  3. Avoid collisions by appending -2, -3, and so on until the name is unused locally and remotely.

  4. Create the branch:

    bash
    git checkout -b <branch-name>

    Report the final branch name, but do not stop for confirmation.

References

来源与署名

来源:getsentry/skills位于skills/create-branch提交d18b7aa

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架