Prompt engineering

How to write a system prompt for your bot — step by step

/p

Illustration: a short rulebook the bot keeps in view

Plenty of people write a system prompt like a friendly greeting: "You are a helpful assistant, help the user." Then they wonder why the bot is vague and does the wrong thing. Here's the crux: a system prompt isn't an intro — it's your bot's constitution. It re-reads it before every message you send. So you should write it not like a greeting, but like a working instruction. Let's build one in five steps.

Step 1. Give it a role and one job

Start with who the bot is and what its job is. Not "an assistant in general," but a specific role with a narrow area of responsibility.

You are the support assistant for the "Zerno" coffee shop.
Your job: answer questions about the menu, hours, and delivery.

One clear role narrows behavior far more than a page of general wishes.

Step 2. Spell out rules and boundaries

Say what the bot must not do, and what to do when it doesn't know the answer. Boundaries are what separate a toy from a working tool.

Rules:
- Only answer about the "Zerno" coffee shop. Politely steer off-topic questions back.
- Don't invent prices or dishes. Not in the menu below — say you don't know and suggest asking a barista.
- Keep it short: 1–3 sentences.

Step 3. Set the tone and format

Describe how to answer: tone, length, language, structure. "Friendly" is too vague; give a reference point.

Tone: warm and plain, casual, no bureaucratic language.
Format: menu questions — a short bulleted list. Otherwise — plain text.

Step 4. Show an example (this switches on the magic)

One good "question → answer" example teaches the model better than a paragraph of description. This is the few-shot trick: show, don't tell.

Example.
Question: "What time do you open on Saturday?"
Answer: "On Saturday we're open 9:00–21:00. See you!"

Drop in 1–2 examples — especially for the questions where the bot used to flounder.

Step 5. Feed it data and test

The bot doesn't know your menu and hours until you give them. Add the current facts right into the prompt (or pull them from a database):

Menu and hours:
- Hours: Mon–Fri 8:00–22:00, Sat–Sun 9:00–21:00.
- Delivery: citywide, from 30 minutes, free over 1500 ₽.

Now test with mean questions: ask about something not in the data, ask off-topic, throw in rudeness. Watch whether the bot holds the boundaries from step 2. If it doesn't, strengthen the rule and repeat.

What you'll get

Put the five blocks together and you get not "a friendly assistant in general," but a specific employee with a role, boundaries, tone, an example, and facts. The practical difference is huge:

Weak promptYou are a friendly assistant, help the coffee shop's users.
Strong prompt

From there it's the usual work on wording, same as any good prompt: the more specific it is, the more predictable the answer.

How is a system prompt different from a regular one?

A regular prompt is a single user message. A system prompt the bot reads before every message: it's the standing rules of the game, not a one-off request.

Why does the bot still break my rules?

A common cause: the rule is too soft or buried in the middle of a long text. Word it more firmly and move the important part up front. More on that in the breakdown of why the model ignores instructions.

How long should a system prompt be?

Just long enough to cover role, boundaries, tone, example, and data — and not a paragraph more. Extra text dilutes the main point and eats up context.

Learn vibe coding — don’t just read about it

Short story-lessons, an agent simulator and daily practice — in our mobile app. Free.

Open the app
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →