Prose in CLAUDE.md and .cursorrules is context, not enforcement. Use cross-platform Node.js hooks to fail closed on secrets and cap verification retries.
Monolithic 300-line CLAUDE.md files and multiple MCP servers can burn 10,000+ idle tokens on every turn before you type a prompt. Audit your workspace first.
git clone https://github.com/tolga571/agent-context-audit.git
node ./agent-context-audit/bin/audit.mjs .
Use Node.js instead of jq/bash so the exact same hook runs on Windows, macOS, and Linux. Return exit code 2 to block .env reads or destructive git commands deterministically.
if (/\.env(\.[A-Za-z0-9_-]+)?$/i.test(filePath)) {
console.error(`Blocked sensitive file read: ${filePath}`);
process.exit(2);
}
Track stop_hook_active and a local retry counter capped at MAX_RETRIES=2 so failed unit tests feed stderr back twice instead of draining your monthly quota.
if (payload.stop_hook_active && retries >= MAX_RETRIES) {
process.exit(0); // break loop safely
}