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:
2026-03-21 10:45:58 +01:00
parent 93a90f4ba7
commit 0d6174067e
3 changed files with 40 additions and 9 deletions

View File

@@ -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..."
}
]
}