How to Structure a System Prompt
The Five Universal Sections (confidence: high)
Analysis of ~52 system prompts reveals five sections present in nearly every effective prompt. Missing any one creates a measurable behavioral gap.
1. Role & Identity (96% prevalence)
1-3 sentences defining persona, expertise scope, tone, and domain constraints. Be concrete. Overly long personas (>5 sentences) reduce compliance. Examples: “You are an expert software engineer” (Claude Code, Cursor) vs. “You are a world-class developer with years of experience” (Cline, Devin).
2. Tool Schema Definitions (92% prevalence)
Function signatures with parameter descriptions, constraints, return value formats, side-effect warnings, and usage examples. Most effective implementations use XML function blocks (Anthropic, Cline) or markdown API docs (Cursor, Windsurf).
3. Workflow & Operations (87% prevalence)
Step-by-step execution instructions. Choose from patterns: chain-of-thought before acting, task state machine, plan-before-implement gate, discussion-before-code default, or cascade pattern. Include gates (approval checkpoints) for non-trivial operations.
4. Guardrails & Safety (81% prevalence)
5-15 rules for autonomous agents, 0-3 for chat tools. Common rules: never overwrite existing files, anti-spill defense, security rules (no secrets in commits), full-file overwrite prohibition, content moderation, crisis detection.
5. Output & Communication (77% prevalence)
Response format, citation style, meta-instructions. Choose from: solution-only, explain-before-do, enumerate exhaustively, concise/minimal, technical/developer, user-friendly, or paired thinking+response.
Decision Points (confidence: high)
- Envelope format: XML for LLM compliance, markdown for human readability. See which-envelope-format-should-i-use.
- Pattern density: 2-5 for chat tools, 10-18 for autonomous agents. See the comparison.
- Architecture: Monolithic for early-stage or single-mode, multi-file for growing tools with role-switching.
- Communication style: Explain-before-do for complex tasks, solution-only for factual queries.
Example Skeleton (confidence: high)
[Envelope format — XML or Markdown]
## Role
You are [identity]. Your expertise is [scope].
## Tools
- [tool name]: [description], [parameters], [constraints]
## Workflow
1. [Step one]
2. [Step two — includes verification gate]
## Rules
- [Rule 1]
- [Rule 2]
## Output
[Style: explain-before-do / solution-only]
[Citation requirements if any]
Implications (confidence: high)
The five universal sections are a non-negotiable checklist. No amount of clever instruction engineering compensates for a missing section. Start with them, then layer on additional patterns (task state machine, skills directory, cooldown heuristics) as your tool’s autonomy requirements grow.
Links: xml-envelope-format, which-envelope-format-should-i-use, communication-style-spectrum, anti-prompt-injection, what-makes-an-agent-prompt-vs-chat-prompt
Sources
- [raw/prompts/articles/taxonomy-synthesis-2026-07-16.md]
- The prompt wiki
AGENTS.mddefines the schema for documenting structured prompts.