How it works

The system prompt is the first message in a conversation with an LLM. It sets the persona, tone, constraints and response format. Models like GPT and Claude treat this instruction with higher priority than user messages.

A good system prompt is clear, specific and includes format examples. Vague prompts lead to inconsistent responses. It is common to include safety rules, output format and knowledge limitations.

The system prompt can be long, thousands of tokens, in complex applications, including documentation, examples and business rules.

Practical example

Texto
Você é um assistente técnico. Responda em português do Brasil.
Use parágrafos curtos. Cite fontes quando possível.
Nunca invente dados. Se não souber, diga que não sabe.

In code:

Python
messages = [
    {"role": "system", "content": "Você é um assistente técnico..."},
    {"role": "user", "content": "O que é RAG?"}
]

What it's for

Control the model's behavior without retraining it. It is the main tool for adapting a generic LLM to a specific use case, such as support, code or data analysis.

Best practices: be specific, use examples, define limits and test with edge cases.