Phase 8c-1: Claude-custom mid-session write protection
Goal: Prevent direct edits to
~/claude-custom files while on main. Extends the SessionStart dirty check (7d-1, PR #61) to block mid-session writes.Owner: Betty Sue (config files are her domain)
Problem
The
check-claude-custom-clean.sh SessionStart hook catches dirty state when a session begins, but nothing prevents Betty Sue from editing ~/.claude/hooks/* files directly on main mid-session. This happened during the bug-merge-hook-silent-error fix -- edit landed on main, had to be stashed and branched retroactively.Solution
Add a PreToolUse hook on
Write|Edit that checks:- Is the target file inside
~/claude-custom(resolved through symlinks)? - Is
~/claude-customcurrently onmain? - If both yes → block with "Create a branch in ~/claude-custom first"
Deliverables
- New hook script:
block-claude-custom-main-edit.sh - Hook registered in
settings.jsonunderPreToolUsematcherWrite|Edit
Related
bug-merge-hook-silent-error— the incident that exposed this gap- 7d-1 (PR #61) — SessionStart dirty check (the first half of this protection)