Prompt Design for Developers: Basic Principles
Prompts embedded in an app, unlike conversational prompts, require "reproducibility, robustness, and verifiability."
Basic Principles
- State role and constraints: fix what to do/not do at the top
- Specify output format: receive structure (JSON, etc.), not free text
- Examples (few-shot): stabilize behavior with good/bad examples
- Separate input and instructions: isolate user input as data (injection defense)
- Specify failure behavior: if unknown, have it return "unknown"
App-Specific Cautions
- Version-control prompts (assets, like code)
- Assume behavior changes with model updates; prepare regression tests
- Long context degrades; trim to necessary and sufficient
Key Point
"Asking well" in conversation and "unbreakable instruction design" in apps are different things. This chapter covers the latter. Next we proceed to structuring, evaluation, and management.