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.4argument-hint: '[optional description of the work]'5---67# Create Branch89Create git branches following consistent naming conventions.10Keep this workflow non-interactive unless the user explicitly asks to choose the name manually.1112## Branch Naming Convention1314Branch names follow `<type>/<short-description>` (kebab-case, ASCII, ideally 3-6 words).1516### Branch Types1718| Type | Use when |19|------|----------|20| `feat` | New functionality |21| `fix` | Broken behavior now works |22| `ref` | Behavior stays the same, structure changes |23| `perf` | Same behavior, faster |24| `chore` | Maintenance of existing tooling/config |25| `style` | Visual or formatting only |26| `docs` | Documentation only |27| `test` | Tests only |28| `ci` | CI/CD config |29| `build` | Build system or dependencies |30| `meta` | Repo metadata |31| `license` | License changes |3233When unsure: use `feat` for new things, `ref` for restructuring, `chore` for maintenance.3435## Workflow36371. **Resolve the work description:**38 - If `$ARGUMENTS` is present, use it39 - Otherwise inspect local state:40 ```bash41 git diff42 git diff --cached43 git status --short44 ```45 - If there are local changes, derive a short description from the diff46 - If there are no local changes, use a generic description like `repo-maintenance`, `tooling-update`, or `work-in-progress`47482. **Classify the branch type** from the table above based on the work being done.49503. **Generate the branch name** as `<type>/<short-description>`. Keep `<short-description>` kebab-case, ASCII-only, ideally 3-6 words.51524. **Choose the base without prompting:**53 ```bash54 git branch --show-current55 git remote | grep -qx origin && echo origin || git remote | head -156 git symbolic-ref refs/remotes/<remote>/HEAD 2>/dev/null | sed 's|refs/remotes/<remote>/||' | tr -d '[:space:]'57 ```58 - If default branch detection fails, fall back to `main`, then `master`, then the current branch59 - If on a detached HEAD, branch from the current commit60 - If already on a non-default branch, branch from the current branch61 - Only switch to the default branch when the user explicitly asks62635. **Avoid collisions** by appending `-2`, `-3`, etc. until the name is unused locally and remotely.64656. **Create the branch:**66 ```bash67 git checkout -b <branch-name>68 ```69 Report the final branch name; do not stop for confirmation.7071## Good Branch Names7273```74feat/add-user-auth # Clear, concise, descriptive75fix/null-pointer-dashboard # Specific about what's being fixed76ref/extract-validation-logic # Clear refactoring goal77test/add-api-tests # Clear testing scope78```7980## Common Mistakes to Avoid8182| Mistake | Bad Example | Good Example |83| --------------- | --------------------------------------------- | ------------------ |84| Too long | `feature/add-authentication-system-for-users` | `feat/add-user-auth` |85| Too vague | `fix-bug` | `fix/null-pointer` |86| Wrong case | `Feat/AddAuth` | `feat/add-auth` |87| Personal prefix | `john/my-work` | `feat/feature-name` |88| Wrong separator | `feat_add_auth` | `feat/add-auth` |89| No type | `add-authentication` | `feat/add-auth` |90| Spelled-out type | `feature/add-auth` | `feat/add-auth` |9192## Handling Uncommitted Changes9394If there are uncommitted changes when you start:95- If they belong on the new branch, that's fine — `git checkout -b` carries them over96- If they belong elsewhere, stash first: `git stash`, create the branch, unstash on the correct branch9798## Related Skills99100- **commit skill**: Uses branch naming to verify commits aren't on main/master101- **create-pr skill**: Uses branch type to derive PR title prefix