Claude API System Prompt Design Guide
A system prompt is the single highest-leverage lever you have when building with the Claude API. It sets the model's role, tone, constraints, and output format before the user ever types a word. If you're struggling with inconsistent outputs, hallucinated capabilities, or responses that ignore your formatting rules, the fix is almost always in how the system prompt is structured, not in the model itself.
This guide covers how to design a system prompt that actually controls Claude's behavior: what to include, how to order it, how long it should be, and the mistakes that cause prompts to silently degrade over time.
What the System Prompt Actually Controls
In the Claude API, the system prompt is a separate field from the messages array — it's not a turn in the conversation, it's a standing instruction that applies to every turn. It's the right place for:
- Role and persona — who Claude is in this context ("You are a billing support assistant for Acme Corp")
- Scope and refusals — what Claude should and shouldn't do
- Output format — JSON structure, markdown, length limits
- Tone and voice — formal, casual, terse, empathetic
- Tool-use rules — when to call a tool vs. answer directly
- Static reference data — small amounts of context that apply to every request
It's the wrong place for per-request variables like user names, timestamps, or dynamic documents — those belong in the first user message, where they're easier to update and don't bloat your cached system prompt.
Structure: Order Matters More Than Length
Claude reads the system prompt top to bottom, and instructions near the top tend to anchor behavior more strongly than instructions buried in paragraph six. A good structure looks like this:
1. Identity and role (1-2 sentences)
2. Primary task and scope
3. Hard constraints (what NOT to do)
4. Output format requirements
5. Edge case handling
6. Examples (if needed)
Here's a concrete example for a support bot:
You are a support assistant for a SaaS billing platform. You answer
questions about invoices, subscriptions, and payment methods.
You must not:
- Discuss pricing changes not listed in the provided plan data
- Process refunds directly — escalate to a human agent
- Reveal internal account IDs or raw database fields
Always respond in plain text, under 150 words, in a direct and
friendly tone. If the question is outside billing (e.g. technical
bugs), say so and suggest contacting support@example.com.
This is short, ordered by priority, and testable — you can write a handful of prompts that should trigger the refusal behavior and confirm they do.
Common Mistakes That Break System Prompts
Burying constraints in prose. "Please try to avoid being too verbose and also don't mention competitors unless asked and remember to stay professional" is three separate rules mashed into one sentence. Claude follows numbered or bulleted constraints far more reliably than run-on instructions.
Contradicting yourself. If you say "always respond in JSON" in one paragraph and "explain your reasoning conversationally" in another, Claude will inconsistently pick one. Read your system prompt as if you were the model — does every sentence agree with every other sentence?
Over-specifying tone with adjectives instead of examples. "Be friendly but professional and warm but not too casual" is vague. One example response does more work than five adjectives.
Treating the system prompt as a dumping ground. Long system prompts that mix static instructions with per-request data (user history, retrieved documents, today's date) waste tokens on every call and make caching less effective. Keep dynamic content in the user message.
Forgetting output format enforcement. If you need structured output, state the exact format and give a minimal example. For strict JSON, pair this with the tools parameter rather than relying on prompt instructions alone — see /docs/tools for how structured tool definitions make output format far more reliable than prompt text alone.
Testing Your System Prompt
Treat your system prompt like code: version it, test it, and regress-check it before deploying changes.
- Write 10–20 representative test inputs covering normal cases, edge cases, and adversarial inputs (users trying to get Claude to break scope).
- Run them against the current prompt and save outputs as a baseline.
- When you change the prompt, rerun the same inputs and diff the outputs.
- Watch specifically for regressions in refusal behavior and output format — these are the two areas most likely to silently break when you add new instructions.
If you're serving the Claude API to multiple applications or teams, this is also where having clean API access per app matters. SubToAPI turns your Claude access into standard HTTPS endpoints with per-application API keys, so each app can carry its own system prompt and configuration without teams stepping on each other's settings. Usage is tracked per key, which makes it easy to see which system prompt version is driving token consumption across your /pricing plan.
A Minimal Working Example
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 300,
"system": "You are a changelog summarizer. Given raw commit messages, output 3-5 bullet points in plain English, no technical jargon, no commit hashes.",
"messages": [
{"role": "user", "content": "fix: null pointer in auth middleware\nfeat: add retry logic to webhook sender\nchore: bump deps"}
]
}'
The system prompt here is doing all the work: it defines the task, the output format (3-5 bullets), and the constraint (no jargon, no hashes) in two sentences. That's the target to aim for — dense, ordered, unambiguous.
If you're just getting started with the API shape, the /docs/quickstart and /docs/messages pages walk through the full request structure, and /docs/streaming covers how system prompts behave in streamed responses.
Questions
How long should a Claude system prompt be? As long as it needs to be to cover role, constraints, and format — often just a few sentences to a few paragraphs. Long prompts aren't wrong, but every unnecessary sentence is a chance for contradiction. Prioritize clarity and ordering over length.
Should I put few-shot examples in the system prompt? Yes, for format-critical tasks. One or two well-chosen examples of input/output pairs in the system prompt are often more effective than additional descriptive instructions, especially for structured output.
Does the system prompt affect token costs on every request? Yes — it's sent with every call and counted as input tokens. Keep static instructions in the system prompt and move per-request variable data (documents, user context) into the user message to avoid unnecessary token overhead and to benefit from prompt caching where supported.