# How to Write Better AI Prompts (A Framework)

> A prompt framework that still holds: role, task, context, format — plus the long-input ordering rule Anthropic measures at up to 30% better answers.

- Canonical: https://guides-ai.pages.dev/guides/write-better-ai-prompts/
- Plate 10.01 · Topic: Prompting (https://guides-ai.pages.dev/topics/prompting/)
- Published: 10 Jun 2026 · Updated: 06 Sept 2026 · 3 min read
- Source site: guides-ai — https://guides-ai.pages.dev/

**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

```text
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:

```text
<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](/glossary/#few-shot) prompting. Wrap them so they can't be mistaken for instructions:

```text
<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](/guides/write-a-system-prompt/), split anything multi-phase with [prompt chaining](/guides/prompt-chaining/), and read the full [prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices).
