Prompting that holds up

Instructions that survive a model change, an adversarial user and a second reader.

What you will be able to do

Write a system prompt, constrain the output, and know which rules a prompt cannot enforce.

Prerequisites
A feature that already calls a model.
Length
7 lessons · 24 min

Syllabus

  1. 1Prompt EngineeringA prompt is a specification written for something with no context on your product. What has to exist before you start, the three failures that look like prompt problems and are not, and the techniques in rough order of payoff.3 min
  2. 2System PromptingThe Messages API takes the system prompt as its own parameter rather than a first message. Putting the date or a user's name in it stops the prefix caching, so you pay the write premium and never collect the read discount.3 min
  3. 3Providing ContextLong documents go above the question, not below it, and the boundary between your instruction and their text is a security control.5 min
  4. 4Structured OutputAsking for JSON in the prompt, JSON mode, and schema-constrained output give different guarantees. JSON mode promises syntactically valid JSON and not conformance to your schema, which is the gap most applications trip on.4 min
  5. 5Few-Shot PromptingAnthropic suggests three to five examples, wrapped in tags and varied enough that the model does not learn a pattern you did not intend. Examples are input tokens, so they belong in the cached prefix.3 min
  6. 6Chain of ThoughtOn models that reason by default, asking for step-by-step thinking pays for the steps twice. Carried-over verification instructions cause over-verification, and tag conventions are a weak way to separate reasoning from the answer.3 min
  7. 7ConstraintsTelling a model what to write beats telling it what to avoid, and a constraint tuned on one model can suppress something the next one needed. Where the line falls between asking and enforcing.3 min