Decompose instead of overloading one prompt
A prompt asked to do five things at once does all of them worse. Prompt chaining breaks a complex task into a sequence of focused calls, each doing one thing well, feeding the next: extract → classify → draft → check. Benefits: each step is simpler, testable, and debuggable; you can validate between steps and retry a single stage. This is the "workflow" pattern from the Agents course — reach for it before an autonomous agent.
Make prompts robust
Real inputs are messy — empty strings, huge inputs, adversarial text, off-topic requests, other languages. A robust prompt:
- Handles the empty/edge case ("if the input is empty or unrelated, return X").
- Bounds the output (max length, the enum, the schema) so a weird input can't produce a runaway response.
- Is tested across a range of inputs, not just the happy path — the same discipline as an eval set.
Self-checking patterns
- Generate-then-verify — one call produces an answer, a second checks it against criteria (the evaluator–optimizer pattern). Great for high-stakes output.
- Self-consistency — sample the answer several times and take the majority (for reasoning tasks); more reliable but more expensive.
- Constrain, then validate — schema-constrain the output and validate it in code, retrying on failure.
Robustness ≠ prompt-only
Some robustness belongs in code, not the prompt: input length caps, rate limits, timeouts, and output validation (Foundations course). The prompt makes the model behave; the surrounding code makes the system safe. A prompt alone can't guarantee the model never misbehaves — pair prompting with guardrails.