Create Branch
Make + checkout new branch. No confirm.
Flow
- Parallel:
git status+git branch --show-current. - Dirty tree -> stop. Tell user to stash or commit first. Why ->
checkout -bcarries staged + unstaged changes into the new branch silently, mixing them with future work. - Pick base:
- Detect, don't assume:
git symbolic-ref --short refs/remotes/origin/HEAD-> strip theorigin/. Ref missing (never fetched) ->git remote set-head origin -a, re-read. No remote ->main, fall backmaster. Why -> a repo based ondeveloportrunkgets branched off the wrong parent otherwise, and the mistake surfaces at PR time as a diff full of other people's commits. - On feature branch + user wants to branch off it -> use current. Skip step 4's fetch; go to step 5 "off current" variant.
- Detect, don't assume:
- Exists?
git show-ref --verify --quiet refs/heads/<name>-> 0 = stop, surface conflict, no overwrite. Why ->checkout -berrors anyway, but check early so message is clean + no half-state. - Create:
- Off
<base>(default):git fetch origin <base>+git checkout -b <name> origin/<base>. - Off current:
git checkout -b <name>(no fetch, no remote ref — current HEAD is the base).
- Off
- Print branch + base.
Naming
<type>/<short-kebab-desc> or <type>/<scope>-<short-kebab-desc>.
Whole name ≤ 60 chars.
Type
Same set + picks as git-commit. See that skill's Type pick + Tiebreakers for disambiguation. Quick list: feat|fix|perf|refactor|docs|test|build|ci|chore.
Desc
- kebab-case. Not camel / snake.
- Imperative present:
add,fix,remove. Notadded,fixes. - < ~50 chars, and keeps the whole name ≤ 60. Over -> drop the scope segment first, then cut modifiers, then pick a shorter verb. Never truncate mid-word:
feat/add-oauth-logreads like a different feature. - No ticket IDs unless asked. Why -> history readable + tool-agnostic; trackers come+go, branches stay. Asked -> suffix:
feat/add-auth-middleware-PROJ-123.
Examples
feat/add-oauth-loginfix/api-timeout-on-retryrefactor/extract-user-servicedocs/update-readmeci/cache-pnpm-store
Rules
- Derive
type+ desc from intent + diff if avail. - User gives name -> verbatim. No rewrite.
- Never delete/reset existing branches here.
- Never push new branch unless asked.
- Branch exists -> stop. Surface conflict. No overwrite.