StudyVisuallyStart studying
Part 01 · LLM basics · Card 8 of 10

System prompt

Standing instructions that set the model's role, tone and rules for the whole conversation.

Last updated

Analogy

Middleware that runs on every request. Write it once at the top, and it quietly shapes every reply after.

Code example

system-prompt.tsTypeScript
const SYSTEM_PROMPT = [
"You are a dev-team assistant.",
"Use tools for live data. Never guess PR numbers.",
"Answer in under 80 words.",
].join("\n");
const messages = [{ role: "system", content: SYSTEM_PROMPT }];

In an agent

The system prompt is where an agent gets its job, its limits and its hints about when to use which tool.

Practice

Flashcards

  • What is a system prompt?Standing instructions that define the model's role, tone and rules.

Questions people ask

What should go in a system prompt for an agent?

Its job, its limits and its hints. Say what the agent is for, what it must never do, how long answers should be, and when to use which tool, for example: use tools for live data and never guess PR numbers. Keep it short and specific; every rule is resent on every call.

Is the system prompt a security boundary?

No. It shapes behaviour, but text the agent reads later, like a web page or an email, can try to override it. That is prompt injection. Real protection comes from code: validate tool arguments, give tools the least permission they need, and require human approval for risky actions.