diff --git a/hooks/hooks.json b/hooks/hooks.json index d8c8c2d73..6ce068169 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -37,10 +37,10 @@ "hooks": [ { "type": "command", - "command": "node -e \"const fs=require('fs');let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const i=JSON.parse(d);const p=i.tool_input?.file_path||'';if(/\\.(md|txt)$/.test(p)&&!/(README|CLAUDE|AGENTS|CONTRIBUTING)\\.md$/.test(p)&&!/\\.claude\\/plans\\//.test(p)){console.error('[Hook] BLOCKED: Unnecessary documentation file creation');console.error('[Hook] File: '+p);console.error('[Hook] Use README.md for documentation instead');process.exit(2)}}catch{}console.log(d)})\"" + "command": "node -e \"let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const i=JSON.parse(d);const p=i.tool_input?.file_path||'';const n=p.replace(/\\\\\\\\/g,'/');const b=n.split('/').pop()||'';if(/\\.(md|txt)$/i.test(n)&&/^(NOTES|TODO|SCRATCH|TEMP|DRAFT|BRAINSTORM|SPIKE|DEBUG|WIP)\\.(md|txt)$/.test(b)&&!/(^|\\/)(docs|\\.claude|\\.github|commands|skills|benchmarks|templates)(\\/|$)/i.test(n)){console.error('[Hook] BLOCKED: Ad-hoc documentation filename');console.error('[Hook] File: '+p);console.error('[Hook] Use structured paths: docs/specs/, docs/adr/, commands/, skills/');process.exit(2)}}catch{}console.log(d)})\"" } ], - "description": "Block creation of random .md files - keeps docs consolidated" + "description": "Block ad-hoc doc filenames (NOTES, TODO, SCRATCH, etc.) unless in structured paths" }, { "matcher": "Edit|Write",