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
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
