Prompting

How to Write Better AI Prompts (A Framework)

3 min read

Vague prompts get vague answers, and the fix is boringly mechanical: say who the model is, what it must do, what it has to work with, and what shape to return. Anthropic’s golden rule is the test — show your prompt to a colleague with no context; if they’d be confused, so is the model.

The framework

You are a [role].
Task: [what you want done].
Context: [key facts, constraints, audience].
Format: [bullet list / table / 200 words / JSON].

Four lines that carry most of the value. Fill every slot; an empty Format line is where cleanup work comes from.

The ordering rule most guides get wrong

That template puts context in the middle, which is fine for a paragraph and wrong for a document. For inputs over roughly 20,000 tokens, put the long material at the top, above your instructions and question. Anthropic measures response quality improving by up to 30% on complex multi-document inputs when the query sits at the end:

<document>
…the whole report…
</document>

You are a financial analyst. Using only the document above, list the three
largest cost drivers. Format: a markdown table with driver, amount, page.

Long input first, instruction last — the ordering that tests best on multi-document prompts.

Examples beat adjectives

One example teaches more than a paragraph of rules; three to five is the recommended range for few-shot prompting. Wrap them so they can’t be mistaken for instructions:

<examples>
<example>
Input: the fn returns nil sometimes idk why
Output: ## Bug: function returns nil intermittently
</example>
</examples>

Tagged examples the model reads as demonstrations, not as part of the task. Use consistent tag names across your prompts.

Say why, not just what

“Never use ellipses” performs worse than “this will be read aloud by a text-to-speech engine, which can’t pronounce ellipses.” Given the reason, the model generalises to cases you forgot to list — the single cheapest upgrade to any prompt.


Next: bake the good version in as a system prompt, split anything multi-phase with prompt chaining, and read the full prompting best practices.

Open the full interactive version (with copy buttons) ↗

← All guides