System Prompt Design: The Five-Block Structure I Use Every Time
The system prompt defines how an LLM application behaves. Here is the five-block structure I use for consistent output. The system prompt is the most important prompt in an LLM application, and it is usually the one written with the least care. It defines the model role, the task boundaries, the response format, the refusal behavior, and the rules the model should follow when user input is ambiguous. A weak system prompt produces inconsistent output that drifts across conversations. A strong system prompt produces consistent behavior that survives edge cases. After writing system prompts for chatbots, agents, and pipeline stages, I have a structure I follow every time. This guide covers that structure. The Five Blocks of a System Prompt Every system prompt I write has five blocks, in a fixed order. The order matters because the model weights earlier instructions more heavily, and role and task need to be established before rules and format. The blocks are role, task, rules, format, and examples. Not every prompt needs all five at full length, but every prompt touches each block. Role defines who the model is and what it knows. Task defines what the model should do for the user. Rules define what the model must and must not do. Format defines the shape of the response. Examples show the desired behavior concretely.