1. Use XML Tags to Structure Your Input
The single highest-leverage change most Claude users can make is switching from free-form prose to XML-delimited sections. Anthropic's own documentation recommends this, and for good reason: Claude's training specifically optimizes attention to XML-structured content.
The pattern is simple. Instead of writing a wall of text, wrap distinct inputs — the task, the context, the data, the constraints — in descriptive XML tags:
<role> You are a senior financial analyst specializing in SaaS metrics. You have deep familiarity with ARR, NRR, CAC payback, and LTV/CAC ratios. </role> <context> I am preparing a board deck for Q1 2026. The audience is three board members — two former operators, one financial investor. They care about unit economics and runway, not vanity metrics. </context> <task> Analyze the following metrics table and write a 3-paragraph executive summary. Flag any metric that looks anomalous relative to SaaS benchmarks. </task> <data> ARR: $4.2M | MoM Growth: 8.3% | NRR: 112% | Gross Margin: 71% CAC Payback: 18 months | LTV/CAC: 3.1x | Runway: 22 months </data> <constraints> - Maximum 250 words - Plain language, define any jargon on first use - Flag runway below 18 months as a board-level concern </constraints>
This is dramatically better than: "Analyze this SaaS metrics table and write an executive summary for my board." XML tags give Claude unambiguous boundaries between what you are, what you know, what you want, what you're working with, and what limits apply. Each section gets full attention independently.
Tag names are flexible. You can use <instructions>, <background>, <examples>, <output_format> — whatever labels make the structure legible to a reader. Consistency within a project matters more than which names you pick.
XML tags are not decoration. Claude treats tagged sections as distinct semantic units. A prompt with five well-labeled tags typically outperforms an equivalent single paragraph by a significant margin on complex tasks — especially when the prompt mixes instructions with data.
2. Role-Context-Task Framing
Every Claude prompt should answer three questions before making any request: Who are you? (role), What's the situation? (context), and What exactly do you want? (task). Leaving any of these implicit forces Claude to guess, and its defaults may not match your intent.
Define the expertise
Specific domain, experience level, and communication style. "Expert Python developer who writes production code, not tutorials" beats "code assistant."
Set the scene
Who is the audience? What decisions hinge on this output? What constraints or prior decisions are already fixed?
State exactly what you want
Format, length, structure, success criteria. "Write a report" is not a task. "Write a 400-word report in three sections with a single recommendation at the end" is.
Role framing in Claude works slightly differently than in other models. Claude responds well to domain-specific competency framing — "You have 15 years of experience in tax law specializing in S-corp elections" — rather than character personas like "You are TaxBot." Competency framing anchors the knowledge domain and communication register without triggering guard-rails that persona framing sometimes activates.
Context is the most commonly omitted element. Most users jump straight from role to task. But Claude calibrates tone, depth, and vocabulary based on who the output is for. A one-page memo for a non-technical CEO should read differently than a technical spec for a senior engineer — and Claude can nail both, but only if you tell it which situation it's in.
3. Few-Shot Examples: Calibrating Output Format
Few-shot prompting is widely understood in theory and consistently underapplied in practice. Most users provide zero examples and then wonder why Claude's output format doesn't match what they had in mind. The fix is mechanical: show Claude one to three examples of the exact output you want, then ask for the new one.
Claude is particularly good at generalizing from examples when they are placed in a dedicated <examples> block. Notice what the examples below communicate that prose instructions cannot — vocabulary level, sentence rhythm, how much detail to pack in, and whether qualifying language is appropriate:
<task> Write a one-line summary of each company in the format shown in the examples. </task> <examples> <example> Company: Stripe Summary: Global payment infrastructure powering millions of internet businesses with a developer-first API. </example> <example> Company: Notion Summary: All-in-one workspace combining notes, wikis, and databases for teams that want to replace five separate tools. </example> </examples> <companies> - Linear - Vercel - Retool </companies>
Two examples calibrate format precisely. A paragraph of instructions tries to describe it and often fails. The examples communicate what instructions cannot: the exact vocabulary level, whether to use passive voice, how many clauses per sentence, and whether to name the product in the summary or not.
One underused technique: the negative example. Adding a <bad_example> alongside a <good_example> — and labeling why the bad one fails — is one of the fastest ways to eliminate a recurring output pattern you don't want. Claude responds to "do not do this" with higher reliability when the violation is shown rather than described.
Stop guessing. Learn the system.
PromptSharp includes 30+ battle-tested templates built for Claude, with annotated examples for every technique covered in this guide. Drop them into your projects and get better output from the first use.
Start Learning with PromptSharp4. System Prompt Structure and Hierarchy
In Claude's architecture, the system prompt sits above the conversation and establishes persistent rules that apply across the entire interaction. Understanding this hierarchy lets you build prompts that stay coherent across long, complex conversations rather than drifting as the context grows.
A well-structured system prompt for Claude covers four zones:
- Identity and expertise — who Claude is in this context, what knowledge to draw from, what communication style to default to
- Behavioral rules — what to always do, what to never do, how to handle edge cases and uncertainty
- Output format defaults — default response length, structure, use of headers, code formatting preferences, markdown vs plain text
- Domain knowledge — project-specific terminology, decisions already made, constraints the model should treat as fixed regardless of user instructions
The critical structural insight: rules stated in the system prompt take precedence over instructions in the human turn when they conflict. This is intentional — it lets you lock behaviors (never use passive voice, always cite sources, output only valid JSON) that survive even if a later instruction appears to contradict them.
Common failure mode: putting critical constraints only in the first human turn. A constraint buried in a user message gets deprioritized as the context window fills. If the constraint matters across the entire conversation — output format, forbidden topics, required structure — it belongs in the system prompt.
Placing critical format or behavior constraints only in the human turn. As conversation length grows, early user messages get compressed in Claude's attention window. System prompt rules stay persistent. If you need a constraint to hold for 20+ turns, it must be in the system prompt.
5. CLAUDE.md: Persistent Context for Claude Code
If you use Claude Code — Anthropic's CLI — the most powerful prompt engineering tool available is the CLAUDE.md file. This file lives in your project directory (or any parent directory) and is automatically injected into Claude's context on every session start. It is, in effect, a permanent system prompt that travels with your project.
Most developers who discover CLAUDE.md use it for a single sentence like "this project uses TypeScript." That significantly underuses the mechanism. A mature CLAUDE.md file does several things simultaneously:
- Encodes architectural decisions so Claude never suggests patterns you've already ruled out — "we use Zustand for state management, never Redux; we use tRPC for API routes, never REST"
- Sets code style rules at the project level rather than repeating them per-prompt — "functions must stay under 40 lines, no default exports, always explicit return types"
- Provides domain context Claude would otherwise lack — "users are institutional traders, not retail investors; assume familiarity with options greeks and margin mechanics"
- Defines workflow laws for recurring task types — "before editing any SQL migration, read the existing migrations directory to match naming conventions and transaction patterns"
- Lists what NOT to do — the negative space is often more valuable than positive instructions because it encodes hard-won lessons about what goes wrong in this specific codebase
The CLAUDE.md file supports a directory hierarchy. A root-level file sets project-wide rules. Subdirectory files can add or override rules for specific subsystems — a CLAUDE.md in /frontend can layer React-specific rules without affecting backend Claude sessions.
Think of CLAUDE.md as the difference between briefing a new contractor once versus briefing them at the start of every conversation. The file makes Claude permanently aware of your project's conventions, saving tokens and eliminating the cognitive overhead of re-establishing context every session.
6. Claude-Specific Formatting and Reasoning Tips
Several techniques work particularly well with Claude due to its training and constitutional design.
Explicit reasoning requests
Claude responds strongly to chain-of-thought cues. Prefacing complex tasks with "Think step by step before answering" or adding a <thinking> block where Claude can reason before producing final output consistently improves accuracy on multi-step problems. Extended thinking mode, available via the API, takes this further — Claude runs an internal reasoning pass invisible to the user before generating the response. For tasks where accuracy matters more than speed, this is worth enabling.
Output format specification
Claude's default format is verbose markdown. For programmatic use, always specify output format explicitly: "Return only valid JSON. No markdown fences, no explanation, no preamble." For prose, be equally specific about structure: "Three paragraphs. No headers. Conversational tone, no jargon." Format instructions in the system prompt are stickier than in the human turn — put them there and the format holds across a long conversation.
Prefilling the assistant turn
Via the Anthropic API, you can prefill the beginning of Claude's response to constrain its opening. Prefilling ```json forces Claude to continue with a JSON code block. Prefilling "Based on the data provided:" primes a more analytical, evidence-anchored response than an empty start. This technique is unavailable in the Claude.ai chat interface but is fully supported via API and Claude Code.
Uncertainty and confidence calibration
Unlike models that confabulate confidently, Claude responds well to explicit uncertainty instructions. Adding "If you are not certain about a fact, say so explicitly rather than guessing. Prefer 'I'm not sure, but...' over a confident incorrect answer" materially reduces hallucination rates on factual tasks. Combining this with a self-check step — "After drafting your answer, verify each factual claim is accurate before outputting the final response" — compounds the benefit.
Hard length limits vs soft adjectives
Claude defaults toward thoroughness. Adjectives like "brief" or "concise" are interpreted generously. Hard limits are not. "Maximum 150 words" is a constraint Claude respects. "Keep it short" is a preference Claude weighs against its instinct to be comprehensive. Use numeric limits whenever output length is genuinely important, and pair them with instructions on what to cut if the limit requires trimming.
These techniques multiply. XML structure + few-shot examples + explicit output format + system prompt constraints, all applied together, produce output that is qualitatively different from any single technique applied in isolation. The combination is the point — each layer constrains a different axis of variance in Claude's output.
Ready to put this into practice?
PromptSharp delivers 30+ ready-to-use Claude templates — built with XML tagging, role-context-task framing, and format constraints already wired in. Every technique from this guide, pre-applied and ready to use.
Start Learning with PromptSharp