A field guide to the potholes every serious builder hits — and the fixes that work.
Anti-PatternsDebuggingReliability
A Handbook For Builders
Pitfalls, Anti-Patterns & How to Avoid Them
Chapter 09
The Claude Code Handbook
Prologue
Every builder hits the same holes.
Reading this list will not stop you from hitting these traps — but it will stop you from spending three days lost inside each one. Bookmark this chapter and re-read whenever a project starts to feel gnarly.
Pitfall
Vague prompts
Symptom: model keeps missing your intent. Fix: use the CRISP checklist (Context, Role, Intent, Structure, Proof).
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Vague prompts".
Figure — Before / after screenshot demonstrating the fix for "Vague prompts".
Pitfall
Missing context
Symptom: model invents APIs or file names. Fix: paste the actual file, or open it via a tool call.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Missing context".
Figure — Before / after screenshot demonstrating the fix for "Missing context".
Pitfall
Blind trust in output
Symptom: shipped code has silent bugs. Fix: always run tests and diffs before merging.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Blind trust in output".
Figure — Before / after screenshot demonstrating the fix for "Blind trust in output".
Pitfall
Uncapped loops
Symptom: bill spikes overnight. Fix: max_steps, max_tokens, and daily spend alerts.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Uncapped loops".
Figure — Before / after screenshot demonstrating the fix for "Uncapped loops".
Pitfall
Losing state between turns
Symptom: agent forgets what it just did. Fix: persist state to a file or DB every step.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Losing state between turns".
Figure — Before / after screenshot demonstrating the fix for "Losing state between turns".
Pitfall
Over-engineering
Symptom: 4 agents when 1 would do. Fix: start with a single loop, split roles only when needed.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Over-engineering".
Figure — Before / after screenshot demonstrating the fix for "Over-engineering".
Pitfall
Leaking API keys
Symptom: bill spikes from unknown IPs. Fix: rotate keys, use secret managers, add .env to .gitignore.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Leaking API keys".
Figure — Before / after screenshot demonstrating the fix for "Leaking API keys".
Pitfall
Ignoring cost
Symptom: unit economics break. Fix: track cost per request, cache aggressively, route by task difficulty.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Ignoring cost".
Figure — Before / after screenshot demonstrating the fix for "Ignoring cost".
Pitfall
Hallucinations
Symptom: confident but wrong. Fix: RAG with citations, temperature=0, verifier pass.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Hallucinations".
Figure — Before / after screenshot demonstrating the fix for "Hallucinations".
Pitfall
Prompt injection
Symptom: agent follows instructions found in fetched web pages. Fix: label untrusted text, refuse contradictory system-level instructions.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Prompt injection".
Figure — Before / after screenshot demonstrating the fix for "Prompt injection".
Pitfall
Brittle scrapers
Symptom: workflow breaks weekly. Fix: use Firecrawl or a hosted API, add tests, alert on empty results.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Brittle scrapers".
Figure — Before / after screenshot demonstrating the fix for "Brittle scrapers".
Pitfall
No evals
Symptom: regressions after every change. Fix: 20-task dataset + nightly run + pass rate dashboard.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "No evals".
Figure — Before / after screenshot demonstrating the fix for "No evals".
Pitfall
No logging
Symptom: cannot debug production incidents. Fix: log prompt/response/tokens/latency for every AI call.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "No logging".
Figure — Before / after screenshot demonstrating the fix for "No logging".
Pitfall
Prompt monoliths
Symptom: one 5,000-word system prompt no one understands. Fix: split into role, rules, tools, examples — each in its own file.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Prompt monoliths".
Figure — Before / after screenshot demonstrating the fix for "Prompt monoliths".
Pitfall
Poor UX for AI errors
Symptom: user sees stack traces. Fix: friendly retries, human handoff button, offline fallbacks.
Claude Code — Terminal
Screenshot placeholder
Before / after screenshot demonstrating the fix for "Poor UX for AI errors".
Figure — Before / after screenshot demonstrating the fix for "Poor UX for AI errors".