System Prompt
A high-priority instruction layer set by the developer to define an LLM's persona, behavioral rules, formatting constraints, and safety boundaries before user input
Table of Contents
Structure Diagram
What is System Prompt?
A high-priority instruction layer set by the developer to define an LLM's persona, behavioral rules, formatting constraints, and safety boundaries before user input. It is a core concept in LLM Fundamentals within AI / ML.
Core Principles
A System Prompt (or Developer Message) sits at the top of an LLM conversation to establish the model's role, operating rules, tool usage guidelines, and output schema before any user message is processed.
Modern models are trained with an Instruction Hierarchy, granting system instructions higher authority than user messages or retrieved third-party text to help resist prompt injection attacks.
Practical Takeaways
- Keep the prefix static for Prompt Caching: Avoid injecting per-request timestamps or dynamic user IDs at the very top of the system prompt so providers can cache the prefix KV state.
- Structure rules with clear delimiters: Organize instructions into clean sections (
Role,Constraints,Output Format) and pair negative constraints with explicit fallback actions. - Version-control prompts like code: Track system prompt revisions in Git and run regression evals before deploying edits to production.
Notable Examples
- AI Coding Agents: Encode repository conventions, tool safety rules, and verification steps in the system prompt.
- Enterprise Support Bots: Lock brand tone, compliance disclaimers, and escalation triggers in the system layer.
- Localization Pipelines: Inject glossaries and formality guidelines into the system prompt for consistent translations.