CC-301e · Module 1

Branch Creation Automation

3 min read

Claude Code can create branches, switch between them, and manage their lifecycle — but only if you tell it the rules. Without explicit instructions, Claude will work on whatever branch is currently checked out, which might be main. The first rule in your CLAUDE.md git section should be: "Never commit directly to main. Always create a feature branch first."

The second rule should specify naming. "Branch names follow the pattern: type/description where type is one of feature, fix, refactor, test, docs." Claude follows naming conventions reliably when they are specified explicitly. It generates descriptive branch names that match the convention: feature/add-user-auth, fix/null-pointer-dashboard, refactor/extract-api-layer.

## Git Workflow
- NEVER commit directly to main
- Create a feature branch before making changes
- Branch naming: `type/description` where type = feature|fix|refactor|test|docs
- Commit messages: conventional commits (feat:, fix:, refactor:, test:, docs:)
- Keep commits atomic — one logical change per commit