New Tool Radar

AI Concepts

How to Write a System Prompt with a Role, a Task and Rules

Write a system prompt with a role, a task and rules so the model knows who it is, what to do and what not to do.

Schematic illustration of write a system prompt with a role, a task and rules: step one name the role, step two state the task, step three list the rules.

A system prompt sets the model’s behaviour for the whole conversation: who it is, what its task is, and the rules it must follow. Three parts cover most needs: a role, a task and rules. A prompt with a role but no task wanders; a task with no rules invents its own limits. Write all three, keep them short, and put the rules last so they are the final instruction the model reads.

Prerequisites

  • The role the model should take, in a few words.
  • The task, in one sentence.
  • The rules, as a short list of things to do and not to do.

Steps

Step 1: Name the role

Name the role in one line: ‘You are a helpful assistant for a bakery.’ The role sets the tone and the knowledge the model should draw on.

Step 2: State the task

State the task in one sentence: ‘Answer customer questions about our breads from the product list.’ One task per prompt is enough; two tasks in one prompt fight each other.

Step 3: List the rules

List the rules as short lines: answer only from the product list; if the answer is not in the list, say so; keep answers under 50 words. Rules should be checkable, so you can tell whether the model followed them.

Worked example: Maple Corner bakery assistant

The fictional Maple Corner bakery writes a system prompt for its customer assistant.

Part Text Checked
Role You are a helpful assistant for Maple Corner bakery. Yes
Task Answer customer questions about our breads from the product list. Yes
Rule 1 Answer only from the product list. Checkable
Rule 2 If the answer is not in the list, say so. Checkable
Rule 3 Keep answers under 50 words. Checkable

The prompt has a role, a task and 3 checkable rules, so the model’s behaviour is set in 5 short lines.

Expected result. The system prompt has a role, one task and checkable rules, and it fits in a few lines. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • A system prompt cannot force a model to know facts it was not given; attach the product list as context.
  • Long system prompts cost tokens on every request; cache them, as the caching guides show.
  • This guide does not cover few-shot examples, which are a separate technique.

Sources

See all