Chapter 5. Case Study: How to Build a Great System Prompt
When designing an AI application, the system prompt is the first piece of context you control. It sets the baseline instructions that are present in every call to the model, preceding every skill, file, tool result, and user input.
System prompts are artifacts you can study. Model weights are frustratingly opaque, but system prompts can be extracted, studied, and compared. They reveal what an application needs the model to know, the behaviors its product team desires, and the model tendencies the team is trying to correct. Simon Willison notes that system prompts “double as better written documentation than any of the official sources.”
To understand their range, we compared system prompts from six coding agents (Figure 5-1): Claude Code, Codex CLI, Cursor CLI, Gemini CLI, OpenCode, and Pi. Each application essentially performs the same function: given a task, gather information, understand the codebase, write code, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access