Prompt Structure
Production prompts almost always follow the same skeleton: system message → context → instructions → examples → input → output format.
Introduction
Production prompts almost always follow the same skeleton: system message → context → instructions → examples → input → output format. Stick to a structure and your prompts become testable, version-controlled software components.
Beginner analogy: Think of a prompt like a well-organised email — subject line (system), background (context), ask (instruction), example (few-shot), attachment (input), expected reply format.
Understanding the topic
Core concepts to understand:
- System message — defines the assistant's role and rules.
- Context — relevant background info or retrieved documents.
- Instructions — the specific task to perform.
- Examples — input/output pairs (few-shot).
- User input — the actual data to process.
- Output format — JSON schema, markdown, length limits.
Syntax reference
Visual workflow / architecture:
┌─────────────── PROMPT STRUCTURE ───────────────┐│ [SYSTEM] You are a senior product analyst. ││ [CONTEXT] Company sells B2B SaaS in EMEA. ││ [TASK] Score this lead 1-10 and explain. ││ [EXAMPLES] Input → Output (×2 few-shot) ││ [INPUT] {{ lead_data }} ││ [FORMAT] {"score": int, "reason": string} │└────────────────────────────────────────────────┘
Real-world use
Anthropic's prompt library, OpenAI cookbook, and frameworks like LangChain, LlamaIndex and Vercel AI SDK all use this structure. Cursor and Claude.ai use highly structured system prompts under the hood.
Best practices
- Always have a clear SYSTEM section setting role and tone.
- Use delimiters (
###or XML tags) to separate sections. - Place the most important instruction last — recency bias helps.
Hands-on exercise
Interview preparation — practice these questions:
- Q1. Walk through the standard sections of a production prompt.
- Q2. Why use XML tags or delimiters in prompts?
- Q3. Where in the prompt should the user input go?