How to write a good agent rulebook (system prompt)

An AI agent is only as good as its instructions. A practical guide to writing an agent's rulebook — role, boundaries, tools, escalation, and voice — that holds up in production.

The Spikefrost Team12 Jun 20262 min read

An AI agent is its instructions plus its tools. The instructions — the rulebook, or system prompt — are where most of an agent's behavior comes from. Here's how to write one that holds up.

What goes in a rulebook

  • Role and goal. Who the agent is and the outcome it owns, in a sentence. "You are a support agent for ACME; you resolve customer issues and escalate what you can't."
  • Boundaries. What it must never do, stated plainly. Be specific: "never quote a price not in the catalog," "never promise a refund over the limit."
  • Escalation rules. Exactly when to hand off to a human, and what to include. (human-in-the-loop)
  • Tool guidance. When to use which tool, and how to behave when one fails.
  • Voice. Tone, length, formatting — how it should sound.

Lead with the non-negotiables

Models pay most attention to what's clear and early. Put the role and the hard rules first; bury nothing important in paragraph nine. If a rule matters, make it short and unmissable.

Don't rely on the prompt for safety

This is the key one. A rulebook shapes behavior, but it is not a security control. "Never delete production data" is a good instruction and a terrible safeguard — because a clever input can talk a model past it. Hard limits belong in the runtime: the agent simply isn't granted the dangerous tool. Use the prompt for judgment; use guardrails for safety.

Keep it short

Every extra paragraph dilutes the rules that matter and adds cost. Write it, then cut everything the runtime already enforces and everything the agent would do anyway. Shorter rulebooks are clearer rulebooks.

Iterate from real transcripts

The best edits come from watching the agent work. When it does something wrong, fix the rulebook and check whether the real fix is a runtime guardrail. Over time the rulebook converges on the few rules that actually shape good judgment.

See the enterprise AI agents guide for how rulebooks fit with tools, scoping, and audit.

Frequently asked questions

What should an AI agent's system prompt include?

Its role and goal, its boundaries (what it must not do), when to escalate to a human, how to use its tools, and its voice. Keep behavior rules in the prompt — but enforce hard limits with the runtime, not just words.

How long should an agent rulebook be?

As short as it can be while being unambiguous. Long prompts dilute the important rules. Lead with the role and the non-negotiables; cut anything the runtime already enforces.