Add simplify-ignore hook for block-level code protection

Single bash script that prevents the model from seeing (and accidentally
simplifying) code blocks marked with simplify-ignore annotations during
/code-simplify sessions.

Hook flow:
- PreToolUse Read: backs up file, replaces blocks with BLOCK_<hash> placeholders
- PostToolUse Edit|Write: expands placeholders, applies model changes, re-filters
- Stop: restores files from backup when session ends

Features:
- Hash-based tokens (content-addressed, unambiguous round-trip)
- Multi-block support per file
- Optional reason string: /* simplify-ignore-start: perf-critical */
- Language-aware placeholders (preserves comment syntax per language)
- Glob-safe parameter expansion (Bash 3.2 compatible)
- Atomic locking with stale lock recovery
- Trailing newline preservation
- Self-healing recovery from interrupted sessions
- Cross-platform: Bash 3.2+, jq, shasum/sha1sum (macOS, Linux, Git Bash)

Implements #2
This commit is contained in:
Federico Bartoli
2026-03-18 05:20:14 +01:00
parent 103124b029
commit 1730a69454
3 changed files with 367 additions and 0 deletions
+1
View File
@@ -3,3 +3,4 @@ node_modules/
.env
.env.*
*.log
.claude/.simplify-ignore-cache/