# Branching Strategy ClaudeForge uses a **Standard Branching Strategy** with protected branches and automated quality gates. ## Overview ``` feature/*, fix/*, hotfix/* → dev → main ↓ ↓ ↓ Development Testing Production ``` **Three permanent branches:** - `main` - Production-ready code, always deployable - `dev` - Integration branch for features - *(temporary)* - Feature, fix, and hotfix branches **Branch protection:** - ✅ No direct commits to main or dev - ✅ All changes via pull requests - ✅ Automated quality gates required - ✅ Conventional Commits enforced - ✅ Linear history (squash merges) --- ## Branch Types ### Main Branch **Purpose:** Production-ready releases only **Protection Rules:** - ✅ Require pull request before merging - ✅ Require status checks to pass: `quality-gates`, `production-build` - ✅ Require linear history (squash merges only) - ✅ No force pushes - ✅ No deletions - ✅ Require review from CODEOWNERS **Who can merge:** - Only `dev`, `release/*`, or `dependabot/*` branches - After passing dev-to-main.yml workflow **Triggers:** - dev-to-main.yml workflow on PR - release.yml workflow for GitHub releases **Typical state:** - Always matches latest GitHub release - Only updated when releasing new version - Every commit corresponds to a version tag (v1.0.0, v1.1.0, etc.) --- ### Dev Branch **Purpose:** Integration branch for all features **Protection Rules:** - ✅ Require pull request before merging - ✅ Require status checks to pass: `quality-gates`, `validate-pr` - ✅ Require linear history (squash merges only) - ✅ No force pushes - ✅ No deletions **Who can merge:** - Feature branches (`feature/*`) - Fix branches (`fix/*`) - Hotfix branches (`hotfix/*`) - Test branches (`test/*`) - Refactor branches (`refactor/*`) - Docs branches (`docs/*`) **Triggers:** - pr-into-dev.yml workflow on PR **Typical state:** - Contains completed features awaiting release - Ahead of main by several commits - Reset to main only after release (via merge) --- ### Feature Branches **Naming Convention:** `feature/` **Purpose:** New features or enhancements **Examples:** - `feature/add-rust-templates` - `feature/vscode-extension` - `feature/ai-suggestions` **Lifecycle:** 1. Create from latest `dev`: `git checkout dev && git pull && git checkout -b feature/my-feature` 2. Make changes, commit with Conventional Commits 3. Push to origin: `git push -u origin feature/my-feature` 4. Create PR to `dev` 5. Pass quality gates and code review 6. Squash merge to `dev` 7. Delete feature branch **PR Requirements:** - ✅ Title must follow Conventional Commits: `feat(scope): description` - ✅ At least one linked issue (recommended) - ✅ All quality gates pass - ✅ Code review approved (if CODEOWNERS configured) --- ### Fix Branches **Naming Convention:** `fix/` **Purpose:** Bug fixes **Examples:** - `fix/installer-windows-path` - `fix/python-syntax-validation` - `fix/broken-markdown-links` **Lifecycle:** Same as feature branches, but: - PR title prefix: `fix(scope): description` - Link to bug issue with `Fixes #123` or `Closes #123` **PR Requirements:** - ✅ Title: `fix(scope): description` - ✅ Linked to bug issue - ✅ Quality gates pass - ✅ Test fix if applicable --- ### Hotfix Branches **Naming Convention:** `hotfix/` **Purpose:** Urgent fixes for production issues **Examples:** - `hotfix/critical-installer-bug` - `hotfix/security-patch` **Lifecycle:** 1. Create from `dev`: `git checkout dev && git pull && git checkout -b hotfix/issue-name` 2. Make minimal fix 3. Create PR to `dev` 4. After merge to dev, immediately create PR dev → main 5. Fast-track review and merge **PR Requirements:** - ✅ Title: `fix(scope): description` or `hotfix(scope): description` - ✅ Link to critical issue - ✅ Quality gates pass (can be expedited) - ✅ Fast-track review **Special considerations:** - Prioritize speed over perfection - Minimal changes only - Document reason for hotfix in PR description --- ### Test Branches **Naming Convention:** `test/` **Purpose:** Testing experiments or validations **Examples:** - `test/new-quality-gate` - `test/workflow-validation` **Lifecycle:** - Same as feature branches - PR title: `test(scope): description` - May not require linked issue --- ### Refactor Branches **Naming Convention:** `refactor/` **Purpose:** Code improvements without changing functionality **Examples:** - `refactor/simplify-analyzer` - `refactor/improve-error-handling` **Lifecycle:** - Same as feature branches - PR title: `refactor(scope): description` - Should not change external behavior --- ### Docs Branches **Naming Convention:** `docs/` **Purpose:** Documentation-only changes **Examples:** - `docs/update-installation-guide` - `docs/add-troubleshooting-section` **Lifecycle:** - Same as feature branches - PR title: `docs: description` or `docs(scope): description` - Can skip some quality gates (Python, Bash) --- ## Workflow Diagrams ### Standard Feature Flow ``` Developer's machine: git checkout dev git pull origin dev git checkout -b feature/add-templates # Make changes git add . git commit -m "feat(skill): add Rust template support" git push -u origin feature/add-templates GitHub: Create PR: feature/add-templates → dev ↓ pr-into-dev.yml runs: ├─ Branch name validation ✅ ├─ PR title validation ✅ ├─ Linked issue check ⚠️ ├─ Quality gates ✅ └─ Ready for review Code review + approval ↓ Squash and merge to dev ↓ Delete feature branch ``` ### Release Flow ``` Dev branch ready for release: ├─ All features merged ├─ CHANGELOG.md updated └─ Version bumped GitHub: Create PR: dev → main ↓ dev-to-main.yml runs: ├─ Source branch validation ✅ (dev allowed) ├─ CHANGELOG.md check ✅ ├─ Version consistency ✅ ├─ Quality gates ✅ ├─ Production build validation ✅ └─ Ready for production Approval + merge to main ↓ Run release.yml workflow: ├─ Input version: 1.1.0 ├─ Validate version format ✅ ├─ Extract CHANGELOG notes ✅ ├─ Create GitHub release ✅ └─ Tag created: v1.1.0 Result: ├─ main branch updated ├─ GitHub release published ├─ Installable via one-line command └─ Ready for announcements ``` ### Hotfix Flow ``` Critical production bug discovered: Developer's machine: git checkout dev git pull origin dev git checkout -b hotfix/critical-installer-bug # Make minimal fix git commit -m "fix(installer): resolve critical Windows path issue" git push -u origin hotfix/critical-installer-bug GitHub: Create PR: hotfix/critical-installer-bug → dev ↓ pr-into-dev.yml runs (expedited review) ↓ Merge to dev ↓ Immediately create PR: dev → main ↓ dev-to-main.yml runs (fast-track) ↓ Merge to main ↓ Create hotfix release: v1.0.1 ``` --- ## Branch Protection Configuration ### Configure Main Branch Protection 1. Go to Settings → Branches → Add rule 2. Branch name pattern: `main` 3. Enable: - ✅ Require a pull request before merging - ✅ Require approvals: 1 (if team) - ✅ Dismiss stale reviews - ✅ Require review from Code Owners - ✅ Require status checks to pass before merging - ✅ Require branches to be up to date - Add required checks: - `quality-gates` - `production-build` - `validate-release-pr` - ✅ Require conversation resolution before merging - ✅ Require linear history - ✅ Do not allow bypassing the above settings 4. Under "Rules applied to everyone including administrators": - ✅ Restrict deletions - ✅ Block force pushes 5. Save changes ### Configure Dev Branch Protection 1. Go to Settings → Branches → Add rule 2. Branch name pattern: `dev` 3. Enable: - ✅ Require a pull request before merging - Require approvals: 0 (can be 1 if team) - ✅ Require status checks to pass before merging - Add required checks: - `quality-gates` - `validate-pr` - ✅ Require linear history - ✅ Do not allow bypassing the above settings 4. Under "Rules applied to everyone including administrators": - ✅ Restrict deletions - ✅ Block force pushes 5. Save changes --- ## Commit Message Guidelines ClaudeForge uses **Conventional Commits** format. ### Format ``` ():