Claude API System Prompt Design: Examples That Work
If you're searching for Claude API system prompt design examples, you're probably past the "write a nice persona description" stage and into the harder problem: getting Claude to consistently follow format rules, stay in scope, and behave predictably across thousands of requests. This article gives you concrete, reusable system prompt patterns — not generic advice about being "clear and specific."
The short answer: effective system prompts for the Claude API are structured, not conversational. They separate role, constraints, output format, and edge-case handling into distinct blocks instead of one paragraph of prose. Below are patterns you can adapt directly, followed by the mistakes that cause system prompts to degrade under real traffic.
Why system prompt structure matters more than wording
Claude responds to a system parameter (not a chat message) that persists across the whole conversation. Because it's evaluated on every turn, small ambiguities compound — a vague instruction that works fine once will drift after 5–6 turns of context. The fix isn't longer prompts, it's structured ones: headers, numbered rules, explicit output contracts.
Pattern 1: Role + scope + refusal boundary
This is the baseline for any production assistant. Separate what Claude is, what it does, and what it won't do.
You are a billing support assistant for Acme SaaS.
Scope:
- Answer questions about invoices, subscription plans, and refund policy.
- Use only the account data provided in the user message.
Boundaries:
- If asked about topics outside billing (technical bugs, legal advice), say:
"I can only help with billing questions here — please contact support@acme.com for that."
- Never invent invoice numbers, dates, or amounts not given to you.
Tone: concise, professional, no exclamation marks.
This works because the refusal boundary is a literal string, not "politely decline." Giving Claude the exact sentence to use reduces variance in how refusals are phrased.
Pattern 2: Strict output format (JSON contracts)
If downstream code parses the response, don't describe the format in prose — show the schema and forbid extra text.
You extract structured data from support tickets.
Output rules:
- Respond with valid JSON only. No markdown, no explanation, no code fences.
- Schema:
{
"category": "billing" | "technical" | "account" | "other",
"urgency": "low" | "medium" | "high",
"summary": string (max 20 words)
}
- If information is missing, use null for that field. Never omit keys.
Claude follows strict enumerations well when the schema is explicit and the "no extra text" rule is stated as its own line, not buried in the middle of the role description.
Pattern 3: Multi-section prompts for complex agents
For agents that use tools or handle multi-step reasoning, split the system prompt into labeled sections Claude can reference internally:
## Role
You are a research assistant that answers questions using the provided search tool.
## Process
1. Decide if the question needs a search or can be answered from general knowledge.
2. If searching, use the search tool with a specific query, not the raw user question.
3. Cite the source title in your final answer.
## Constraints
- Never call the search tool more than twice per question.
- If search results are empty, say so explicitly rather than guessing.
This maps cleanly onto tool-using workflows — see /docs/tools for how tool definitions interact with system-level instructions when you're routing Claude through an API.
Pattern 4: Few-shot examples inside the system prompt
For tone or formatting that's hard to describe abstractly, show 2–3 examples directly in the system prompt rather than relying on the conversation history:
You rewrite customer messages into professional tone. Examples:
Input: "ur app is broken again smh"
Output: "I'm experiencing a recurring issue with the app."
Input: "cancel my sub NOW"
Output: "I'd like to cancel my subscription, effective immediately."
Apply the same transformation to the user's next message. Output only the rewritten text.
Few-shot examples in the system prompt are more reliable than describing style with adjectives like "formal" or "friendly," which Claude interprets inconsistently across edge cases.
Common mistakes that break system prompts at scale
- Mixing instructions with context. Don't put dynamic data (user name, account tier, today's date) inside the system prompt string template if it changes per request — inject it cleanly via a template, and keep the instructional part static so you can cache and version it.
- Over-specifying tone with no format rules. "Be helpful and friendly" without an output contract leads to inconsistent response length and structure once real users start asking edge-case questions.
- No explicit fallback behavior. Always define what happens when the model doesn't have enough information — "say X" is more reliable than leaving it to infer a graceful response.
- Treating the system prompt as a one-time write. Production prompts need versioning. Log which prompt version produced which response so you can trace regressions.
Testing system prompts before shipping
A system prompt that looks correct in a one-off curl test can fail under real traffic once users send malformed input, unexpected languages, or adversarial phrasing. Before shipping:
- Run the same prompt against 10–20 real (or realistic) inputs, not just the happy path.
- Check output format compliance programmatically — parse the JSON, don't eyeball it.
- Test what happens with empty or missing fields in the user message.
If you're calling the API directly, a minimal request with a structured system prompt looks like this:
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"system": "You extract structured data... [schema as above]",
"messages": [{"role": "user", "content": "Ticket: app crashes on login"}]
}'
}'
SubToAPI exposes the same /v1/messages interface as the native Claude API, so these system prompt patterns carry over directly — see /docs/messages for the full request reference and /docs/quickstart if you're setting up a key for the first time.
Keeping prompts maintainable as you scale
Once you have more than two or three system prompts in production, store them outside your application code — as config, not string literals — so you can update tone or rules without redeploying. Pair that with response logging (which SubToAPI's dashboard provides per key) so you can see which prompt version handled which request when something goes wrong.
FAQ
Should the system prompt or the first user message carry the main instructions? Use the system prompt for persistent rules (role, format, boundaries) and the user message for the actual task or data. Mixing them makes prompts harder to version and test independently.
How long should a Claude system prompt be? As long as it needs to be to remove ambiguity — there's no fixed limit that helps. Structured 200–400 word prompts with clear sections usually outperform both one-liners and unstructured 1,000-word essays.
Can I change the system prompt per request without retraining anything? Yes — the system prompt is just a parameter on each API call, so you can swap it per request, per user tier, or per feature with no retraining involved. That's the main lever for customizing Claude's behavior through the API.