Loading
Loading
A System Prompt is a set of hidden instructions sent to the model before any user conversation begins. The user never sees them, but they define the model's identity, behavior, and constraints for the entire session.
Think of it as "stage directions" an actor memorizes before performing ā the audience never sees them, but they shape everything the actor says and does.
| | System Prompt | User Message |
|--|--------------|--------------|
| Who sees it? | The model only | Both user and model |
| When sent? | Before conversation starts | With each new message |
| Purpose | Define identity, rules, context | Ask a question or make a request |
| Changes in session? | Fixed throughout the session | Changes with each turn |
| In the API | system field | messages field |
A good System Prompt has four essential elements:
1. Identity and Role (Persona) Who is the model in this session?
You are a medical assistant for a family medicine clinic in Riyadh.
2. Rules and Constraints What should it do and what is forbidden?
Never diagnose illnesses. Always refer to a qualified doctor.
Never mention medications by brand name.
3. Format and Style How should responses be structured?
Use numbered steps for instructions. Use professional English.
Keep each response under 150 words.
4. Reference Context What fixed information does the model need?
Clinic hours: 8 AM - 8 PM.
Specialties: Family medicine, pediatrics, dermatology.
Appointments: Call 920-XXX-XXX.
Level 1 ā No System Prompt: User asks: "How do I restart my device?" Model gives a generic, unhelpful answer because it has no context.
Level 2 ā Simple System Prompt:
You are a technical assistant.
Slightly better, but still vague.
Level 3 ā Complete System Prompt:
You are "Darhous Support," the technical assistant for Darhous Tech.
Our products: Dell computers, HP printers, Samsung monitors.
Rules:
- Respond in the language the customer uses
- If you don't know, refer to support@darhous.com
- Never mention competitor brands by name
Format:
- Numbered steps for procedures
- Short sentences for explanations
- Maximum 200 words per response
Result: Accurate, consistent responses in every conversation.
ā Building a custom chatbot or assistant ā API calls in a software application ā Establishing a consistent style for a recurring task ā Always fixing the output language or format ā Protecting the app from out-of-scope uses
ā Regular conversation in claude.ai ā just include instructions in your message ā One-time tasks ā system prompts are for repeated, consistent sessions
Be specific, not general:
ā Be helpful and friendly
ā
Respond in two sentences maximum. Always begin by acknowledging the problem
State constraints explicitly:
ā
Never discuss politics or religion under any circumstances
ā
Never provide medical information beyond advising the user to see a doctor
Add examples of desired behavior:
If customer asks about price: "Product X costs $Y including tax"
If you don't know: "This question needs a specialist ā I'll connect you with support"
Always test edge cases: After writing a System Prompt, test with difficult or out-of-scope questions to verify model behavior before deployment.
Keep it reasonably concise: A System Prompt longer than ~2000 tokens may dilute the model's attention to the rules. Focus on what's essential.
import anthropic
client = anthropic.Anthropic(api_key="your-api-key")
# The System Prompt defines identity, rules, format, and context
SYSTEM_PROMPT = """
You are "Darhous Support," the technical assistant for Darhous Tech.
Our products: Dell computers, HP printers, Samsung monitors.
Rules:
- Respond in the language the customer uses
- If you don't know the answer, refer to support@darhous.com
- Never mention competitor brands by name
Format: numbered steps for procedures, short sentences for explanations.
"""
def ask(question: str) -> str:
response = client.messages.create(
model="claude-opus-4-5",
max_tokens=500,
system=SYSTEM_PROMPT, # <-- System Prompt goes here
messages=[
{"role": "user", "content": question} # <-- User message here
]
)
return response.content[0].text
# The system prompt shapes ALL these responses consistently
print(ask("How do I restart my Dell laptop?"))
print(ask("My HP printer is offline, what do I do?"))
print(ask("ŁŁŁ Ų£ŁŲ¹ŁŲÆ Ų¶ŲØŲ· Ų·Ų§ŲØŲ¹ŲŖŁ Ų„ŁŁ Ų„Ų¹ŲÆŲ§ŲÆŲ§ŲŖ Ų§ŁŁ
ŲµŁŲ¹Ų"))