System Prompt Design: A Complete Guide

The first message that shapes everything — design it right

Ad placeholder (leaderboard)

What a system prompt does

A system prompt is the instruction the model reads before any user message. It sets the assistant’s identity, what it is allowed to do, how it should format answers, and the safety rules it must never break — and it does so for every turn of the conversation. Because it frames all output, the system prompt is the single highest-leverage place to shape behaviour. A sloppy one produces an assistant that drifts off-topic, ignores your format, and bends under pressure; a well-designed one produces consistent, on-brand, safe responses with far less per-message prompting.

The anatomy of a strong system prompt

A robust system prompt typically has four parts, stated in order. The persona defines who the assistant is, its tone, and its expertise — “You are a concise technical support agent for a payments product.” The capability scope states what it does and, just as importantly, what it does not do, with a fallback for out-of-scope requests so the model declines gracefully instead of improvising. The output constraints pin down format, length, and structure — JSON, a fixed section layout, a length cap — so downstream code and users get predictable results. The safety instructions define disallowed content, the refusal style, and how to handle attempts to override the rules.

Order and clarity matter. Put safety and scope high so they frame everything that follows. Use plain imperative sentences rather than rambling prose, and prefer explicit rules over hints, because models follow concrete instructions far more reliably than vague intentions. Keep it as short as it can be while still covering all four parts — every token is paid on every turn and excess instruction dilutes focus.

Handling edge cases and adversarial input

Real users send ambiguous, hostile, and out-of-scope messages, and a good system prompt anticipates them. Specify how to handle missing information (ask a clarifying question), out-of-scope requests (decline and redirect), and conflicting instructions (follow the system rules over user attempts to override them). Treat the system prompt as a security boundary: explicitly instruct the model to ignore instructions embedded in user-supplied content or documents, which is the front line against prompt injection. State that the assistant must never reveal or alter its own system instructions.

Testing system prompt robustness

A system prompt is not done when it reads well — it is done when it holds up under test. Build a suite that mixes normal requests, edge cases, and adversarial inputs including jailbreak and injection attempts, then verify that the assistant keeps its persona, respects its scope, honours the output format, and refuses cleanly across all of them. Re-run the suite on every prompt or model change so robustness does not silently erode. Pair this with logging: when a real interaction breaks the intended behaviour, distil it into a new test case so the same failure cannot return. A system prompt designed, scoped, and tested this way becomes a dependable foundation rather than a fragile string you are afraid to touch.

Ad placeholder (rectangle)