Skip to content
AI Engineer Guide.

concept · concepts · intermediate · concept 3 of 26

Prompt anatomy

0 of 26 complete

Why it matters

Prompts grow by accretion: a rule for one incident, a clarification for one customer, a format note from a downstream team. Without a structure, no one can tell which sentence caused a regression or which part is safe to delete. Naming the sections makes the prompt reviewable: each section has a purpose, an owner and a test, so changes can be attributed and obsolete rules removed.

Mental model

Prompt anatomy is the layout of a form: header, instructions, fields, signature. The comparison breaks because a form is enforced by its boxes, while a prompt's sections are only conventions the model may ignore. A missing box is obvious on paper and invisible in a prompt.

How it works

A prompt as six line itemsInteractive

Prompt budget · illustrative tokens

700 input+ 200 reserve= 900 of 900

window full

Step 1/4 · Six sections, one prompt

Step 1Six sections, one prompt

Role and policy, task, input data, constraints, examples and output format take the whole 700-token input. The 200-token answer reserve is intact, but there is no slack left for a rule added after an incident.

reserve 200700 tokens

Output reserve

200
output reserveBar length is each block's token share of the window.

Pick a section to read its token count, its role and its state.

Figure. A prompt is six sections sharing one token budget. Each section is a line item with its own failure mode, so the figure draws the composition: delete one and the tokens it frees are visible even when its absence is not.

What to notice. Token counts are authored to make the arithmetic visible; no prompt was rendered and no model was run. The removal steps describe an ablation you would run against an eval set — the figure reports no score. Six sections of one prompt are shown; delimiters, per-section versioning and the model's chat markers are omitted.

Text version

A 900-token window with a 200-token answer reserve, so 700 tokens are available for the prompt. The default first step fills them: role and policy 90, task statement 60, input data 240, constraints 80, worked examples 140 and output format 90. The window reads 700 input + 200 reserve = 900 of 900, window full. The second step highlights the constraints and the output format to show those sections named and given stable positions. The third step removes the constraints and leaves 80 tokens free; its note says the answer stopped enforcing the refund window. The fourth step restores the constraints and removes the 140-token worked examples instead, leaving 140 free, and says that is an ablation to run, not a result reported here. Selecting a section shows its token count, role and why it is in the prompt.

  1. Split the prompt into role and policy, task, input data, constraints, examples and output format.
  2. Give each section a delimiter and a heading the model can refer to, and keep the order stable across versions.
  3. Write the task as one imperative sentence and move conditional rules into the constraints section.
  4. Put variable content in the input section only, and keep it clearly separated from instructions.
  5. Test each section by removing or changing it alone and measuring the effect on the evaluation set.
  6. Delete sections that no longer change the score, since unused rules still consume attention and tokens.

Trade-offs

ChoiceGood forCostFails when
Minimal promptCheap, easy to readEdge cases handled by guessworkThe task has strict format or policy needs
Fully sectioned promptReviewable and testableMore tokens and maintenanceThe task is simple and stable
Rules in proseFlexible, handles nuanceRules conflict and get droppedThe rule is mechanically checkable
Rules as schema or codeEnforced, testableLess nuance, more engineeringThe requirement is judgemental
Trade-off mapInteractive

Good for

Cheap, easy to read

Cost

Edge cases handled by guesswork

Fails when

The task has strict format or policy needs

  1. The task has strict format or policy needs
  2. The task is simple and stable
  3. The rule is mechanically checkable
  4. The requirement is judgemental

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Minimal prompt is good for Cheap, easy to read, costs Edge cases handled by guesswork, and fails when The task has strict format or policy needs. Fully sectioned prompt is good for Reviewable and testable, costs More tokens and maintenance, and fails when The task is simple and stable. Rules in prose is good for Flexible, handles nuance, costs Rules conflict and get dropped, and fails when The rule is mechanically checkable. Rules as schema or code is good for Enforced, testable, costs Less nuance, more engineering, and fails when The requirement is judgemental

Failure modes

  • Instruction buried. A critical constraint sits after a long document and is ignored. Debug: move the constraint before the data and compare scores on the same set.
  • Section collision. User input contains text that looks like a section heading and changes the structure. Debug: render input containing your delimiters and inspect the result.
  • Orphan rule. A constraint refers to a format the output section no longer uses. Debug: map each rule to a test case and delete the ones with no case.

In production

Version the prompt by section so a diff shows which part changed. Keep a test case per constraint, and review the prompt when a downstream consumer changes.

Common misconceptions

People think: Longer prompts are more thorough.

Actually: Unused rules add tokens and can dilute attention; every section should earn its place on the evaluation.

People think: Prompt writing is copywriting.

Actually: Most of the work is specifying behaviour precisely enough to test it.

Interview angle

Name the sections and give each one a failure mode, then explain how you would test a change to one section in isolation. Strong answers connect sections to ownership and versioning. Weak answers recite a template without saying what breaks when a section is missing.

Sources