feat: enforce feature branch workflow with PreToolUse hook
Add a guard script that blocks git commit/push on protected branches (develop, main, master) via a PreToolUse hook. Update CLAUDE.md with stricter branching rules: one commit per task, immediate commits on feature branches, no direct commits to protected branches. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,14 @@
|
||||
"PreCompact": [
|
||||
{ "hooks": [{ "type": "command", "command": "beans prime" }] }
|
||||
],
|
||||
"PreToolCall": [
|
||||
"PreToolUse": [
|
||||
{
|
||||
"matcher": "Bash",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "bash -c 'if echo \"$TOOL_INPUT\" | grep -q \"git commit\"; then BRANCH=$(git branch --show-current); if [ \"$BRANCH\" = \"develop\" ] || [ \"$BRANCH\" = \"main\" ]; then echo \"BLOCK: Cannot commit directly to $BRANCH. Create a feature branch first: git checkout -b feature/<name>\"; exit 2; fi; fi'"
|
||||
"command": ".claude/guard-branch.sh",
|
||||
"statusMessage": "Checking branch protection..."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user