tractatus/.claude/hooks/trigger-word-checker.js
TheFlow 3009e4942f fix(governance): add architectural enforcement for "ff" and "ffs" trigger words
Problem: Claude failed to recognize "ffs" code word despite inst_082 being active.
Root cause: No architectural enforcement to check for trigger words on every user message.

Solution:
- Created .claude/hooks/trigger-word-checker.js that runs on UserPromptSubmit
- Detects "ffs" → instructs to run framework-stats.js (inst_082)
- Detects "ff " prefix → instructs to run framework-audit-response.js (inst_078)
- Registered hook in .claude/settings.json

Testing:
 "ffs" detection works correctly
 "ff " prefix detection works correctly
 Normal messages pass through silently

Philosophy: Governance enforced architecturally, not by voluntary compliance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 12:32:52 +13:00

34 lines
1.2 KiB
JavaScript
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Trigger Word Checker Hook
*
* Detects "ff" and "ffs" code words in user prompts and provides
* immediate instruction to Claude on how to handle them.
*
* This runs on EVERY user message to ensure triggers are never missed.
*/
const input = JSON.parse(process.argv[2] || '{}');
const userMessage = input.text || '';
// Normalize: trim whitespace, lowercase for matching
const normalized = userMessage.trim().toLowerCase();
// Check for "ffs" trigger (exact match or standalone word)
if (normalized === 'ffs' || /\bffs\b/.test(normalized)) {
console.log('\x1b[33m⚠ CODE WORD DETECTED: "ffs"\x1b[0m');
console.log('\x1b[36mClaude MUST run: node scripts/framework-stats.js\x1b[0m');
console.log('\x1b[36mSee inst_082 and CLAUDE.md lines 66-88\x1b[0m');
process.exit(0);
}
// Check for "ff" prefix trigger
if (normalized.startsWith('ff ')) {
console.log('\x1b[33m⚠ CODE WORD DETECTED: "ff"\x1b[0m');
console.log('\x1b[36mClaude MUST run: node scripts/framework-audit-response.js --prompt "..." --type "boundary_question"\x1b[0m');
console.log('\x1b[36mSee inst_078 and CLAUDE.md lines 48-64\x1b[0m');
process.exit(0);
}
// No trigger words found - continue normally
process.exit(0);