-
Notifications
You must be signed in to change notification settings - Fork 0
docs: Add comprehensive hybrid workflow documentation #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,198 @@ | ||||||||||||||||||||||||
| # Hybrid Workflow Guide | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| This repository uses a hybrid workflow that balances automation with human oversight, optimized for Claude Code CLI development while maintaining best practices for collaborative work. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| The hybrid workflow uses two primary branches: | ||||||||||||||||||||||||
| - **`main`** - Protected, stable branch for production-ready code | ||||||||||||||||||||||||
| - **`dev`** - Active development branch with relaxed rules for rapid iteration | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Key Principles | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 1. **Incremental Development**: Small, focused commits and PRs | ||||||||||||||||||||||||
| 2. **Automated Synchronization**: Nightly rebases keep branches in sync | ||||||||||||||||||||||||
| 3. **Smart Automation**: Automate repetitive tasks, keep human oversight for critical decisions | ||||||||||||||||||||||||
| 4. **Clear Conventions**: Consistent naming and process standards | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Branch Strategy | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Main Branch | ||||||||||||||||||||||||
| - **Purpose**: Stable, production-ready code | ||||||||||||||||||||||||
| - **Protection**: Strict (requires reviews, all checks passing) | ||||||||||||||||||||||||
| - **Merge Strategy**: Squash and merge | ||||||||||||||||||||||||
| - **Who can push**: Nobody directly (PR only) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Dev Branch | ||||||||||||||||||||||||
| - **Purpose**: Active development and integration | ||||||||||||||||||||||||
| - **Protection**: Relaxed (no reviews required, allows force push) | ||||||||||||||||||||||||
| - **Merge Strategy**: Regular merges or rebases | ||||||||||||||||||||||||
| - **Who can push**: Developers after PR merge | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Feature Branches | ||||||||||||||||||||||||
| - **Naming**: `feat/`, `fix/`, `docs/`, `test/`, `chore/` prefixes | ||||||||||||||||||||||||
| - **Base**: Usually `dev`, occasionally `main` for hotfixes | ||||||||||||||||||||||||
| - **Lifecycle**: Create → Develop → PR → Merge → Delete | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Workflows | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### 1. Starting New Work | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| # Use the claude-branch script for easy branch creation | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh my-new-feature | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Or with a draft PR | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh my-new-feature --pr | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # For fixes targeting main | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh critical-fix --base main --pr | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### 2. Development Process | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### Commit Standards | ||||||||||||||||||||||||
| - Maximum 30 files per commit | ||||||||||||||||||||||||
| - Maximum 800 lines per commit | ||||||||||||||||||||||||
| - Use conventional commit format: `type(scope): description` | ||||||||||||||||||||||||
| - Commit frequently (approximately every 30 minutes of active work) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### Pushing Changes | ||||||||||||||||||||||||
| - Auto-push is enabled for single source of truth | ||||||||||||||||||||||||
| - Use `--force-with-lease` for safety when needed | ||||||||||||||||||||||||
| - Pre-commit hooks ensure standards compliance | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### 3. Pull Request Process | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### To Dev Branch | ||||||||||||||||||||||||
| - No review required (but welcomed) | ||||||||||||||||||||||||
| - Small PRs (<200 lines) auto-merge when approved | ||||||||||||||||||||||||
| - Focus on rapid iteration | ||||||||||||||||||||||||
| - CI must pass | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### To Main Branch | ||||||||||||||||||||||||
| - Requires 1 approval | ||||||||||||||||||||||||
| - All conversations must be resolved | ||||||||||||||||||||||||
| - Branch must be up-to-date | ||||||||||||||||||||||||
| - More thorough review expected | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### 4. Automated Processes | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### Nightly Rebase (3 AM UTC) | ||||||||||||||||||||||||
| - Automatically rebases `dev` onto `main` | ||||||||||||||||||||||||
| - Creates PR for conflicts requiring manual resolution | ||||||||||||||||||||||||
| - Sends notifications on success/failure | ||||||||||||||||||||||||
| - Cleans up old rebase branches after 7 days | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### PR Management | ||||||||||||||||||||||||
| - Auto-labels by size (XS to XL) | ||||||||||||||||||||||||
| - Adds target branch labels | ||||||||||||||||||||||||
| - Detects and warns about conflicts | ||||||||||||||||||||||||
| - Manages stale PRs (7-day warning, 14-day close) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #### Commit Enforcement | ||||||||||||||||||||||||
| - Pre-commit hooks check size limits | ||||||||||||||||||||||||
| - CI validates commit standards | ||||||||||||||||||||||||
| - Protected files require PR review | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Tools and Scripts | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### claude-branch.sh | ||||||||||||||||||||||||
| Creates properly formatted branches with optional draft PRs. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| # Examples | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh add-search # Creates feat/add-search | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh fix-bug --pr # Creates fix/fix-bug with PR | ||||||||||||||||||||||||
| ./scripts/claude-branch.sh docs-update # Creates docs/docs-update | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### apply-branch-protection.sh | ||||||||||||||||||||||||
| Applies the correct protection rules to main and dev branches. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| # Dry run to see what would change | ||||||||||||||||||||||||
| ./scripts/apply-branch-protection.sh --dry-run | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Apply protection | ||||||||||||||||||||||||
| ./scripts/apply-branch-protection.sh | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Best Practices | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### For Claude Code CLI Users | ||||||||||||||||||||||||
| 1. Work primarily with `dev` as your base branch | ||||||||||||||||||||||||
| 2. Use the `claude-branch.sh` script for consistency | ||||||||||||||||||||||||
| 3. Commit frequently within size limits | ||||||||||||||||||||||||
| 4. Let automation handle rebasing and synchronization | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### For Human Developers | ||||||||||||||||||||||||
| 1. Review PRs to `main` carefully | ||||||||||||||||||||||||
| 2. Use `dev` for experimental work | ||||||||||||||||||||||||
| 3. Leverage automation for routine tasks | ||||||||||||||||||||||||
| 4. Override automation when judgment is needed | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Conflict Resolution | ||||||||||||||||||||||||
| When the nightly rebase encounters conflicts: | ||||||||||||||||||||||||
| 1. A PR is automatically created with instructions | ||||||||||||||||||||||||
| 2. Check out the rebase branch locally | ||||||||||||||||||||||||
| 3. Resolve conflicts following the guide in the PR | ||||||||||||||||||||||||
| 4. Push the resolved branch | ||||||||||||||||||||||||
| 5. Merge the PR to update dev | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Migration Guide | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| For existing repositories adopting this workflow: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 1. **Create dev branch** (if doesn't exist): | ||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| git checkout -b dev main | ||||||||||||||||||||||||
| git push -u origin dev | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 2. **Apply branch protection**: | ||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| ./scripts/apply-branch-protection.sh | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 3. **Update CI/CD** to recognize both branches | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 4. **Configure team**: | ||||||||||||||||||||||||
| - Set `dev` as default branch for new PRs | ||||||||||||||||||||||||
| - Communicate new workflow to team | ||||||||||||||||||||||||
| - Update documentation references | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## Troubleshooting | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Common Issues | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| **Commits rejected by pre-commit hook** | ||||||||||||||||||||||||
| - Check file count and line count | ||||||||||||||||||||||||
| - Split large changes into multiple commits | ||||||||||||||||||||||||
| - Use `SKIP_CLAUDE_RULES=true git commit` for exceptions (use sparingly) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| - Use `SKIP_CLAUDE_RULES=true git commit` for exceptions (use sparingly) | |
| - Use `SKIP_CLAUDE_RULES=true git commit` for exceptions (use sparingly) | |
| - **When to use**: This override should only be used in specific scenarios, such as: | |
| - Emergency fixes that cannot wait for pre-commit hook adjustments. | |
| - Non-critical changes (e.g., documentation updates) that are blocked by overly strict rules. | |
| - **Risks**: Bypassing pre-commit hooks can: | |
| - Introduce errors or inconsistencies into the codebase. | |
| - Bypass quality checks, leading to potential vulnerabilities. | |
| - **Best Practices**: If you use this override: | |
| - Review your changes carefully before committing. | |
| - Notify your team and document the reason for bypassing the hooks. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description 'Developers after PR merge' is ambiguous. Consider clarifying whether this means developers can push directly to dev after their PR is merged, or if they need to go through the PR process for each push.