TL;DR
Claude follows instructions literally, parses XML-style tags as hard boundaries, and weights the last instruction most. So the reliable recipe is: long inputs at the top, your task and constraints at the bottom, structure wrapped in tags, 3-5 in-context examples, and a concrete output-format spec. Anthropic’s own documentation says putting the query at the end of a long, multi-document prompt can improve answer quality by up to 30% in their tests. Everything below is built around that.
These patterns apply across the current line as of June 2026: Claude Opus 4.7 (the top model), Claude Sonnet 4.6 (the workhorse), and the same models inside the Claude app, Claude Code, and Claude Cowork.
What changed with Opus 4.7
If you tuned prompts for an older Claude and they now feel “off,” this is usually why: Claude Opus 4.7 (released April 2026) follows instructions more literally than its predecessors. Where 4.6 would infer what you probably meant and fill reasonable gaps, 4.7 tends to do exactly what you asked, no more and no less.
Two practical consequences:
- State scope explicitly. “Apply this formatting to every section, not just the first one” now matters, because 4.7 will not silently generalize a rule from one item to the rest.
- Dial back shouting. If your old prompts used “CRITICAL: you MUST…” to force a tool or a behavior, the newer models can now over-trigger on that. Plain “Use this when…” works better.
Who this is for
Anyone running Claude daily through claude.ai or the API: writers, engineers, researchers, support leads, who keep getting “almost right” output and are tired of fiddling. If your average prompt is one or two sentences, you will see the biggest jump here.
Skip the structure for casual brainstorming, where surprise is a feature, not a bug. Use it whenever output consistency matters: client deliverables, repeatable workflows, code edits, content templates, anything you will quote or ship.
The structure that works
Wrap structured context in XML-style tags. Claude was trained heavily on this style and treats tags as clean boundaries between instructions, context, and the variable parts of your prompt. Use descriptive names (<context>, <task>, <draft>, <constraints>); Claude understands any tag name as long as it describes what is inside.
<context>
You are reviewing a marketing email for a fintech audience.
Tone: confident, plain English, no jargon.
</context>
<task>
Rewrite the draft below to 180 words. Keep the CTA in the last line.
</task>
<draft>
[paste draft here]
</draft>
<constraints>
- No exclamation marks
- No words longer than 4 syllables
- Subject line must be under 50 characters
</constraints>
Note the order. Background and source material go first; the actual ask and the hard constraints go last. For long inputs this is not cosmetic. Anthropic’s long-context guidance is explicit: place long documents and data near the top, above your query and examples, and that alone can move quality by up to 30% on complex, multi-document prompts.
Specify the output format
“Reply with a single 180-word paragraph” beats “be concise.” Claude’s newer models calibrate length to perceived task complexity instead of a fixed verbosity, so if you do not name the shape you want, you will get a different shape every run.
A few format levers that actually move the model:
- Show the exact shape. “Return a JSON array where each item has
title,summary, andpriorityfields.” - Say what to do, not what to avoid. “Write in smoothly flowing prose paragraphs” outperforms “do not use bullet points.” Anthropic recommends positive instructions over negative ones for exactly this reason.
- Match your prompt style to the output. If you want prose, strip the markdown out of your own prompt; heavy markdown in the prompt tends to pull markdown into the answer.
- On the API, prefer Structured Outputs over prefill. Prefilling the assistant turn to force JSON used to be a common trick. As of the Claude 4.6 generation it is gone: a prefilled final assistant message returns a
400error. Use the Structured Outputs feature, ask for a schema directly, or output inside XML tags instead.
Examples are the highest-leverage edit
A few well-chosen examples (few-shot or multishot prompting) move accuracy and consistency more than any amount of abstract description. Anthropic’s guidance: include 3-5 examples, wrap each in <example> tags (and the set in <examples>), and make them both relevant (mirroring your real case) and diverse (covering edge cases so Claude does not latch onto an accidental pattern).
<examples>
<example>
Input: "synergize cross-functional deliverables"
Output: "get teams working on the same thing"
</example>
<example>
Input: "let's circle back on the action items"
Output: "we'll follow up on the tasks"
</example>
</examples>
Rewrite this sentence in plain English: "We need to leverage our core competencies."
If you only change one thing about a weak prompt, change the examples. One concrete bad example helps only when the failure mode is subtle; otherwise it adds noise.
End with a self-check
Append a concrete verification step and Claude will run it: “Before you finish, verify the word count and confirm no exclamation marks remain.” This catches errors reliably, especially in code and math. Keep it specific; “double-check your work” does nothing, but “confirm every JSON key from the schema is present” does.
One nuance worth knowing: when extended thinking is off, Claude is sensitive to the literal word “think.” If a self-check is firing more reasoning than you want, swap in “consider,” “verify,” or “confirm.”
Set durable defaults once
Stable preferences belong in your settings, not retyped every chat:
- claude.ai: put writing voice, code style, and rules like “never invent statistics” in custom instructions so every conversation starts from your defaults instead of Anthropic’s.
- Recurring work with shared files: use a Claude Project so the project knowledge and instructions ride along automatically.
- Coding in the terminal: put repo conventions in a
CLAUDE.mdfile so Claude Code loads them on every session.
Editing these per-chat does not persist. If you find yourself overriding a custom instruction repeatedly, that override is the signal to update the instruction itself.
Quick reference: lever, when to use, what to write
| Lever | Use it when | Concrete move |
|---|---|---|
| XML tags | Prompt mixes instructions, context, and inputs | Wrap each part: <context>, <task>, <constraints> |
| Input-at-top, ask-at-bottom | Document is 20k+ tokens | Source first, question last (up to ~30% quality gain) |
| 3-5 examples | Output format or tone must be consistent | Wrap in <example> tags; relevant + diverse |
| Explicit format spec | You will parse or ship the output | ”Return JSON with fields x, y” / “one 180-word paragraph” |
| Positive instructions | Steering style | ”Write in prose” instead of “no bullet points” |
| State scope explicitly | Rule must apply broadly (Opus 4.7) | “Apply to every section, not just the first” |
| Self-check line | Hard constraints (counts, schema, math) | “Before finishing, verify [specific criterion]“ |
| Structured Outputs (API) | You need guaranteed JSON shape | Use the schema feature; prefill now returns 400 |
Common mistakes
- One-paragraph prompts with no structure. Claude follows instructions in order; unstructured input produces unstructured output.
- Skipping the format spec. “Be concise” is interpreted differently every run, more so now that length is task-calibrated.
- Zero examples. The single highest-leverage edit, left on the table.
- Stacking 10+ constraints. Past five or six, Claude starts dropping the middle ones. Keep them tight and ranked.
- Assuming a rule generalizes. On Opus 4.7 it will not. Name the scope.
- Still relying on prefill for JSON. It errors on 4.6-generation models. Move to Structured Outputs.
- Editing custom instructions inside a single chat. It does not persist; put it in settings, a Project, or
CLAUDE.md.
FAQ
- Do XML tags actually help, or is it a meme?: They help. Anthropic’s own prompt-engineering docs lead with XML structuring as the way to make complex prompts unambiguous, and Claude parses the tags as boundaries between instructions, context, and inputs. The model understands any descriptive tag name.
- Where do I put the source material, top or bottom?: For long inputs, source at the top and your question at the bottom. Anthropic reports up to a 30% quality improvement from putting the query last on complex multi-document prompts. The recent-instruction bias also means your final instruction wins ties.
- How long should a Claude prompt be?: Long enough to be unambiguous, short enough to read back. 200-500 words is typical for serious work. Length is not the goal; removing ambiguity is.
- Can I still prefill Claude’s response to force JSON?: Not on the current models. A prefilled final assistant turn returns a
400error starting with the Claude 4.6 generation. Use Structured Outputs, ask for the schema directly, or wrap output in XML tags. - Do prompts I tuned for Claude 3.5 still work?: Mostly, but re-test them. Opus 4.7 follows instructions more literally, so prompts that relied on it “filling in the gaps” may now under-deliver, and old “you MUST” emphasis can cause over-triggering. Dial back the shouting and state scope explicitly.
- Should I say “please” and “thank you”?: Politeness neither measurably helps nor hurts. Clarity matters more. Spend the words on format and constraints instead.
Related
External references: Anthropic prompting best practices and the prefill / migration notes.