05 section
Prompting and Context
Getting reliable behavior out of a model you cannot retrain — instruction design, example selection, reasoning elicitation, context budgeting, schema-constrained output, automatic optimization, injection defense
What is in here
The first four pages build up reasoning technique, from plain instructions to branching search. Context engineering and structured generation are where prompting stops being craft and becomes system design; DSPy answers the question of who maintains all these prompts once there are two hundred. Read the injection page if any untrusted text ever reaches your model.
01
3 min
Prompt Engineering Fundamentals
Prompts as code: instruction hierarchy, delimiters, role framing, and the intent-versus-constraint balance that decides how much a model's output varies run to run
promptingfundamentals
02
3 min
Few-Shot and In-Context Learning
How many examples to show, how to pick them dynamically per query, and why the hard edge cases teach more than the clean ones
promptingcontextretrieval
03
3 min
Chain-of-Thought
Reasoning traces moved from a prompt trick to a model feature; when to elicit them, how to verify them, and when overthinking hurts accuracy
promptingreasoning
04
3 min
Tree-of-Thought
Branching search over reasoning paths — propose, evaluate, backtrack — and where MCTS-style exploration earns its large latency and token bill over a linear chain
reasoningplanningprompting
05
5 min
Context Engineering
With million-token windows the question is no longer what fits but what earns its place: budgeting, lost-in-the-middle, thinking budgets, and cache-friendly prompt layout
contextcachingcost
06
3 min
Structured Generation
Getting machine-readable output every time — JSON schema modes, constrained decoding with grammars and regex, multi-stage extraction, and what to do when validation still fails
structured-outputpromptingtool-use
07
3 min
Prompt Optimization with DSPy
DSPy treats prompts as weights an optimizer tunes: signatures, modules, teleprompters, and the metric you must define before any of it works
promptingevaluationproduction
08
3 min
Prompt Injection Defense
Direct and indirect injection, why input sanitizing alone never holds, and the architectural defenses: dual-LLM isolation, tagged untrusted spans, and output filtering
securitypromptingreliability