Branch SKILL
Context
- Repo check (
(no repo)means this directory is not under git): !out=$(git rev-parse --show-toplevel 2>/dev/null) || true; printf '%s\n' "${out:-(no repo)}" - Current branch: !
out=$(git branch --show-current 2>/dev/null) || true; printf '%s\n' "${out:-(no branch — detached HEAD, or no repo)}" - Existing branches: !
out=$(git branch --list 2>/dev/null) || true; printf '%s\n' "${out:-(no branches yet)}" - Recent commits: !
out=$(git log --oneline -5 2>/dev/null) || true; printf '%s\n' "${out:-(no commits yet)}" - Git status: !
out=$(git status --short 2>/dev/null) || true; printf '%s\n' "${out:-(working tree clean)}"
Your task
Create a properly named git branch following ${CLAUDE_PLUGIN_ROOT}/skills/branch/references/conventional-branch-1.0.0.md conventions.
Step 0 — Confirm there is a repo
If the repo check in the context reads (no repo), this directory is not under
version control. Say so, point the user at init to create the repo, and stop —
nothing below applies until there is one.
Step 1 — Determine branch type
Analyze the user's request to determine the appropriate branch prefix:
| Prefix | When to use |
|---|---|
feat/ |
New feature or capability |
fix/ |
Bug fix |
hotfix/ |
Urgent fix for production |
release/ |
Preparing a versioned release |
chore/ |
Non-code tasks (deps, docs, CI, cleanup) |
If the user's intent is ambiguous, use AskUserQuestion to settle it — list the plausible prefixes as options, most likely first, each with a one-line explanation of why it fits. Never guess a prefix silently.
Step 2 — Compose branch name
Build the branch name as <type>/<description>:
- Use lowercase alphanumerics and hyphens only (dots allowed in release versions)
- No consecutive, leading, or trailing hyphens or dots
- Keep it concise but descriptive
- Include ticket numbers when the user mentions them (e.g.,
feat/issue-123-add-login)
Examples:
- "Add a search feature" →
feat/add-search - "Fix the login bug from ticket #42" →
fix/issue-42-login-bug - "Update dependencies" →
chore/update-dependencies - "Prepare release 2.1.0" →
release/v2.1.0 - "Critical security patch" →
hotfix/security-patch
Step 3 — Confirm with user
Confirm with AskUserQuestion — this is the only way this skill takes approval, never a plain-text "shall I?":
- Show the proposed branch name
- Show the base branch it will be created from (current branch)
- Offer options: "Create it! / Change name / Change type / Cancel"
If the user picks "Change name" or "Change type", apply their input and re-ask. Nothing is created until this step returns approval.
Step 4 — Create and switch
- Check for uncommitted changes — if the working directory is dirty, list the files and use AskUserQuestion: "Create the branch anyway (changes carry over) / Cancel and deal with them first".
- If a branch with the same name already exists, use AskUserQuestion to offer
the alternatives: switch to the existing branch, use a suffixed name (
-2, ticket number), or cancel. Never force-create over an existing branch. - Create the branch:
git switch -c <branch-name> - Confirm success with the new branch name
Integration
- Before this skill: Make sure you're on the right base branch
- After this skill: Use
committo make conventional commits on the new branch (commit) - End of work: Use
mergeto bring the branch into its target (merge)
Rules
- Always validate branch names against the spec before creating
- Every decision the user has to make goes through AskUserQuestion — branch type, final name, dirty tree, name collision. Never ask in prose and wait for a typed reply
- Never force-create branches that overwrite existing ones without explicit confirmation
- NEVER include co-authoring or attribution references
- Any git command you run during the task must be written so a non-zero exit
cannot abort the step. Use
out=$(<command> 2>/dev/null) || true; printf '%s\n' "${out:-(marker)}", the same form the context block uses. Several git commands report an ordinary, expected answer through a non-zero status —check-ignoreexits1for "not ignored",config --getexits1for "unset",config --unsetexits5for "was not set",rev-parse HEADexits128on a repo with no commits — and an unguarded one of those reads as a crash and stops work that should have continued - Do not re-run a context command just to confirm what is already printed above. Do re-check when its output contradicts itself or carries a shell error — a wrong answer is worth verifying — but re-run it in the guarded form, never bare, or the check fails the same way the original did
- Never put an unquoted glob (
README*,*.md) in a command. Shells disagree about an unmatched one: bash andshpass it through literally, zsh aborts the whole command before it runs and printsno matches found— which no2>/dev/nullcan suppress, because the shell emits it during expansion rather than the command emitting it. The result is a confident wrong answer. List the directory and filter it instead:ls -A | grep -iE "^(readme|license)"