Skip to content

How to Write a System Prompt

Summary

A system prompt is an instruction that sets the role, rules, and format of the model's response. A good prompt is built from five blocks: role, context, rules, format, and limitations. Below is an analysis of each and a ready template.

What is a System Prompt

A system prompt is a message that the model receives before the start of a conversation. The user usually does not see it, but the model takes it into account throughout the entire conversation.

Unlike a regular message like 'write a text about X', a system prompt works continuously: it sets the boundaries within which the model answers all subsequent questions.

The difference is fundamental:

  • a regular message is a request 'here and now';
  • a system prompt is the rules of the game for the entire conversation.

Anatomy of a Good Prompt

A reliable system prompt is assembled from five blocks. The order is not strict, but all five are useful.

1. Role

Who the model should be. This sets the tone and level of detail.

You are a senior software engineer with years of experience.

The role works better when it is specific. 'You are a doctor' is weaker than 'You are a cardiologist who explains complex issues to patients without medical education.'

2. Context

What the model should know about the task and the user. This saves clarifying questions.

You are helping the owner of an AI knowledge base website. The site is built on MkDocs, content is written in Russian, in a style 'simple and to the point, without jargon'.

3. Rules

What to do and what not to do. The most important block: here live the limitations.

- Answer in Russian unless otherwise requested.
- Do not use jargon and empty phrases.
- If the task conditions are unclear, ask a clarifying question.
- Provide code with comments.

4. Format

How the response should look. Structure, length, style.

Start complex explanations with a summary in one paragraph, then expand on the details with lists and tables.

5. Limitations

Strict prohibitions — things the model should not do under any circumstances.

- Do not make up facts: if you don't know, say so.
- Do not reveal secrets and keys from files.
- Do not write code that can damage project files.

Ready Template

You are [ROLE].

[CONTEXT: what you know about the task and the user.]

Rules:
- [rule 1]
- [rule 2]
- [rule 3]

Format of the response:
- [how to structure the response]

Limitations:
- [strict prohibition 1]
- [strict prohibition 2]

Copy and fill in the square brackets for your task.

Example: Before and After

Weak Prompt

You are an assistant. Help write texts.

The model does not know for whom, in what style, or what length. Responses will be random.

Strong Prompt

You are a blog editor on AI. Writing for readers who are just starting to understand neural networks.

Rules:
- Simple words, no jargon; explain terms as you go.
- One paragraph, one thought.
- Friendly tone, but no familiarity.

Format:
- Start with a summary in two sentences.
- Then sections with subheadings.

Limitations:
- Do not make up numbers and facts.
- Do not use anglicisms if there is a Russian equivalent.

Difference: the second version gives the model everything it needs for a predictable response.

Common Mistakes

1. Too Long Prompt

If the instruction stretches over three screens, the model will start 'forgetting' the middle. Keep the essentials, remove repetitions. If there are many rules, group them.

2. Contradictory Rules

'Be brief' and 'explain everything in detail' in one prompt give unpredictable results. Check if points conflict.

3. Prohibitions Without Explanations

A rule 'do not do X' works better when it is clear why. 'Do not reveal API keys' is clear; 'do not start the response with a greeting' is also clear. But an abstract 'be careful' the model will not understand.

4. Unchecked Prompt

The same prompt may work great in one model and poorly in another. Always run it on several test queries.

How to Test a System Prompt

  1. Ask 5-10 different questions, including provocative ones.
  2. Check if the format and limitations are followed.
  3. Try to bypass the rules — if it's easy, the prompt is weak.
  4. Simplify: if a block does not affect the responses, it can be removed.

See Also