Skip to main content

Which Pattern When?

The AI section covers many patterns. In production you combine them -- rarely "just an LLM" or "just RAG." This page is a capstone decision guide: where to start, what to add next, and what to skip. It assumes you have skimmed Large Language Models and points to deep dives rather than repeating them.

If you want to…

GoalStart hereUsually addOften skip (at first)
Answer questions over your docsRAGEmbeddings, structured outputs for citations/metadataAgents until retrieval works
Build a support or internal Q&A botRAG + AI in ProductsEvaluation & LLMOps, privacyMulti-agent systems
Automate multi-step work (search, act, repeat)AgentsMCP tools, human-in-the-loopPure chat without tools
Use AI inside your dev workflowAI-Assisted DevelopmentProject memory & rules, Agent SkillsCustom fine-tuning
Ship a feature users see in your productAI in ProductsStructured outputs, cost & latencyAutonomous agents without approval
Keep sensitive data on-premCloud vs LocalLocal LLM app, privacySending full corpus to frontier APIs
Control spend at scaleCost, Latency & Model RoutingContext engineering, evalsFrontier model for every request
Make outputs machine-parseableStructured OutputsValidation/repair loops, eval scorersFree-form prose to regex later
Operate safely in productionSafety + Privacy & DataHuman-in-the-loop, red-teaming via evalsGuardrails as the only layer
Debug wrong or broken behaviorDebugging LLM AppsTraces from LLMOpsRewriting the whole prompt blindly

Core decision: what kind of problem is it?

Knowledge problem -- model does not know your facts → RAG, knowledge management patterns, or tools that fetch live data.

Action problem -- model must do things, not just text → Agents with narrow tools and HITL on destructive steps.

Format problem -- downstream code needs JSON/fields → Structured outputs, not "please return JSON."

Process problem -- team repeats the same agent ritual → Skills or project memory, not a longer system prompt every time.

RAG vs agent vs chat

PatternShapeChoose whenWatch out for
ChatSingle model call per turnTransformation, drafting, classification with small contextStale knowledge, no actions
RAGRetrieve → generateLarge doc corpus, FAQ, grounding requirementsBad chunks, injection via retrieved text
AgentModel + tools in a loopDynamic plans, APIs, code execution, multi-step researchCost, latency, runaway loops, tool sprawl
WorkflowFixed steps (your code controls)Known pipeline, compliance, predictable costLess flexible than agents

Hybrid is normal: RAG inside an agent (retrieve then act), or router that picks chat vs RAG vs agent per request (cost & latency).

Adaptation ladder (cheapest first)

From LLMs -- try in order; stop when quality is good enough:

  1. Prompt / context -- instructions, examples, context engineering
  2. RAG -- fresh, private knowledge at inference
  3. Project memory / rules / skills -- repeatable team conventions and workflows
  4. Fine-tuning / LoRA -- domain style or format the model resists via prompting (see RAG vs fine-tuning)
  5. Pre-training -- almost never

For coding agents, (3) often beats (4).

Configuration stack for coding agents

NeedUse
Repo orientation, build commandsAGENTS.md / project memory
File-type conventionsCursor rules
Multi-step rituals (release, review)Agent skills
External systems (Jira, DB)MCP servers

Do not duplicate the same checklist in memory, rules, and skills -- one source of truth per concern.

Production checklist (any pattern)

Before launch, you should have answers for:

Common anti-patterns

  • Agent first -- jumping to agents before retrieval and prompts work
  • Frontier everywhere -- no routing; invoice surprises (Cost & Latency)
  • Guardrails only -- no HITL on money/deletes/publish (Human-in-the-Loop)
  • Eval never -- shipping on vibes (Evaluation & LLMOps)
  • Giant system prompt -- everything in one blob instead of skills, RAG, and tools (Context Engineering)

Suggested reading order

New to LLMs: LLMContext Engineering → this page → your goal row in the table above.

Building a product feature: AI in ProductsStructured OutputsRAG or AgentsEval & LLMOps.

Using AI as an engineer: AI-Assisted DevelopmentProject Memory & RulesAgent Skills.

Operating in production: Evaluation & LLMOpsDebugging LLM AppsCost & Latency.

See also