AI and agents · Guide

12 prompting patterns that are actually worth it

They aren't secret commands and they don't switch on hidden modes. They're ways of structuring instructions to reduce ambiguity, steer the analysis and make the result easier to check.

The rule of this document: “backed” doesn't mean “guaranteed”. The principles backed by Anthropic show up in its documentation. Some names, like Evidence First, are @itsmarbuilds' own labels. The external frameworks are established methods that carry over to prompting, not special Claude features.
8 backed directly by Anthropic
4 established reasoning frameworks
12 prompts to copy
01

Few-shot

Anthropic

Show it examples of the result you want, instead of hoping it guesses the pattern.

⌄

Use it when

You want a new piece of code, text or classification to follow a pattern that already exists.

Why it makes sense

Anthropic describes examples as one of the most reliable ways to steer format, tone and structure, and recommends 3–5 relevant, varied examples.

Prompt ready to copy
I want to add a new endpoint to this project.
Before you write it, review these three existing endpoints: [A], [B] and [C].
Use their structure, naming, validation and error handling as the reference.
Then implement the new endpoint following that pattern.
Limit: Don't copy a bad example without noticing. The examples have to really represent the pattern you want.
Anthropic · Prompting best practices ↗
02

Evidence first

Anthropic

Get it to look for the evidence before it draws the conclusion.

⌄

Use it when

Bugs, audits, research, long documents or any question where a convincing but made-up answer is dangerous.

Why it makes sense

Anthropic recommends not speculating about code Claude hasn't opened. For long documents it also recommends pulling out the relevant passages first and answering afterwards.

Prompt ready to copy
Before you tell me what the cause is, investigate first.
Open the relevant files and base every conclusion on what you find.
If you don't have enough evidence to claim something, say so explicitly.
Limit: Having a quote doesn't automatically make the conclusion right. The evidence can also be incomplete or misread.
Anthropic · Prompting best practices / Reduce hallucinations ↗
03

Premortem

Established method

Imagine the plan has already gone wrong and look for why before you carry it out.

⌄

Use it when

Before a migration, deploy, refactor, launch or risky decision.

Why it makes sense

Gary Klein's premortem method starts precisely by imagining that a plan has failed, to surface threats and obstacles before carrying it out.

Prompt ready to copy
Imagine that tomorrow this change has broken production.
Give me five possible causes and, for each one, what I can check now to reduce that risk.
Limit: It generates possible scenarios, not predictions. Claude may suggest risks that don't apply.
Gary Klein · Premortem Method of Risk Assessment ↗
04

First principles

Reasoning framework

Stop assuming the current solution is the only possible one and go back to what really has to be true.

⌄

Use it when

You're optimizing an inherited solution and you suspect the problem is in the original approach.

Why it makes sense

Reasoning from first principles means breaking the problem down to fundamental facts or constraints and reasoning up from there. Elon Musk has publicly championed it over reasoning only by analogy.

Prompt ready to copy
Forget for a moment how it's solved now.
1. What goal do we really need to achieve?
2. Which constraints are truly mandatory?
3. What are we taking for granted just because it's always been done this way?
With that, rebuild the simplest solution from scratch.
Limit: It doesn't guarantee Claude will correctly identify which facts are fundamental. You have to check its premises.
TED 2013 · Elon Musk on first-principles reasoning ↗
05

Steelman

Reasoning framework

Make it build the best version of the argument against yours.

⌄

Use it when

Architecture, product or strategy decisions, or any moment when you're already very convinced of one option.

Why it makes sense

Steelmanning is the opposite of building a straw man: it tries to represent the opposing position in its strongest version before evaluating it.

Prompt ready to copy
I'm leaning towards [OPTION A].
Before recommending anything, build the best possible argument for [OPTION B].
Don't make up data. Point out what would have to be true for B to be the better decision.
Limit: Claude can strengthen a position until it distorts it, or add assumptions. Ask it to separate arguments from facts.
Argumentation literature · Steelmanning ↗
06

Scope fence

Anthropic

Tell it explicitly what you DON'T want it to touch, so a fix doesn't turn into a renovation.

⌄

Use it when

Small changes, hotfixes, tasks in big repos, or when Claude tends to over-engineer.

Why it makes sense

Anthropic's current documentation includes specific instructions to avoid over-engineering and keep changes focused on what was asked.

Prompt ready to copy
Make only the change needed to solve this task.
Don't add features, don't refactor unrelated code and don't create abstractions for hypothetical needs.
If you spot another improvement, point it out separately without implementing it.
Limit: Too much scope fence can block a fix that's needed around the change. Leave a way for Claude to tell you if something adjacent is essential.
Anthropic · Avoid over-engineering ↗
07

Output contract

Anthropic

Define what a useful answer looks like before you ask for it.

⌄

Use it when

Claude tends to give you an answer that's right but with the wrong format, depth or scope.

Why it makes sense

Anthropic recommends clear, explicit instructions, including output format, constraints and steps when the order matters.

Prompt ready to copy
I want the result to have exactly:
- a diagnosis in 3–5 sentences
- the files affected
- the minimal recommended change
- risks
- how to verify it
Don't implement anything yet.
Limit: A contract that's too rigid can flatten an open task. Use it when the format really matters.
Anthropic · Be clear and direct ↗
08

Give the why

Anthropic

Don't just give a rule. Explain why it exists so Claude can generalize it.

⌄

Use it when

Style, security, product or architecture rules that Claude will have to apply in cases nobody anticipated.

Why it makes sense

Anthropic says that giving context or motivation helps Claude understand the goal and generalize the instruction better.

Prompt ready to copy
Don't change this API's response schema.
Reason: two old clients depend on exactly that contract.
You can change the internal implementation, but the external shape has to stay compatible.
Limit: The context has to be true and relevant. A made-up explanation just adds another source of error.
Anthropic · Add context to improve performance ↗
09

XML structure

Anthropic

Separate instructions, context and data so Claude doesn't mix them up.

⌄

Use it when

Long prompts, several documents, examples mixed with instructions, or dynamic inputs.

Why it makes sense

Anthropic recommends XML tags for complex prompts because they reduce ambiguity between instructions, context, examples and inputs.

Prompt ready to copy
<instructions>
Analyze the bug and propose the minimal change.
</instructions>

<context>
The API must stay backwards compatible.
</context>

<logs>
[PASTE THE LOGS HERE]
</logs>
Limit: It doesn't add much to a two-line request. Use it when there really are separate blocks to keep apart.
Anthropic · Structure prompts with XML tags ↗
10

Role prompting

Anthropic

Give it a specific perspective when that perspective changes what it should prioritize.

⌄

Use it when

Specialized review: security, accessibility, performance, data, legal, UX, etc.

Why it makes sense

Anthropic says that assigning a role focuses Claude's behavior and tone for a use case.

Prompt ready to copy
Review this change as a senior backend engineer focused on reliability.
Prioritize regressions, race conditions, error handling and observability.
Don't assess visual style or product unless they affect the backend.
Limit: Saying “you're the best expert in the world” doesn't add knowledge. A useful role defines perspective and priorities, not grandeur.
Anthropic · Give Claude a role ↗
11

Tests first

Anthropic

Define how we'll know it works before letting Claude change the code.

⌄

Use it when

Features, reproducible bugs, refactors and long agentic tasks.

Why it makes sense

Anthropic recommends that agents write tests before starting and keep them as a structured measure of progress.

Prompt ready to copy
Before implementing, define the tests that would prove this task is solved.
Include the happy path, edge cases and relevant regressions.
Then implement the change and run those tests.
Don't change the tests just to make them pass.
Limit: Tests can be badly designed. “Passing the tests” isn't the same as solving the problem correctly.
Anthropic · Agentic coding guidance ↗
12

Red team

Established method

Ask it to try to break your idea instead of helping you defend it.

⌄

Use it when

Plans, pitches, decisions, lightweight threat modeling and adversarial review beforehand.

Why it makes sense

Red teaming is an established practice of structured challenge to plans and assumptions. Here it's adapted as a prompting framework, not as a substitute for an audit or a real red team.

Prompt ready to copy
Act as a red team for this plan.
Look for weak assumptions, edge cases, ways it could fail and what evidence is missing.
For each criticism, propose a concrete check.
Don't make up vulnerabilities or facts you can't back up.
Limit: Criticism generated by an LLM isn't the same as an adversarial test that was actually run, or an independent security audit.
UK Ministry of Defense · Red Teaming Handbook ↗

Interactive version by @itsmarbuilds