Prompt instructions have a non-zero failure rate. For business rules where compliance is mandatory — refund authorization, customer verification, regulatory checks — programmatic enforcement is the only acceptable design. This lesson covers how to use prerequisites, hooks, and structured handoffs to guarantee critical workflow steps.
Programmatic Enforcement vs Prompt Guidance
A system prompt that says "Always call get_customer before process_refund" will work most of the time. In production, "most of the time" means 12% of refunds skip customer verification. For a financial workflow, that's catastrophic.
The fix is a programmatic prerequisite: process_refund rejects the call (returns an error) unless a verified customer ID is in scope. The model can't bypass this — the rejection is enforced by your code, not by Claude's judgment.
The Prerequisite Pattern
async function process_refund({ customer_id, amount }) {
if (!await isCustomerVerified(customer_id)) {
return {
isError: true,
errorCategory: "validation",
isRetryable: false,
message: "Customer must be verified via get_customer before refund processing"
};
}
// ... actual refund logic
}
When the model sees this error, it does the right thing automatically: calls get_customer, then retries process_refund. You haven't told it to do that in the system prompt — the tool's error message did the work.
Decomposing Multi-Concern Requests
A user request like "What's the status of my order, and can I change my shipping address?" has two independent concerns. The right pattern is to investigate them in parallel (two subagent or tool calls in one turn) and synthesize a unified response. Sequential investigation wastes time and can lose state.
Structured Handoff to Humans
When escalating to a human agent, provide a structured handoff summary: customer details, root cause analysis, recommended actions, conversation context. The human agent doesn't have access to the model's reasoning — they need an explicit briefing.
## Escalation Summary
Customer: [name, account number]
Root cause: [one-sentence diagnosis]
What I tried: [actions taken so far, each with outcome]
Recommended action: [what the human should do]
Sensitive: [PII, conversation excerpts the human should review]
Skills to Develop
- Identify business rules where prompt-only compliance is unacceptable (financial, security, regulatory) and convert them to programmatic prerequisites.
- Design tool error responses that guide the model toward the correct next step ("call X first") rather than generic failure messages.
- Compile structured handoff briefings when humans pick up an in-flight conversation.