Skip to content

Commit 2133ff0

Browse files
authored
Add branch protection and issues setup to template workflow (#10)
* feat: add self-disable step to template setup workflow - Add final step to change alwaysApply from true to false after template initialization - Prevents detailed template setup instructions from consuming context window space - Ensures template setup rules are visible during one-time setup but hidden afterwards - Maintains accessibility via reference in workflow.mdc if needed later * feat(template): Add branch protection and issues setup to template workflow - Add GitHub CLI commands to enable issues in new repos - Include complete branch protection rules that match template repo - Provide both CLI and manual setup instructions - Document all protection settings for consistency across projects
1 parent ec4e1ac commit 2133ff0

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

.cursor/rules/template_setup.mdc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,52 @@ When a user prompts "initialize this project as <my project name>", I will **ONL
2828
- **Project `.env`**: Will contain application-specific configuration (database URLs, app API keys, etc.)
2929
- **Never mix these**: TaskMaster configuration is separate from project application configuration
3030

31+
## Branch Protection Setup (Optional)
32+
If the new project is a GitHub repository, consider setting up branch protection rules to match the template:
33+
34+
### Enable Issues
35+
First, ensure issues are enabled in the repository:
36+
37+
```bash
38+
# Enable issues in the repository
39+
gh api repos/OWNER/REPO --method PATCH --field has_issues=true
40+
```
41+
42+
### Required Branch Protection Rules
43+
Apply these settings to the `main` branch:
44+
45+
```bash
46+
# Enable branch protection with pull request reviews
47+
gh api repos/OWNER/REPO/branches/main/protection \
48+
--method PUT \
49+
--field required_status_checks='{"strict":true,"contexts":[],"checks":[]}' \
50+
--field required_pull_request_reviews='{"dismiss_stale_reviews":false,"require_code_owner_reviews":false,"require_last_push_approval":false,"required_approving_review_count":1}' \
51+
--field required_signatures='{"enabled":false}' \
52+
--field enforce_admins='{"enabled":false}' \
53+
--field required_linear_history='{"enabled":false}' \
54+
--field allow_force_pushes='{"enabled":true}' \
55+
--field allow_deletions='{"enabled":false}' \
56+
--field block_creations='{"enabled":false}' \
57+
--field required_conversation_resolution='{"enabled":false}' \
58+
--field lock_branch='{"enabled":false}' \
59+
--field allow_fork_syncing='{"enabled":false}'
60+
```
61+
62+
### Branch Protection Summary
63+
- **Pull Request Reviews**: 1 approval required
64+
- **Status Checks**: Strict mode enabled
65+
- **Force Pushes**: Allowed
66+
- **Branch Deletions**: Disabled
67+
- **Admin Enforcement**: Disabled (admins can bypass)
68+
69+
### Alternative: Manual Setup
70+
1. Go to repository Settings → Branches
71+
2. Add rule for `main` branch
72+
3. Enable "Require a pull request before merging"
73+
4. Set "Required number of approvals before merging" to 1
74+
5. Enable "Require status checks to pass before merging"
75+
6. Check "Require branches to be up to date before merging"
76+
3177
## After Template Initialization
3278
Template initialization is complete after customizing the project files. TaskMaster, PRD creation, and git setup are separate workflows that require explicit user requests.
3379

0 commit comments

Comments
 (0)