01Chapter 1: What a system prompt is and how roles workA system prompt is the block of instructions your application sends to a language model before any user input. It defines the model's job, limits, and output format for a whole conversation. This chapter explains how the system prompt fits into the message list the model receives, what each role mea7 min read
02Chapter 2: State the task, role, and audienceThis chapter covers the opening block of a system prompt: what the model must do, who it acts as, and who reads its output. It assumes you have called an LLM chat API, know that system and user messages are different roles, and can read basic Python. The earlier chapter on message roles explains whe7 min read
03Chapter 3: Organize the prompt with sections and delimitersThis chapter assumes you have called an LLM chat API, can read JSON, and can read basic Python. It covers how to lay out a system prompt so the model can tell instructions, reference material, and user input apart. Later chapters build on this layout when they cover rules, output formats, and untrus7 min read
04Chapter 4: Write constraints that the model can followThis chapter assumes you have already written a basic system prompt with a task and role, and that you can read short Python functions. A constraint is a rule in your prompt that limits what the model may do or how it must do it. Examples are "do not give tax advice", "answer in under 100 words", an6 min read
05Chapter 5: Specify the output formatThis chapter assumes you have called an LLM chat API, can read JSON, and can read basic Python. It builds on the system prompt you wrote in earlier chapters, which already has a role, a task, and rules. Here you add the last piece of that structure: a precise description of what the reply must look 8 min read
06Chapter 6: Teach by exampleThis chapter covers few-shot examples: sample input and output pairs placed in a prompt to show the model the behavior you want. It assumes you can call a chat API, read JSON, and read basic Python. It also assumes you have read the earlier chapters on rules and output format, because examples work 7 min read
07Chapter 7: Add dynamic and retrieved contextA system prompt is fixed text, but most apps also need request-specific data. That data includes retrieved documents, the user's account details, the current date, and earlier conversation facts. This chapter covers how to insert that data so the model uses it correctly and treats it as data. It ass6 min read
08Chapter 8: Handle untrusted input and prompt injectionThis chapter assumes you have read the earlier chapters on message roles, delimiters, and output formats. It also assumes you can read basic Python and JSON. You should know that a system prompt holds your fixed instructions and that user messages carry per-request content.6 min read
09Chapter 9: Instruct the model on tool useThis chapter assumes you have called a chat API with tool (function) calling at least once. It also assumes you can read JSON Schema and short Python functions. It builds on the earlier chapters on constraints and output format. Here you decide what the model may do, when it should do it, and what t6 min read
10Chapter 10: Guide reasoning and handle uncertaintyThis chapter assumes you can call a chat API, read basic Python, and work with JSON. It also assumes you have read the chapters on writing constraints and specifying output format. Here you decide how much the model should reason before it answers, and what it should do when it cannot answer with co6 min read
11Chapter 11: Test prompts with a small evaluation setA prompt change that looks better on one example can quietly break five others. This chapter shows how to build a small evaluation set (an "eval set") so you can compare prompt versions with evidence instead of impressions.5 min read
12Chapter 12: Diagnose and fix common failuresThis chapter assumes you have read the earlier chapters on roles, constraints, output formats and evaluation. You should have a system prompt and a small test set, and you should be able to read short Python. It covers what to do when a test fails: how to find the cause, how to choose a fix, and how6 min read
13Chapter 13: Version and maintain prompts over timeA system prompt is part of your application's behavior, so it needs the same care as code. This chapter covers how to store, identify, change, release, and retire prompt versions. It assumes you have read the earlier chapters on writing prompts and building a small evaluation set. You should be comf7 min read