Executive Summary
Why the best AI apps don’t just ‘prompt better’—they treat prompts like code: versioned, tested, and observable.
In production, prompts aren’t ‘messages’. They’re executable policy. A prompt selects what the model pays attention to, what it is allowed to do, and what it must refuse to do.
Prompt hygiene means you treat prompts like code: version them, test them, lint them, and measure their outputs. Your UX depends on it.
“Production is where good ideas meet boring reality. The winners instrument the boring part.”AI & Dev Dispatch
The Core Idea
Most “AI failures” are system failures: missing contracts, missing logs, missing ownership lines. Fix the system, and the model suddenly looks smarter.
Contract
Define the stable input/output boundary first.
Logs
Capture raw facts, not just summaries.
Policy
Centralize allow/deny decisions and expose reason codes.
UX
Make failure legible and recoverable.
// Stable contract surface (gateway request)
POST /.netlify/functions/gateway-chat
{
"org_id": "...",
"user_id": "...",
"model": "gpt-4.1-mini",
"messages": [...]
}
That snippet is not a complete app. It’s a reminder: your system should prefer verifiable facts over narrative.
Failure Modes You’ll Actually See
-
Prompt drift
Small edits silently change behavior. Without versioning, you won’t know why yesterday worked.
-
Hidden policy conflicts
System text says ‘do X’, product copy says ‘do Y’. The model picks one; users pay the price.
-
Unbounded context
Stuffing every note and log into context increases cost and decreases quality.
-
No evaluation harness
If you don’t test prompts, you only discover failures in production—live, in public.
Implementation Notes
Store prompt templates in a versioned table (or repo) and reference them by ID in every gateway call.
Build a tiny evaluation set: 20–50 test cases that represent your real user intents and failure modes.
Log prompt version, system policy version, and any retrieved evidence IDs alongside every response.
For architecture and rollout planning, use the Contact Hub.
Ship‑Ready Checklist
Use this as a pre‑deploy gate. If you can’t check these boxes, don’t pretend you’re “done.”
- A single source of truth for versions (prompt/policy/schema) and a way to display them in-app.
- Request correlation ID visible in UI, logged server-side, and searchable.
- Explicit failure UX: what happened, why, and a safe next step.
- An audit trail you can replay: inputs, decisions, outputs, and cost facts.
- A small test harness (even 20 cases) that runs before deployment.
Further Reading
External references (full links):
Related Reads in This Series
Want this turned into a working product?
Use the Contact Hub to scope features, security, billing, and the deployment plan.