The three parts of a system prompt
Every system prompt, no matter how complex, breaks down into three parts. These are the load-bearing walls of your prompt:
1. Identity/Role
"You are a..." — Who is the AI? What's its expertise, background, and perspective?
2. Instructions
"Do this..." — What should the AI do? How should it behave? What format should responses take?
3. Constraints
"Never..." — What shouldn't it do? What are the boundaries and safety rails?
Part 1: Identity and Role
This is the AI's character. It answers: "Who is speaking?" The more specific the role, the better the results.
Too vague:
"You are a helpful assistant."
Better:
"You are an expert code reviewer with 10 years of experience in Python. You prioritize security, performance, and readability. You've worked on systems handling millions of requests."
The second version gives Claude context about experience level, values, and background — which shapes every response.
Part 2: Instructions
These are the behaviors and outputs you want. Include format preferences, step-by-step breakdowns, examples, and tone.
Example structure:
- When analyzing code, always check for: security vulnerabilities, performance bottlenecks, and code clarity.
- Explain findings in clear, concise language. Provide specific suggestions for improvement.
- Always include example code showing the fix.
- Format your response as: Problem → Impact → Solution → Example.
Part 3: Constraints
These are the guardrails. What shouldn't the AI do? What are the limits of its authority?
Examples:
- Never share or explain API keys, database credentials, or authentication tokens.
- Don't make up information. If you don't know something, say so.
- Don't optimize for brevity at the expense of accuracy.
- Don't approve dangerous code patterns without warning.
Full example: All three parts together
# IDENTITY
You are an expert technical writer specializing in making complex concepts accessible. You have a background in both software engineering and education.
# INSTRUCTIONS
- Explain concepts by building from first principles.
- Use analogies and real-world examples.
- Assume the reader has no prior knowledge.
- Structure answers with: Definition → Why it matters → How it works → Real example.
- Use simple, active language. Avoid jargon unless necessary.
# CONSTRAINTS
- Don't assume any prior knowledge.
- Don't use industry jargon without explaining it first.
- Don't oversimplify to the point of inaccuracy.
Why all three parts matter
Missing role
The AI guesses what level of expertise you want. Responses become generic.
Missing instructions
The AI doesn't know what format or style you expect. Hit-or-miss results.
Missing constraints
The AI might make assumptions or step outside safe boundaries.
How the three parts interact
Identity, Instructions, and Constraints are not independent knobs — they multiply. A vague identity weakens even crisp instructions because the model has no anchor for what "good" looks like. Detailed instructions paired with no constraints produce confident but unsafe output. Strict constraints layered onto a generic role yield a cautious assistant that refuses to help with reasonable requests.
The order on the page matters too. Models read top-down and weight earlier tokens more heavily, so the conventional ordering is Identity → Instructions → Constraints. Identity frames every line that follows; instructions define the work; constraints sit at the bottom as the final filter. Putting constraints first tends to make the model overly cautious; burying identity in the middle makes the persona feel unstable.
A practical test: read your system prompt out loud as if you were briefing a contractor on their first day. The role should feel concrete enough that a new hire knows how to introduce themselves. The instructions should read like a checklist they can refer back to. The constraints should sound like things you would put in the employment contract — short, firm, and non-negotiable. If any of those three doesn't quite land, that's the layer to revise.
Reusable templates by use case
Three production-ready system prompts that show all three parts working together. Copy, adapt, and version them in your repo.
Template: Customer support agent
# IDENTITY
You are a senior customer support specialist for Acme, a B2B SaaS analytics product.
You have access to the product docs and the user's account context.
# INSTRUCTIONS
- Acknowledge the user's issue in one sentence before asking anything.
- Walk through troubleshooting in numbered steps the user can follow.
- If the issue requires engineering, escalate with a ticket draft.
- End every reply with: "Anything else I can help with?"
# CONSTRAINTS
- Never reveal internal pricing, roadmap, or engineering decisions.
- If asked about a feature you cannot verify in the docs, say so explicitly.
- Do not promise timelines for fixes — escalate instead.
Template: Senior code reviewer
# IDENTITY
You are a staff engineer reviewing Python pull requests for a high-traffic backend.
Your bar is security, performance, and clarity, in that order.
# INSTRUCTIONS
- Quote the exact line you are commenting on.
- Classify each finding as: Bug, Risk, or Nit.
- Suggest the smallest patch that resolves the issue.
- If the diff looks correct, say so and stop.
# CONSTRAINTS
- Do not invent context that is not in the diff.
- Never approve raw SQL string interpolation or shelled-out subprocess input.
- Do not optimise for brevity at the expense of correctness.
Template: Long-form content writer
# IDENTITY
You are a technical writer who has shipped developer-facing docs at GitHub and Stripe.
You write for engineers who skim first and read second.
# INSTRUCTIONS
- Lead every section with the answer; explain afterwards.
- Use short sentences, active voice, no marketing fluff.
- Include a runnable code example in any "how-to" section.
- Close with a "Next steps" list of 3 concrete actions.
# CONSTRAINTS
- Never invent API names, versions, or stats — flag uncertainty instead.
- Avoid em dashes, "delve", "in today's fast-paced world", and other AI clichés.
- Do not exceed 1200 words without explicit instruction.
For the user-side counterpart to these prompts, see our prompt anatomy guide covering message-level structure, and role and persona prompting for picking effective identities.
System Prompt Anatomy FAQ
What are the three parts of a system prompt?
Every system prompt has three core parts: Identity/Role (who the AI is), Instructions (what the AI should do and how), and Constraints (what the AI should not do). Together they shape every response the model generates.
Why does the Identity section matter in a system prompt?
The Identity section tells the AI who it is — its expertise, background, and perspective. A specific role like 'expert Python code reviewer with 10 years of experience' produces far better results than a vague 'helpful assistant' because it activates relevant knowledge and reasoning patterns.
What happens if a system prompt is missing constraints?
Without constraints, the AI may make assumptions, share unsafe information, or step outside appropriate boundaries. Constraints act as guardrails that keep the model focused and safe across different inputs.
How long should a system prompt be?
There is no strict length limit, but effective prompts are concise and well-structured. A good system prompt covers Identity, Instructions, and Constraints in a few focused paragraphs rather than rambling for pages.
Can I use the same system prompt structure for any AI model?
Yes, the three-part anatomy (Identity, Instructions, Constraints) is a universal framework that works across Claude, GPT, Gemini, and other large language models. The specific wording may need tuning per model, but the structure transfers.
What order should Identity, Instructions, and Constraints appear in?
Identity first, Instructions second, Constraints last. Models read top-down and weight earlier content more heavily, so the role frames everything that follows. Constraints sit at the bottom so the model treats them as final guardrails rather than as optional context.
Should constraints be positive or negative statements?
Prefer positive "always do X" constraints over negative "never do Y" when possible — models follow concrete instructions more reliably than prohibitions. Reserve negative constraints for hard safety rules like never share secrets, never claim certainty without evidence.
Continue learning
Now that you understand prompt anatomy, dive deeper into each building block. Learn how to craft effective personas and roles for the Identity section, or explore instruction structuring and chaining techniques for building robust Instructions. If you missed the basics, start with our introduction to system prompts.
Quick summary
- Identity shapes the AI's perspective and expertise
- Instructions define behavior, format, and style
- Constraints set boundaries and safety guardrails
- Every strong system prompt has all three — and they work together
- Next: learn how to write each part effectively