Lv.1 0 XP

Programmatic Enforcement vs Prompt Guidance — The Most Tested Concept

⚡ MOST TESTED 12 min +50 XP
💡
THE ANALOGY

A bank's fraud detection system vs a training manual that says 'always verify large transactions.' The training manual works most of the time. The fraud detection system works every time. When the consequence of failure is financial, legal, or safety-critical, you use the system — not the manual.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Thinking that a very detailed, well-written prompt instruction provides the same guarantee as programmatic enforcement. It doesn't. LLMs are probabilistic. No matter how clearly you write 'always verify identity before processing refunds,' there is a non-zero probability of non-compliance in production at scale.

KEY POINTS
1 LLMs are probabilistic — any instruction in a prompt has a non-zero failure rate, making prompts unsuitable as the sole mechanism for critical compliance requirements.
2 Programmatic enforcement uses code to intercept, block, or modify tool calls — it is deterministic and 100% reliable.
3 The decision rule: if a failure has financial, legal, or safety consequences → programmatic enforcement. If a failure is a preference violation → prompt guidance is fine.
4 PreToolUse hooks intercept BEFORE tool execution — can block the call entirely or modify its inputs.
5 PostToolUse hooks intercept AFTER tool execution — can transform results before Claude sees them.
6 Hooks and prompt guidance are complementary — use prompts to guide behavior within the space that hooks allow.