Starbase / 01 PlainAgent

PlainAgent / How to write an agent system prompt

Guide · Prompts

How to write an agent system prompt

Write it as a short job description in six parts: role, job, inputs, rules, output format and handoff. Then accept its limits: in an agent, tool descriptions, an output parser and approval steps do more for reliability than any extra sentence in the prompt.

The six parts

  1. Role: who it is and who it serves. One line.
  2. Job: the single task, and what "done" means.
  3. Inputs: what it receives each time and where knowledge comes from.
  4. Rules: what it must and must never do. Concrete, testable statements.
  5. Output format: length, tone, or exact JSON fields if another step reads it.
  6. Handoff: exactly when to stop and involve a person, and what to pass along.

Template

You are {ROLE} for {ORGANISATION}. You serve {USERS}.

Job: {ONE SENTENCE}. You are done when {DONE CONDITION}.

Inputs: each time you receive {INPUTS}. Use only {KNOWLEDGE SOURCE} for facts.

Rules:
- {MUST}
- Never {MUST NOT}
- If information is missing, say so instead of guessing.

Output: {FORMAT}

Handoff: stop and hand off to a person when {CONDITIONS}. Include a two-line summary.

Where it goes in n8n, and what it can't fix

  • It isn't the main text box. In n8n's AI Agent node, the Prompt (User Message) field carries each run's input. The system prompt goes under Options, System Message (n8n docs).
  • Tools are picked by their descriptions. When a builder asked on the n8n forum how to get an AI Agent to follow its system prompt, because it skipped tools it was told to call, the suggested fixes were distinct tool descriptions that say exactly when to use each one (“Use this tool ALWAYS when [Scenario X] occurs.”), two or three examples of correct tool use, and evaluations. Write each tool's description as carefully as the prompt.
  • Format is enforced by a parser, not by prose. Turn on Require Specific Output Format and connect a Structured Output Parser. In our study of 13,574 public n8n templates, 1,638 of 4,247 agent templates (38.6%) do; the rest ask for JSON in the prompt and hope.
  • Approval is a setting, not a sentence. "Never send without approval" in a prompt is a request. n8n's human review for tool calls pauses the workflow until someone approves the gated tool.
  • Loops cost money. Max Iterations defaults to 10: the number of times the model may run to try to produce an answer. Lower it while you test.

Test it like code

Keep 10 to 20 real inputs with the answer you expect, and re-run all of them after every prompt change. n8n has built-in evaluations for this: run a test dataset through the workflow and compare the outputs, by eye at first and with metrics later. Almost nobody ships them: 17 of the 4,247 public agent templates (0.4%) include an Evaluation node.

Common mistakes

  • Vague rules ("be helpful") that can't be tested.
  • No permission to say "I don't know", so it guesses.
  • Free-text output when the next step needs structured fields.
  • Stuffing every edge case into the prompt instead of fixing the knowledge.
  • Changing the prompt without re-running your test examples.

Generate a filled-in version with the agent planner.

Sponsor slot · availableFeature your product here
Newsletter

One agent template a week

A short Friday email: one agent spec, the system prompt, and what to test before you switch it on. Free, and the unsubscribe link is in every email.