LikePrompts

How to Write Claude System Prompts That Actually Constrain Output

LikePrompts Editorial August 24, 2026
How to Write Claude System Prompts That Actually Constrain Output

Image generated with AI.

Vague Claude system prompts get vague answers. Learn the exact structure Anthropic recommends - role, hard rules, XML tags, few-shot examples and output formats that Claude actually follows.

Most claude system prompts fail for one reason: they are vague. Claude then has to guess what you want, and it guesses differently every time. Here is the structure Anthropic recommends to make Claude actually follow your constraints.

The good news is that this is a solved problem. Anthropic publishes the exact techniques its own engineers use, and they all point in the same direction: be explicit, separate data from instructions, specify the output format, and show examples. Apply those four moves and your system prompts stop being suggestions and start being specifications.

Why Vague Claude System Prompts Fail

Anthropic's prompt engineering guidance puts "be explicit and clear" at the top of the list, and the reason is simple: most quality problems with Claude are instruction problems, not model problems. When a system prompt says "always do your best" or "answer accurately", Claude has to decide what good looks like. It will decide differently depending on the conversation, the context, and even the phrasing of the user message. Every detail you leave unspecified is a decision Claude makes on its own, and those decisions drift.

The fix is not a longer prompt. It is a more specific one. A system prompt built from clear roles, hard rules, structured sections and an explicit output contract removes the ambiguity before Claude ever sees the task. The rest of this guide walks through each piece of that structure and shows you how to assemble it.

What a System Prompt Is (and Where It Lives)

Before changing how you write, it helps to know exactly what the system prompt is. The system prompt is the persistent instruction block that defines who Claude is and how it should behave for the entire conversation. Everything in it stays active from the first message to the last, which makes it the right place for the rules and constraints you want applied consistently, no matter what the user asks.

System Prompt vs. User Message

The system prompt sets the frame; the user message carries the task. A one-off instruction belongs in the user message. A behavior that should hold for a whole session - a writing style, a security rule, a format contract - belongs in the system prompt. A common mistake is duplicating the same instructions in both places, which bloats the context and creates room for contradictions. Keep the system prompt stable, and let each user message do one concrete job.

Where to Put It: API, Claude.ai Projects and the Web App

Where you type the system prompt depends on where you work. In the API, you pass it as the system parameter of the messages request. On Claude.ai, Projects expose a custom instructions field that acts as a system prompt for every conversation inside that project, which is ideal for team-wide standards. The web app offers a similar custom instructions area for general preferences. The location does not change the mechanics: the same writing rules apply everywhere, as documented in Anthropic's prompting best practices.

The Anatomy of a Constraining System Prompt

A system prompt that actually constrains output has five moving parts. You do not always need all five, but each one removes a specific kind of ambiguity, and together they cover the cases where Claude most often goes off the rails.

Role and Context

Start by telling Claude who it is and why it matters. Role prompting through the system prompt measurably improves tone and accuracy when the role carries relevant expertise: "You are a senior technical editor" produces different output than "You are a copywriter", even with the same task. Add one or two sentences of context about the audience and the goal so the role is not an empty label.

Hard Rules (Do and Do Not)

Write the non-negotiables as explicit always and never statements. "Always cite the source of every factual claim" and "Never invent statistics" are actionable constraints; "be accurate" is a wish. Hard rules are the cheapest constraint you can add, and they compound: each rule removes one whole class of bad output. For a production example of rule-driven constraints, the Claude Data Cleaning Partner prompt locks down transformation rules so data changes stay predictable.

XML Tags That Separate Data from Instructions

For longer prompts, XML tags such as <role>, <context>, <rules> and <output> organize the content and visibly separate data from instructions. Anthropic notes that modern models understand structure even without tags, but tags remain genuinely useful in specific situations: large data blocks, complex instructions with several sections, and any prompt where you need Claude to treat one part as content and another part as command. Tags also make the prompt easier to maintain, because every section has a clear home.

Output Format Specification

This is the single highest-leverage constraint in the list. If you specify the output format - exact JSON fields, a markdown structure, a table, a length limit - you eliminate most useless answers before they happen. "Return a JSON object with the fields id, title and summary" is a constraint. "Summarize this" is a wish. A format specification turns an open-ended generation into a contract. For a live example of strict output structure, the Claude Meeting Notes Action Items prompt forces every action item into an owner and deadline shape.

Few-Shot Examples

When describing the result is not enough, show it. One to three input and output pairs inside the prompt demonstrate the desired result directly: Claude infers format, tone and level of detail from the example rather than from your adjectives. Few-shot prompting is especially effective for output format, because a single example is worth a paragraph of description. Keep the examples short and representative - two good pairs beat five sloppy ones.

A Reusable System Prompt Template

Here is a skeleton that combines every constraint described above. Fill in the angle-bracket sections, adjust the rules to your domain, and you have a constrained system prompt in minutes:

<role>
You are a senior technical writer specialized in developer documentation.
</role>

<context>
The reader is a developer with basic programming knowledge.
The goal is a tutorial that can be followed without external help.
</context>

<rules>
- Always explain concepts before showing code.
- Never use jargon without defining it.
- Keep every section under 300 words.
</rules>

<output>
Return the article in markdown with an H2 heading per section.
Start with a two-sentence summary, then the sections, then a conclusion.
</output>

If you want a production-ready version of this pattern, the Claude Technical Docs Writer prompt applies fixed structure and output rules to technical documentation, and is a good reference for how role, rules and format work together.

Common Mistakes That Weaken Constraints

Even with the right structure, a few habits quietly undo your constraints. The first is asking for everything at once: one giant prompt with twenty requirements performs worse than the same task broken into steps, because Claude handles large tasks more reliably when they are divided. The second is contradictory rules - "be concise" next to "cover every detail" - which leave Claude to pick a winner. The third is describing instead of specifying: "use a professional tone" is a description, while "write in complete sentences, active voice, no marketing adjectives" is a specification Claude can follow.

There is also a cost consideration. Long system prompts consume context on every request, so they should earn their tokens. If you use the API, prompt caching lets you pay a fraction of the price for the repeated prefix, which makes a well-built system prompt cheap to reuse at scale. The lesson is not "keep it short" but "keep it useful".

Proven Constrained Prompts to Steal

The fastest way to internalize these ideas is to read prompts that already apply them in production. The LikePrompts catalog carries several Claude prompts built around the constraints above: the Claude Meeting Notes Action Items prompt enforces an owner and deadline output format, the Claude Data Cleaning Partner prompt hard-codes transformation rules, and the Claude Technical Docs Writer prompt shows role and structure working together. Study how each one states its rules and formats its output, then apply the same moves to your own system prompts.

The pattern is always the same: be explicit, separate data from instructions, specify the output, and show an example. Do that, and Claude will follow your constraints - not because you asked it to behave, but because you left it nothing to guess. Anthropic's own 2026 prompt engineering best practices confirm that most quality gains come from exactly these moves.

LikePrompts Editorial

Practical guides for getting the most out of AI prompts — written by the LikePrompts team.