| name | create-branch |
| description | Generate a branch name from current changes and create it if on main. Use when starting new work and need a properly named feature branch. |
| allowed-tools | Bash(git branch:*), Bash(git status:*), Bash(git diff:*), Bash(git checkout:*) |
Create Branch from Changes
You are tasked with generating a meaningful branch name based on the current uncommitted changes.
Process:
-
Check current branch:
- Run
git branch --show-current
- Note whether you're on
main or another branch
-
Analyze the changes:
- Run
git status to see which files are modified/added/deleted
- Run
git diff to understand what the changes do
- If there are staged changes, also run
git diff --cached
-
Generate a branch name:
- Use format:
<type>-<short-description>
- Types (from Conventional Commits):
feat - new feature
fix - bug fix
refactor - code restructuring
docs - documentation only
chore - maintenance tasks
test - adding/updating tests
style - formatting, no code change
- Description: 2-4 words, kebab-case, lowercase
- Keep total length under 50 characters
- Examples:
feat-add-user-dashboard
fix-login-validation
refactor-api-handlers
docs-update-readme
-
Create the branch (if on main):
- If on
main: run git checkout -b <branch-name>
- If NOT on
main: just output the suggested branch name and explain you're not on main
-
Confirm success:
- Run
git branch --show-current to verify you're on the new branch
- Tell me the branch name created
Important:
- Analyze the actual content of changes, not just file names
- Choose the most appropriate type based on what the changes do
- Keep branch names concise but descriptive
- Never include issue numbers unless explicitly asked