Patterns, Examples & Anti-patterns

Write System Prompts That Make Claude Do Exactly What You Need

Your first project. 20 minutes.

A well-written system prompt turns Claude from a general-purpose assistant into a precise, specialized tool. Whether you are building a product with the API or setting up a Claude Project for your team, the system prompt defines the ceiling of what Claude can reliably do for you.

A Claude system prompt is a set of instructions that runs before any conversation and shapes every response. The best system prompts follow the pattern: role definition + output format + constraints + examples. Claude follows structured system prompts with high fidelity.

Six Core Principles

What every good system prompt must do

Define the role
Start with who Claude is in this context. Not "You are a helpful assistant" — that's the default. Say "You are a senior TypeScript engineer reviewing code for a fintech startup." Specificity shapes every response.
Set the output contract
Specify format, length, and structure explicitly. "Respond in JSON with keys: summary, risk_level, action_items" removes ambiguity. Claude will honor format contracts consistently when they are part of the system prompt.
Constrain the scope
Tell Claude what not to do. "Do not speculate on topics outside the provided context. If unsure, say 'I don't know' and list what additional information would help." Constraints prevent hallucination drift.
Inject standing context
Include facts that are always true: the user's company, product category, audience, technical level, or business constraints. Claude uses this as grounding for every response.
Provide examples
One concrete input/output example in the system prompt is worth 300 words of instruction. Show Claude exactly what a good response looks like for the hardest case.
Handle edge cases explicitly
Think through what happens when the user sends something off-topic, ambiguous, or adversarial. Specify exactly how Claude should handle it — not "use judgment," but "respond with: [exact template]."

How to Write a System Prompt (6 Steps)

01
Start with role and context

Write one sentence describing who Claude is in this application. Specific job title + company type + audience level.

02
Define the output format

Specify structure, length, and any required fields. JSON, markdown, bullet points, word count targets — whatever your downstream system expects.

03
List explicit constraints

What Claude must never do. Edge case behavior. How to handle uncertainty. Escalation triggers.

04
Inject standing facts

Company name, product context, user segment, technical level. Anything that's always true about the user.

05
Add one worked example

Input → output. Pick the hardest real case. This calibrates Claude faster than any instruction block.

06
Test on adversarial inputs

Try off-topic questions, vague requests, and edge cases. Update the system prompt to handle each one explicitly.

Real System Prompt Examples

Code Review Assistant
You are a senior software engineer conducting code reviews for a TypeScript/Next.js codebase.

For every code snippet provided:
1. Identify security vulnerabilities (SQL injection, XSS, exposed secrets, missing auth)
2. Flag performance issues (N+1 queries, unoptimized re-renders, missing caching)
3. Note code style violations (no any types, explicit column selects only, parameterized queries)
4. Suggest specific rewrites for issues found

Output format:
{
  "risk_level": "critical|high|medium|low",
  "issues": [{"line": N, "type": "security|perf|style", "description": "...", "fix": "..."}],
  "approved": true|false
}

If the snippet is safe and clean, output: {"risk_level": "low", "issues": [], "approved": true}
Customer Support Bot
You are a support agent for [Product Name], a project management SaaS tool.

Context:
- Users range from individual freelancers to enterprise teams
- Common issues: billing questions, integration errors, permission problems, import failures
- Escalate to human agent if: refund request over $500, data loss reported, account compromised

Response rules:
- Answer in 3 sentences or fewer for simple questions
- Use numbered steps for any multi-step process
- Never speculate about timelines or make promises ("Your issue will be resolved by...")
- End every response with: "Was this helpful? Reply 'yes', 'no', or describe what you still need."

If you cannot answer confidently, say: "I'll flag this for our team — please expect a reply within one business day."
Content Editor
You are a professional editor for a B2B SaaS marketing team.

Brand voice: direct, expert, never jargon-heavy. Second-person ("you"), active voice, sentences under 20 words.

Never use: "leverage", "synergy", "game-changing", "unlock potential", "robust", exclamation points, or em dashes.

When editing:
1. Preserve the author's ideas and examples — change words, not meaning
2. Flag any claims that need a source with [CITE NEEDED]
3. Note if the opening hook is weak and suggest an alternative
4. Output the edited version followed by a 3-bullet change summary

For subject line or headline tasks: provide 5 variants with the primary goal (curiosity/benefit/urgency/social proof/question) labeled for each.

System Prompt Anti-Patterns

✗ "Be helpful, accurate, and concise."

Why it fails: This is the default — it tells Claude nothing about your specific context.

Fix: Define who Claude is, what it's helping with, and exactly what output format to use.

✗ "Always be positive and encouraging."

Why it fails: Tone instructions without examples produce generic warmth, not your actual brand voice.

Fix: Show the tone with a concrete before/after example in the system prompt.

✗ "Never make up information."

Why it fails: Negative constraints on complex behaviors are hard to enforce without specifics.

Fix: "If you're not confident, output: 'I'm not certain — here's what I'd need to know: [list]'" gives Claude a template to follow.

✗ "You are an expert in everything."

Why it fails: Broad expertise claims reduce calibration. Claude hedges less when it should hedge more.

Fix: Specify the actual domain: "You are an expert in HIPAA compliance for healthcare SaaS startups."

Frequently Asked Questions

What is the best Claude system prompt?

The best system prompts are specific, structured, and include role definition, output format, constraints, and examples. There is no universal best prompt, but the pattern of role + format + constraints + examples consistently produces the highest-quality output.

How long should a system prompt be?

As long as it needs to be. A 500-word system prompt with clear structure outperforms a 50-word vague one. Include role, format requirements, constraints, and 1-2 examples for optimal results.

What is the difference between a system prompt and a user prompt?

A system prompt runs before any conversation and shapes all responses. A user prompt is a single message within a conversation. System prompts set persistent behavior; user prompts make specific requests.

Can I use system prompts in Claude.ai?

Yes. Claude Projects let you set a system prompt (called custom instructions) that applies to every conversation within that project. In the API, system prompts are passed as the system parameter.

Master prompt engineering hands-on

Interactive exercises that build real prompting instincts.