Claude System Prompts
System prompts are the most powerful tool in Claude prompt engineering. They define Claude's role, behaviour, output format, and operating constraints for every message in a conversation or workflow. A well-designed system prompt is the difference between Claude that reliably does what you need and Claude that's inconsistent, verbose, or off-format. This guide covers how to write production-quality system prompts.
What System Prompts Do
The system prompt is a special instruction you provide that Claude treats as foundational context — above the conversation itself in authority. It defines:
- Who Claude is in this context: Its role, expertise, and persona
- What format to use: The output structure, JSON schemas, length constraints
- What rules to follow: Business logic, routing criteria, compliance requirements
- How to handle edge cases: Uncertain inputs, missing data, out-of-scope requests
In the Anthropic API, the system prompt is a separate parameter from the messages array — making it clearly distinct from user messages and giving it persistent authority throughout the conversation.
The Four-Part System Prompt Structure
Effective system prompts have four parts:
Part 1: Role and context
Part 2: Output format
Part 3: Business rules
Part 4: Edge case handling
Writing the Role Description
The role description anchors everything else. Make it:
Specific about domain: "Customer support agent for a SaaS company" is good. "Helpful assistant" is not — it's too vague to anchor behaviour.
Specific about knowledge: "You have access to our product documentation and customer account information via the available tools." This tells Claude what it knows and doesn't know.
Specific about authority: "You can issue refunds under $50 and provide 30-day extensions to trial accounts." Explicit authority prevents both under-doing (not helping when you should) and over-doing (taking unauthorised actions).
Output Format Design
The output format section is the most important part for automation. Design it before writing the rest of the prompt.
JSON for structured processing: Always use JSON for automation. Define the schema precisely:
- List every field name
- Specify the type (string, boolean, number)
- Specify allowed values for enum fields
- Specify constraints (max length for strings)
No additional text: "Return only the JSON object" prevents Claude from adding prose before or after the JSON that would break parsing.
Handling optional fields: For fields that may not apply: "Include discount_reason only if a discount was offered. Omit the field otherwise." This is cleaner than always including null.
Common System Prompt Patterns
Classifier:
Extractor:
Generator with constraints:
Router:
Testing and Iterating System Prompts
Test your system prompt with a diverse set of inputs before deploying:
- Normal cases: 10-15 typical inputs the prompt will process
- Edge cases: Inputs with missing data, unusual formats, or multiple intents
- Adversarial inputs: Attempts to get Claude to behave outside its defined role
- Minimum and maximum length: Very short and very long inputs
For each test, verify:
- The JSON is valid
- All required fields are present
- Enum fields contain only allowed values
- The response is appropriate for the input
- Edge cases are handled as specified
Recommended Tools
- Claude.ai — Develop and test system prompts interactively
- Anthropic API Console — API playground for system prompt testing
- n8n — Deploy tested prompts in production workflows
- Make.com — Visual system prompt configuration in automation scenarios
“A system prompt is production code. It determines what your AI automation does. Version-control it, test it with real data, and change it carefully.”
Related articles
Building a 24/7 customer support agent with Claude and n8n
A production teardown — routing, retrieval, escalation, and the guardrails that keep it safe.
Prompt engineering for reliable automation workflows
Prompts that survive contact with messy production data — structure, schemas, and fallbacks.
Claude tool use: building agents that take real actions
Wiring Claude to your stack safely — schemas, confirmation steps, and audit trails.