05 est. 40 min

Prompting for production

Module 05 · est. 40 min · You’ll walk away with: the prompt skeleton I use for every production agent, the ability to spot why a prompt that works in ChatGPT will quietly fail when it runs unattended, and the three API settings that do jobs prompts used to do badly.

TL;DR: A ChatGPT prompt optimizes for one good answer with you sitting there to course-correct. A production prompt optimizes for correct behavior across thousands of inputs with nobody watching. The skeleton that survives production: define the role and the unattended context, give an explicit “done,” handle the empty/ambiguous case, forbid invention and say why, specify the output exactly, and state rules plainly with their reasons. Current models follow instructions literally, so the ALL-CAPS, “you MUST” style that older models needed now makes agents rigid and over-cautious. Three things moved out of the prompt and into the API: effort (how hard it thinks), structured outputs (the exact shape of the answer) and mid-run system messages (new instructions without rewriting the prompt).

[Operator’s read] I have prompts that have run thousands of times without me reading the output. The only reason that’s safe is that the prompt anticipated the weird inputs I never saw. Every clause in the skeleton below is scar tissue from an agent that did something dumb because I didn’t tell it not to.


Why your ChatGPT prompts will fail

You’re good at ChatGPT. You ask, it answers, if it’s off you say “no, more like this,” and you converge. That conversational repair is doing way more work than you realize. In production, there is no repair turn. The agent runs at 6am, on input you’ve never seen, and whatever it produces is the final answer. It ships. No “actually, try again.”

That changes everything about how you prompt. Three specific failures show up the moment you remove the human:

Failure 1 — The agent assumes there’s always something to do. You prompt “summarize today’s events.” In ChatGPT, there’s always input because you pasted it. In production, sometimes the calendar is empty — and an under-specified agent will invent events because the prompt implied events exist. The empty case doesn’t occur to you when you’re testing with real data. It occurs constantly in production.

Failure 2 — The agent never stops, or stops too early. Agents loop (Module 02). A ChatGPT prompt doesn’t need a stop condition because you read the answer and close the tab. A production prompt without an explicit “done” will re-call tools, second-guess itself, or trail off mid-task. You have to define the finish line.

Failure 3 — The output format drifts. In ChatGPT you eyeball the answer and copy the part you want. In production, something downstream consumes the output — a Slack message, an email body, a database write. If the format drifts (“Sure! Here’s your digest: …” one day, a markdown table the next), the downstream breaks. You need the format pinned, exactly.

The production prompt skeleton

Here’s the structure I use for every agent. Not every section every time, but this is the checklist. I’ll build it up clause by clause and explain why each one earns its place.

code
## Role and context
You are {specific role} for {specific business}. You run {trigger: e.g.
"on a schedule, unattended, every morning at 6am"}. Nobody reviews your
output before it ships, so there's no one to ask: make the call yourself,
and if you can't do the job properly, say so in the output.

## Inputs
You will receive:
- {input 1}: {what it is, what it might look like, including the empty case}
- {input 2}: ...
Inputs may be empty, partial, or malformed. The rules below say what to do then.

## Job
1. {step}
2. {step}
3. {step — usually the action via a tool}

## Rules
- Only include what the inputs support. {Why: e.g. "The owner forwards
  this to staff, so an invented item turns into a wasted shift."}
- If inputs are empty or unusable, {exact fallback behavior}, and stop there.
- {domain rule, with its reason}
- {safety rule, e.g. "Don't quote prices: they change weekly and the
  booking page is the source of truth."}

## Output
{Exact format. Show a literal example. Say what the output is for, and
what it must leave out, e.g. "Plain text, because it's sent as an SMS."}

## Done means
You have {specific completion condition, usually "called {tool} once"}.
Then stop.

Now the reasoning behind each section.

Role and context — the “unattended” line is load-bearing. Telling the model nobody reviews this changes what it does. It stops asking clarifying questions (useless when nobody’s there to answer) and commits to a decision. Giving it a way out (“if you can’t do the job properly, say so”) matters just as much: an agent with no permitted way to fail will produce something. State the trigger too — “you run every morning” frames the whole task.

Inputs — describe the weird ones. Beginners describe the happy-path input. Pros describe the empty, partial, and malformed inputs, because those are what break things. “You’ll receive today’s calendar — which may be empty on weekends, may contain all-day events with no time, and occasionally contains a malformed entry from the import.” Every weird case you name is a failure you prevent.

Job — ordered steps, ending in the action. Number them. The last step is almost always “call the tool that does the real thing,” which connects the thinking to the consequence. Keep the steps at the level of what, and leave how to think about it to the model. Current models plan well on their own; a twelve-step script for reasoning written for a 2023 model now makes them rigid.

Rules — real constraints, each with its reason. This is where you encode everything that should never happen. Three rules belong in nearly every agent:

  • The anti-hallucination rule (“only include what the inputs support”). Your single most important sentence.
  • The empty-case rule (“if inputs are empty, do X and stop”). Prevents Failure 1.
  • A safety rule specific to the domain (never quote prices, never name competitors, never send to more than N people, never spend over $X).

Attach the reason to each one. “Don’t quote prices: they change weekly and the booking page is the source of truth” gets applied correctly to cases you never listed, like a customer asking what a lesson “usually” costs. A bare “NEVER QUOTE PRICES” gets applied to everything in sight, like refusing to mention that the court rental is on the booking page. A model that knows why a rule exists can tell what’s inside it.

Output — show, don’t describe, and say what it’s for. Don’t write “respond professionally.” Show a literal example of the exact output, and say who or what consumes it: “Plain text, because this goes straight into an SMS.” When code consumes the output, use structured outputs (below) and stop describing JSON in prose.

Done means — the stop condition. “You have called send_digest once. Then stop.” This single line prevents the agent from looping or re-sending. Without it, you’re trusting the model to know when to quit, and it won’t reliably.

Current models read you literally

Prompts written for 2023 and 2024 models were full of shouting: IMPORTANT, you MUST, NEVER EVER, three exclamation marks. That was a fix for models that skimmed past instructions. Current Claude models follow the system prompt closely and literally, so the same shouting over-applies. An agent told “you MUST call the search tool” will call it even when it already has the answer. One told “NEVER be negative” may refuse to admit the AC really was broken on Saturday. And when five rules are all marked critical, the markers stop meaning anything, and the whole prompt reads anxious, so you get an anxious, hedging agent.

It cuts the other way too. Soft words get read literally. “Try to include the booking link” is now permission to leave it out. If something is required, say it plainly as a requirement: “Include the booking link.”

The working style:

  • Plain statements, with the reason attached. “Use the search tool when the question is about this week’s schedule, because the schedule changes daily” beats “ALWAYS USE SEARCH.”
  • Capitals and “must” only where a test proved one instruction was being ignored, and only on that one instruction.
  • Say what you want instead of listing banned phrases. “Open with the reviewer’s specific point” works better than ten openers it must never use.
  • Keep prohibitions that encode a real business rule (refund caps, what you can’t promise, who you never email). Those stay, with their reasons.

If you’re carrying old prompts forward, this is the first pass to make. Search them for capital letters and “must” and ask of each line: what failure did this prevent, and does it say why?

Three jobs that moved out of the prompt

1. Effort: the dial for depth and cost. Current models think before they answer, and decide for themselves how much. You don’t set a thinking budget anymore (the API rejects one). You set output_config: { effort } to low, medium, high, xhigh or max. Lower effort means less thinking, fewer and more consolidated tool calls, shorter preambles and a smaller bill. Higher effort means more thorough work at more tokens. On claude-opus-5-5 the default is medium, which is what the starter sets explicitly.

How I’d use it: low for classification, routing and the cheap worker calls from Module 03. medium for a routine digest or reply. high or xhigh for multi-step research or anything long-horizon. max almost never. Don’t guess, though: run your Module 04 evals at two effort levels and keep the lower one if it still passes. Effort barely changes how long the answer is, so set length in the prompt (“3-6 bullets”).

2. Structured outputs: the exact shape, guaranteed. The old trick for getting clean JSON was to pre-fill the start of the model’s answer with { and then beg it in capitals for “ONLY valid JSON.” Pre-filling is gone; current models reject it with an error. When code consumes the output, give the API a schema and it guarantees the answer matches:

typescript
import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod';
import { z } from 'zod';

const Reply = z.object({
  reply: z.string(),
  needsHuman: z.boolean(),
  reason: z.string(),
});

const res = await client.messages.parse({
  model: 'claude-opus-5-5',
  max_tokens: 16000,
  output_config: { effort: 'medium', format: zodOutputFormat(Reply) },
  system: systemPrompt,
  messages: [{ role: 'user', content: reviewText }],
});
if (res.stop_reason !== 'end_turn' || !res.parsed_output)
  throw new Error(`Stopped: ${res.stop_reason}`);
const { reply, needsHuman } = res.parsed_output;

The same idea applies to tool calls: strict: true on a tool (Module 02) guarantees its input matches the schema. Between the two, the “output format drifts” failure goes away for anything a machine reads. You still write the output section of the prompt for tone and content; the schema handles shape.

There’s one more pattern to retire. Older code forced a specific tool call with tool_choice. Opus 5.5, Sonnet 5.5 and Fable 5.2 reject a forced tool choice with an error. Leave tool_choice on auto, put strict: true on the tool, and say in the prompt when to call it. That’s what the starter’s “Call send_digest once” line does.

3. System messages mid-run: new instructions without a new prompt. Sometimes an instruction arrives partway through: the facility closes early today, a customer is flagged, the operator wants terser replies. Editing the top-level system prompt mid-run throws away the prompt cache (Module 06) and muddles the history. Current models accept a system message appended to the conversation instead:

typescript
messages.push({
  role: 'system',
  content:
    'Holiday hours this week: the facility closes at 6pm. Mention it in any reply that touches on booking.',
});

Append it after a user turn (the tool results, say) and before the next call. It carries operator authority, so the model treats it as an instruction from you. That’s the difference from pasting the same text into a user message, where it would sit next to customer text the model is supposed to treat as data (Module 06). Keep your stable rules in the main prompt and use these for what changes during a run.

The “few-shot” upgrade: show, don’t tell

When behavior is fuzzy and rules aren’t enough, give examples. Two or three input→output pairs teach tone and judgment faster than a paragraph of description. This is how I get review replies in the right voice:

code
## Examples (match this tone)

Review: "Courts were great but the AC was struggling on Saturday."
Reply: "Really glad you enjoyed the courts! You're right about Saturday —
we've already got the AC issue scheduled for service this week. Thanks for
the heads up, and hope to see you back on court soon."

Review: "Booking system is confusing."
Reply: "Thanks for flagging this — booking should be the easy part. Mind
sending us a quick note about where you got stuck? We're actively improving
it and your specifics genuinely help."

Now reply to the review provided, matching this tone: warm, specific,
accountable, never defensive, never generic.

Two examples did more than three paragraphs of “be warm and professional” ever could. The model pattern-matches the register — sentence length, the accountability move, the specific callback. Current models copy examples closely, so vary them on purpose: if both examples open with “Thanks,” every reply will. Pull your examples from your actual best work.

The over-stuffing trap (the opposite failure)

There’s a failure mode on the other side: cramming so much into the prompt that the model loses the thread. A 2,000-word prompt with forty rules will have rules contradicting each other and the model applying the wrong one. Signs you’ve over-stuffed:

  • Rules that contradict each other (the model has to pick one).
  • Edge cases for inputs that can’t actually occur.
  • Re-explaining the same constraint three ways.
  • Instructions about how to reason, step by step, for a model that already plans well.

The fix: every clause must earn its place by preventing a real failure you’ve seen or can concretely predict. If you can’t name the failure a rule prevents, cut it. My best prompts are shorter than my early ones, because I learned which clauses actually matter. Tight beats comprehensive.

Prompt like you’re managing, not coding

The mental shift that makes you good at this: you’re delegating to a fast, literal, capable employee who takes everything you say at face value and nothing you don’t. It won’t read your mind. It won’t infer “obviously don’t email all 5,000 customers” unless you said so. But tell it clearly, with the reason, and it executes at 3am.

So write prompts the way you’d brief a sharp new hire on a task you’re about to leave them alone with: the goal, the steps, the hard limits and why they exist, what “done” looks like, and the two or three ways it could go wrong that they’d never guess. You wouldn’t shout at that new hire in capitals. Don’t shout at the model either. That brief is the prompt.

Hands-on lab

Rewrite your Module 02/04 agent’s prompt into the production skeleton.

Step 1 — Audit your current prompt against the skeleton. Which of the six sections do you have? Almost certainly you’re missing an explicit “done,” a real empty-case rule, or a pinned output. Mark the gaps.

Step 2 — Add the three universal rules, with reasons. The anti-hallucination rule, the empty-case rule, and one domain safety rule specific to your business. Write each as a plain statement followed by why it exists.

Step 3 — De-shout it. Search the prompt for capitals, “must,” “never ever,” and “try to.” For each, keep it only if it encodes a real constraint, rewrite it as a plain statement with a reason, and turn every “try to” on a requirement into a requirement.

Step 4 — Pin the output. If a person reads it, replace “respond professionally” with a literal example and a line on where it goes. If code reads it, switch to structured outputs and delete the prose describing the format.

Step 5 — Set effort deliberately. Run your Module 04 evals at low and at medium. If low still passes, keep it. Write the choice in a comment so the next person knows it was tested.

Step 6 — Run your evals and add one. Your hardened prompt should pass them. Then write one new eval: feed the agent deliberately ambiguous input (a half-sentence, a contradictory instruction) and assert it handles it gracefully — falls back, flags uncertainty, or says it can’t — instead of confidently making something up.

Step 7 — The unattended test. Read your final prompt and ask: “If I handed this to a literal-minded stranger and left the room, would they do the right thing on a weird input?” If you hesitate, there’s a missing clause. Add it.

Deliverable: your agent’s prompt, restructured into the six-section skeleton, with the three universal rules and their reasons, no leftover shouting, a pinned output (structured outputs if code consumes it), a tested effort level, and a new eval proving it handles ambiguity without hallucinating. Next module: the three things that kill agents before features ever do — cost, latency, and security — and where to put the human gate so none of them bankrupt or embarrass you.

↵ ↵ to see all results esc esc to close