Create Branch
Create git branches following consistent naming conventions.
Keep this workflow non-interactive unless the user explicitly asks to choose the name manually.
Branch Naming Convention
Branch names follow <type>/<short-description> (kebab-case, ASCII, ideally 3-6 words).
Branch Types
| Type |
Use when |
feat |
New functionality |
fix |
Broken behavior now works |
ref |
Behavior stays the same, structure changes |
perf |
Same behavior, faster |
chore |
Maintenance of existing tooling/config |
style |
Visual or formatting only |
docs |
Documentation only |
test |
Tests only |
ci |
CI/CD config |
build |
Build system or dependencies |
meta |
Repo metadata |
license |
License changes |
When unsure: use feat for new things, ref for restructuring, chore for maintenance.
Workflow
Resolve the work description:
Classify the branch type from the table above based on the work being done.
Generate the branch name as <type>/<short-description>. Keep <short-description> kebab-case, ASCII-only, ideally 3-6 words.
Choose the base without prompting:
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 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
Avoid collisions by appending -2, -3, etc. until the name is unused locally and remotely.
Create the branch:
git checkout -b <branch-name>
Report the final branch name; do not stop for confirmation.
Good Branch Names
feat/add-user-auth # Clear, concise, descriptive
fix/null-pointer-dashboard # Specific about what's being fixed
ref/extract-validation-logic # Clear refactoring goal
test/add-api-tests # Clear testing scope
Common Mistakes to Avoid
| Mistake |
Bad Example |
Good Example |
| Too long |
feature/add-authentication-system-for-users |
feat/add-user-auth |
| Too vague |
fix-bug |
fix/null-pointer |
| Wrong case |
Feat/AddAuth |
feat/add-auth |
| Personal prefix |
john/my-work |
feat/feature-name |
| Wrong separator |
feat_add_auth |
feat/add-auth |
| No type |
add-authentication |
feat/add-auth |
| Spelled-out type |
feature/add-auth |
feat/add-auth |
Handling Uncommitted Changes
If there are uncommitted changes when you start:
- If they belong on the new branch, that's fine —
git checkout -b carries them over
- If they belong elsewhere, stash first:
git stash, create the branch, unstash on the correct branch
Related Skills
- commit skill: Uses branch naming to verify commits aren't on main/master
- create-pr skill: Uses branch type to derive PR title prefix
1---2name: create-branch3description: Create git branches following naming conventions. Use when creating new feature branches, bug fix branches, or any branch for development work. Defines the branch naming standards used across commit and PR skills.4---56# Create Branch78Create git branches following consistent naming conventions.9Keep this workflow non-interactive unless the user explicitly asks to choose the name manually.1011## Branch Naming Convention1213Branch names follow `<type>/<short-description>` (kebab-case, ASCII, ideally 3-6 words).1415### Branch Types1617| Type | Use when |18|------|----------|19| `feat` | New functionality |20| `fix` | Broken behavior now works |21| `ref` | Behavior stays the same, structure changes |22| `perf` | Same behavior, faster |23| `chore` | Maintenance of existing tooling/config |24| `style` | Visual or formatting only |25| `docs` | Documentation only |26| `test` | Tests only |27| `ci` | CI/CD config |28| `build` | Build system or dependencies |29| `meta` | Repo metadata |30| `license` | License changes |3132When unsure: use `feat` for new things, `ref` for restructuring, `chore` for maintenance.3334## Workflow35361. **Resolve the work description:**37 - If `$ARGUMENTS` is present, use it38 - Otherwise inspect local state:39 ```bash40 git diff41 git diff --cached42 git status --short43 ```44 - If there are local changes, derive a short description from the diff45 - If there are no local changes, use a generic description like `repo-maintenance`, `tooling-update`, or `work-in-progress`46472. **Classify the branch type** from the table above based on the work being done.48493. **Generate the branch name** as `<type>/<short-description>`. Keep `<short-description>` kebab-case, ASCII-only, ideally 3-6 words.50514. **Choose the base without prompting:**52 ```bash53 git branch --show-current54 git remote | grep -qx origin && echo origin || git remote | head -155 git symbolic-ref refs/remotes/<remote>/HEAD 2>/dev/null | sed 's|refs/remotes/<remote>/||' | tr -d '[:space:]'56 ```57 - If default branch detection fails, fall back to `main`, then `master`, then the current branch58 - If on a detached HEAD, branch from the current commit59 - If already on a non-default branch, branch from the current branch60 - Only switch to the default branch when the user explicitly asks61625. **Avoid collisions** by appending `-2`, `-3`, etc. until the name is unused locally and remotely.63646. **Create the branch:**65 ```bash66 git checkout -b <branch-name>67 ```68 Report the final branch name; do not stop for confirmation.6970## Good Branch Names7172```73feat/add-user-auth # Clear, concise, descriptive74fix/null-pointer-dashboard # Specific about what's being fixed75ref/extract-validation-logic # Clear refactoring goal76test/add-api-tests # Clear testing scope77```7879## Common Mistakes to Avoid8081| Mistake | Bad Example | Good Example |82| --------------- | --------------------------------------------- | ------------------ |83| Too long | `feature/add-authentication-system-for-users` | `feat/add-user-auth` |84| Too vague | `fix-bug` | `fix/null-pointer` |85| Wrong case | `Feat/AddAuth` | `feat/add-auth` |86| Personal prefix | `john/my-work` | `feat/feature-name` |87| Wrong separator | `feat_add_auth` | `feat/add-auth` |88| No type | `add-authentication` | `feat/add-auth` |89| Spelled-out type | `feature/add-auth` | `feat/add-auth` |9091## Handling Uncommitted Changes9293If there are uncommitted changes when you start:94- If they belong on the new branch, that's fine — `git checkout -b` carries them over95- If they belong elsewhere, stash first: `git stash`, create the branch, unstash on the correct branch9697## Related Skills9899- **commit skill**: Uses branch naming to verify commits aren't on main/master100- **create-pr skill**: Uses branch type to derive PR title prefix