/branch Command
Create a new git branch following AIKit naming conventions.
Usage
# Create a feature branch
/branch feat/new-feature
# Create a bug fix branch
/branch fix/authentication-bug
# Create a refactor branch
/branch refactor/user-service
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
<name> | string | No | Branch name with type prefix |
Branch Naming Conventions
# Feature branches
feat/<feature-name>
feat/user-authentication
feat/product-list-page
# Bug fix branches
fix/<bug-description>
fix/login-timeout
fix/api-response-error
# Refactor branches
refactor/<what-why>
refactor/extract-auth-service
refactor/cleanup-auth-middleware
# Documentation branches
docs/<what-changed>
docs/update-api-guide
docs/add-readme
# Test branches
test/<what-testing>
test/add-user-tests
test/test-api-integration
# Hotfix branches (urgent production fixes)
hotfix/<critical-issue>
hotfix/security-vulnerability
# Chore branches
chore/<what-task>
chore/update-dependencies
chore/cleanup-imports
Workflow
1. Ensure Clean State
# Check current status
git status
# Stash or commit changes
git stash # If you want to save work
# or
git add . && git commit -m "WIP: save work"
2. Update Main Branch
# Switch to main
git checkout main
# Pull latest changes
git pull origin main
# Verify you're up to date
git status
3. Create New Branch
# Create branch and switch
git checkout -b feat/new-feature
# Verify new branch
git branch
# Shows: * feat/new-feature
Examples
Feature Development
# Start new feature
/branch feat/user-profiles
# Work on feature
# ... commit changes ...
# Merge back to main
# (See: /merge)
Bug Fix
# Fix a bug
/branch fix/authentication-timeout
# Implement fix
# ... implement fix ...
# Test and merge
git checkout main
git merge fix/authentication-timeout
Refactoring
# Refactor code
/branch refactor/extract-auth-service
# Restructure while keeping tests green
# ... make changes ...
# Merge refactor
git checkout main
git merge refactor/extract-auth-service
Hotfix (Production Issue)
# Urgent production fix
/branch hotfix/security-vulnerability
# Fix immediately
# ... implement fix ...
# Merge quickly
git checkout main
git merge --no-ff hotfix/security-vulnerability
# Tag and push
git tag v1.0.1-hotfix
git push origin main --tags
Best Practices
Branch Names
✅ DO:
- Use descriptive names
- Follow type prefix conventions
- Keep names short (< 50 characters)
- Use kebab-case (hyphens not underscores)
- Be specific about what the branch does
❌ DON'T:
- Use generic names (e.g., "branch-1", "wip")
- Skip type prefix
- Use uppercase or spaces
- Create branches without purpose
Branch Lifecycle
✅ DO:
- Keep branches short-lived (< 2-3 days)
- Merge frequently to reduce conflicts
- Delete branches after merging
- Don't let branches linger
❌ DON'T:
- Let branches sit for days/weeks
- Create long-lived feature branches
- Keep merged branches around
- Let branches diverge heavily from main
Branch Management
# List branches
git branch -a
# Delete local branch
git branch -d feat/old-feature
# Delete remote branch
git push origin --delete feat/old-feature
# Track remote branches
git fetch origin
git branch -r
Related Commands
- /merge - Merge branches
- /rebase - Rebase branches
- /cherry-pick - Cherry-pick commits
- /stash - Stash changes
Related Skills
- Git Workflow - Complete git workflow guide
- Documentation - Documenting decisions
Related Documentation
- Git Workflow - Git best practices
- Commands Reference - All commands overview