一键导入
branch-discipline
Use before any code changes - hard gate ensuring work never happens on main branch, with proper feature branch creation from correct base
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use before any code changes - hard gate ensuring work never happens on main branch, with proper feature branch creation from correct base
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use after creating PR - monitor CI pipeline, resolve failures, address review feedback, and merge when all gates pass
Use when receiving UAT feedback, bug reports, user testing results, stakeholder feedback, QA findings, or any batch of issues to investigate. Investigates each item BEFORE creating issues, classifies by type and priority, creates well-formed GitHub issues with proper project board integration.
MANDATORY for all work - the project board is THE source of truth. This skill provides verification functions and gates that other skills MUST call. No work proceeds without project board compliance.
Use to spawn isolated worker processes for autonomous issue work. Uses Task tool with run_in_background for parallel execution and TaskOutput for monitoring. Pre-extracts context to minimize worker token usage.
Defines behavior protocol for spawned worker agents. Injected into worker prompts. Covers startup, progress reporting, exit conditions, and handover preparation.
Use when user requests autonomous operation across multiple issues. Orchestrates parallel workers using Task tool, monitors with TaskOutput, handles SLEEP/WAKE cycles, and works until scope is complete without user intervention.
| name | branch-discipline |
| description | Use before any code changes - hard gate ensuring work never happens on main branch, with proper feature branch creation from correct base |
| allowed-tools | ["Bash","mcp__git__*"] |
| model | opus |
Never work on main. Create feature branches for all work.
Core principle: The main branch is sacred. All work happens in feature branches.
This is a HARD GATE. Do not proceed with code changes if on main.
┌─────────────────────────────────────┐
│ CODE CHANGE NEEDED │
└─────────────────┬───────────────────┘
│
▼
┌─────────────────┐
│ Current branch? │
└────────┬────────┘
│
┌─────────┴─────────┐
│ │
main feature/*
│ │
▼ ▼
┌─────────┐ ┌─────────┐
│ STOP │ │ PROCEED │
│ Create │ │ with │
│ branch │ │ work │
└─────────┘ └─────────┘
# Show current branch
git branch --show-current
# If output is "main" or "master" → STOP
# If output is feature/* or fix/* → PROCEED
[type]/issue-[number]-[short-description]
| Type | Use For |
|---|---|
feature | New functionality |
fix | Bug fixes |
chore | Maintenance, dependencies |
docs | Documentation only |
refactor | Code restructuring |
test | Test additions/fixes |
feature/issue-123-user-authentication
fix/issue-456-login-redirect-loop
chore/issue-789-update-dependencies
docs/issue-101-api-documentation
refactor/issue-202-extract-validation
test/issue-303-add-integration-tests
# Ensure main is up to date
git checkout main
git pull origin main
# Create and checkout new branch
git checkout -b feature/issue-[NUMBER]-[description]
# Push branch to remote (establishes tracking)
git push -u origin feature/issue-[NUMBER]-[description]
When building on in-progress work:
# Checkout the base branch
git checkout feature/issue-100-base-feature
# Ensure it's up to date
git pull origin feature/issue-100-base-feature
# Create new branch from it
git checkout -b feature/issue-101-dependent-feature
Document the dependency in the issue.
Create → Work → Push → PR → Merge → Delete
# Switch to main
git checkout main
# Pull the merge
git pull origin main
# Delete local branch
git branch -d feature/issue-123-completed-feature
# Delete remote branch (usually done via PR UI)
git push origin --delete feature/issue-123-completed-feature
If main has moved ahead:
# Option 1: Rebase (preferred for clean history)
git checkout feature/issue-123-my-feature
git fetch origin
git rebase origin/main
# Option 2: Merge (if conflicts are complex)
git checkout feature/issue-123-my-feature
git fetch origin
git merge origin/main
Main should be protected. Never:
If you accidentally commit to main:
# If not yet pushed - move commits to new branch
git branch feature/issue-123-accidental-main
git reset --hard origin/main
# If already pushed - DO NOT force push
# Instead, revert and recreate in proper branch
Generally NO. Each issue gets its own branch.
Exception: Tightly coupled sub-issues from issue-decomposition MAY share a branch if:
Document this in the issues if doing so.
Before making any code change:
# Check current branch
BRANCH=$(git branch --show-current)
# Verify not on main
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
echo "ERROR: On protected branch. Create feature branch first."
exit 1
fi
# Verify branch follows naming convention
if ! echo "$BRANCH" | grep -qE '^(feature|fix|chore|docs|refactor|test)/issue-[0-9]+-'; then
echo "WARNING: Branch name doesn't follow convention"
fi
| Mistake | Prevention |
|---|---|
| Committing to main | Check branch before every commit |
| Pushing to main | Branch protection rules |
| Wrong base branch | Verify before creating branch |
| Outdated branch | Rebase/merge before PR |
| Branch name typos | Use consistent naming |
Before writing any code:
This skill is called by:
issue-driven-development - Step 6This skill enables: