Vault / wiki/201/system-prompts.md
updated 2026-05-28System Prompts
What a system prompt is
The instruction layer Claude reads before any user turn. It sets persona, rules, tools-of-trade, response style, and constraints. The user can't override it (in well-designed apps).
In the Messages API:
client.messages.create(
model="claude-sonnet-4-6",
system="You are an expert SQL reviewer...",
messages=[...],
)
Or as content blocks for caching:
system=[
{"type": "text", "text": "You are an expert..."},
{"type": "text", "text": LARGE_KNOWLEDGE_BASE, "cache_control": {"type": "ephemeral"}},
]
Anatomy of a strong system prompt
Anthropic's recommended structure (for non-trivial agents):
1. Role / identity — "You are a customer support agent for ACME..."
2. Core mission — what success looks like, the single primary goal
3. Tone & style — formal? terse? bilingual?
4. Capabilities & tools — what Claude can do, including tool names + purpose
5. Boundaries — what Claude must NEVER do; escalation rules
6. Output format — JSON schema, markdown, plain text
7. Examples (optional) — few-shot showing edge cases
Principles vs conditionals
A common cert exam concept:
- Principles ("Always cite sources") — apply universally, hold up under pressure.
- Conditionals ("If user is angry, transfer to human") — fragile, easy to dilute.
Prefer principles. Stack too many conditionals and the prompt degrades — Claude starts missing rules. This is the "dilution" failure mode.
Dilution
A long system prompt with too many rules at the same priority level causes Claude to weight them poorly. Mitigations:
- Move critical rules to the start AND end of the system prompt (recency + primacy).
- Use a
# CRITICALheader for must-never-violate rules. - Move stable reference material into a cached block and keep the rule-of-conduct prompt short.
- Split into focused subagents instead of one mega-prompt.
System prompt vs user instruction
| Use system for | Use user for |
|---|---|
| Stable rules across all turns | Per-request data |
| Persona, tone | The actual task |
| Tool descriptions in some setups | The user's literal message |
| Long cached reference docs | Variable inputs |