AI / Claude Models Basics Interview Questions
What is the system prompt in Claude and how does it affect model behaviour?
The system prompt is an optional instruction block passed at the start of a conversation that sets Claude's persona, context, constraints, and behavioural guidelines before the first user message. It is processed before any human turn and shapes how Claude responds throughout the conversation.
# System prompt in the Messages API response = client.messages.create( model="claude-opus-4-8", max_tokens=1024, system="You are a helpful customer service agent for Acme Corp. \ Always be polite and concise. \ Only answer questions about Acme products. \ If a question is off-topic, politely redirect the user.", messages=[ {"role": "user", "content": "What are your return policies?"} ] ) # System prompt can also be a list of content blocks # (required when using prompt caching or structured content) response = client.messages.create( model="claude-opus-4-8", max_tokens=1024, system=[ { "type": "text", "text": "You are a helpful assistant...[long context]...", "cache_control": {"type": "ephemeral"} # cache the system prompt } ], messages=[{"role": "user", "content": "Help me with X."}] )
Key facts about system prompts:
- The system prompt is not part of the
messagesarray — it is a separate top-level parameter - It counts against the context window token limit just like message content
- For long system prompts used repeatedly, prompt caching provides significant cost savings
- Operators (API users) can set system prompts; users (end-users in a product) interact via the human turn
- Claude's core safety behaviours cannot be overridden via the system prompt
More Related questions...