Pattern library
18 patterns. Every entry documents: problem statement, naive approach + why it fails, correct mental model, step-by-step solution, code example, trade-offs, failure modes, when to use / not to use, and citations.
RAG — Retrieval-Augmented Generation
Ground your LLM in your own data. The single most-adopted pattern in production AI.
ReAct agent loop
Reason + Act + Observe. The pattern that turns an LLM into an agent.
Reflexion loop
Self-critique and retry. How agents recover from their own mistakes.
Tree-of-Thought
Explore multiple reasoning paths, prune, backtrack. When linear CoT isn't enough.
Hybrid search with Reciprocal Rank Fusion
Dense + sparse retrieval combined by RRF — the RAG upgrade that beats vanilla.
Query decomposition
Break a complex question into sub-questions before retrieval.
HyDE — Hypothetical Document Embedding
Ask the LLM to write the answer, then embed THAT and retrieve.
Prompt compression
Cut your tokens 50-80% without losing quality — LLMLingua and friends.
Prompt caching
Cache the invariant prefix of your prompt for 10x cost savings on repeat requests.
LLM as judge
Use one LLM to grade another's output — with the caveats.
Output parsing with retries
How to reliably get JSON out of an LLM.
Streaming + tool use
The UX pattern that makes agents feel fast.
Multi-agent orchestration
Orchestrator + workers, hierarchical, or market-based — when each wins.
Input & output guardrails
The defense-in-depth pattern for safe LLM apps.
Model routing
Route cheap queries to Haiku, hard queries to Opus — with the eval to prove it.
Batch inference
50% cost savings for non-real-time workloads.
Shadow-mode evaluation
Ship two models side-by-side, log both, compare in prod without user impact.
Prompt injection defense
Input filtering, output filtering, privilege separation, sandboxing — the layered defense.