Module 2: Mental Models for AI Code
Module 2: Mental Models for AI Code
Module 2: Mental Models for AI Code
Capsule overview
In the previous module you understood the problem: only 3% of developers highly trust AI code, and the solution isn't to accept everything or reject everything, but to develop calibrated trust. You finished with a basic verification framework — Red Zone, Yellow Zone, Green Zone. That framework tells you what to review. But it doesn't tell you how to think while you review.
This module gives you something more powerful than a checklist: mental models. A mental model is a thinking framework that lets you make good decisions in new situations — even in situations no checklist could anticipate. A developer with mental models can navigate any AI code scenario. A developer with only a checklist is limited to what that checklist covers.
You're going to learn 3 complementary mental models that, together, cover all the decisions you make when working with AI-generated code. Think of them as the "operating system" on which all the techniques you'll learn in the rest of the guide run.
Module context
Where are we?
You're in Module 2 of the "Debugging & Code Review with Claude Code" guide, within Phase 1: Understanding the Problem.
Phase 1: Understanding the Problem
├── Module 1: Only 3% Trust It ← completed
│ └── Awareness + basic verification framework
│ └── Capsules: statistic, extremes, calibrated trust, framework
├── Module 2: Mental Models ← you are here
│ └── Thinking frameworks for supervising AI code
│ └── Capsules: intro, MIT, Circuit Breaker, Trust Calibration, exercise
└── Module 3: Detecting Hallucinations → next
└── The most dangerous and subtle error in AI code
Module 1 gave you awareness and a first verification framework. This module raises your thinking: instead of following a list, you internalize mental models that guide all your decisions. Module 3 will apply these models to the most subtle and dangerous type of error: hallucinations — code that looks correct but isn't.
The transition: from framework to mental models
In module 1, your 3-zone framework tells you:
🔴 Red Zone: Always review (security, business logic, data)
🟡 Yellow Zone: Frequently review (edge cases, error handling)
🟢 Green Zone: Generally trust (boilerplate, formatting, docs)
But when you're in front of real code, questions arise that the framework doesn't answer:
- "This endpoint has auth and CRUD. Do I review all of it as Red Zone or only the auth part?"
- "Claude Code generated 5 files. Do I review them all at once or one by one?"
- "This function looks simple but touches business logic. How much do I trust it?"
- "I found an issue in file 2. Do I keep reviewing file 3 or do I stop?"
The mental models answer these questions. The module 1 framework is the "what." The mental models in this module are the "how," "when," and "how much."
Why mental models before techniques?
You might think: "I already have a checklist from module 1, give me more techniques." The problem is that techniques without judgment are dangerous. If someone gives you a 50-item checklist for code review, do you apply all of them to every line? Which ones do you skip? When do you go deeper?
The mental models answer those questions. They're the judgment that lets you decide when to apply each technique, at what depth, and when to stop. Without them, modules 3-7 would be a collection of techniques with no unifying thread.
Think of the difference between a chef and someone who follows recipes:
Developer with only techniques (follows recipes):
├── Has a 50-item checklist
├── Applies them mechanically to everything
├── Spends 30 minutes on a README
├── Spends 30 minutes on auth middleware
├── Doesn't know when they can skip items
└── Gets lost when the situation doesn't fit the checklist
Developer with mental models (chef):
├── Has the same 50 items available
├── Knows which to apply to each type of code
├── Spends 2 minutes on a README, 30 on auth
├── Adapts their process to each situation
├── Can navigate scenarios that aren't in the checklist
└── Their judgment improves with experience
The 3 Mental Models
Overview
The 3 models you're going to learn are complementary — each answers a different question:
| Mental Model | Question it answers | Metaphor | Capsule |
|---|---|---|---|
| Managing an Intern (MIT) | How do I supervise? | Claude Code is a brilliant intern | 02 |
| Circuit Breaker | When do I stop to verify? | Safety checkpoints | 03 |
| Trust Calibration | How much do I trust this task? | A trust thermometer | 04 |
Managing an Intern (MIT)
The most intuitive model. The central idea: Claude Code is like a brilliant intern who knows many languages and frameworks, works incredibly fast, but doesn't understand your business, doesn't know why certain decisions were made, and sometimes invents things that sound plausible.
A good intern manager:
├── Supervises the important decisions
├── Delegates the routine work
├── Verifies the business logic
├── Doesn't micro-manage every variable
└── Gives context the intern doesn't have
The same applies with Claude Code:
├── Supervise business logic and security
├── Delegate boilerplate and formatting
├── Verify the code meets the requirements
├── Don't review every import statement
└── Provide context in the prompt
Circuit Breaker
Adapted from the software engineering pattern. In distributed systems, a Circuit Breaker stops requests when a service fails to avoid cascades. Applied to code review: you define checkpoints where you pause and verify before continuing. If something fails, you stop — you don't keep generating code on top of a defective base.
Without a Circuit Breaker:
Generate 5 files → Accept all → Discover a bug in file 2
→ Files 3, 4, 5 based on buggy code → Complete revert
With a Circuit Breaker:
Generate file 1 → Checkpoint ✅ → Generate file 2 → Checkpoint ❌
→ Fix file 2 → Regenerate 3, 4, 5 on a correct base
Trust Calibration
The most actionable model. It turns "I think it's fine" into a structured process. For each type of task, you define a trust level that determines your review depth.
Trust Calibration in action:
Boilerplate setup → 85% → Visual review (1-2 min)
CRUD endpoint → 65% → Focused review (5-8 min)
Business logic → 30% → Exhaustive review (15-20 min)
Auth/Security → 15% → Line by line + docs (20-30 min)
Payment processing → 10% → Everything + tests + compliance (30+ min)
How they complement each other
Imagine Claude Code just generated 3 files for a new feature. What do you do?
1. Trust Calibration → How much do I trust each file?
"models.py: 80% (data models, routine)
service.py: 35% (business logic, I need to verify)
routes.py: 55% (endpoints, review auth and validations)"
2. Managing an Intern → How do I review each one?
"models.py: Visual review — fields and types correct?
service.py: The manager's 5 questions — each one
routes.py: Verify auth on sensitive endpoints"
3. Circuit Breaker → When do I pause?
"Checkpoint after models.py → if the models are wrong,
service.py and routes.py are based on incorrect models.
Checkpoint after service.py → if the logic is wrong,
routes.py exposes defective logic."
Without the 3 models, your review is inconsistent — sometimes you review too much, sometimes too little, and you have no criteria to know which is which.
Module progression
Module map
| Capsule | Topic | What you'll learn | Type |
|---|---|---|---|
| 02 | Managing an Intern (MIT) | How to supervise AI code without micro-managing or abandoning it | Technique |
| 03 | Circuit Breaker | When to pause and verify — checkpoints for your flow | Technique |
| 04 | Trust Calibration | How much to trust by type of task — the table you use daily | Technique |
| 05 | Integrative Exercise | Apply the 3 models to real scenarios with code | Exercise |
Learning flow
You start with the most intuitive model: Managing an Intern (capsule 02). The metaphor is powerful — if you've ever supervised someone junior, you already understand 80% of the model. Then you learn Circuit Breaker (capsule 03), which gives you the discipline to pause at key points instead of accepting everything at once. Then Trust Calibration (capsule 04), which gives you the most actionable tool: a detailed table with 15 types of task and their recommended trust level. Finally, the integrative exercise (capsule 05) makes you apply the 3 models together to 3 real scenarios with Python/FastAPI code.
The progression is: how to supervise → when to pause → how much to trust → apply it all together.
Dependencies between capsules
The capsules build on one another:
Capsule 02 (MIT) ─────────┐
├── Capsule 05 (Exercise)
Capsule 03 (Circuit Breaker)├── Applies the 3 models
│ to real code
Capsule 04 (Trust Cal.) ───┘
You can read capsules 02, 03, and 04 in any order — they're independent. But capsule 05 requires having completed all three.
Professional objective
By the end of this module you'll be able to:
- ✅ Explain the Managing an Intern model and apply it: what you supervise, what you delegate, how you review
- ✅ Define Circuit Breakers in your workflow: concrete checkpoints where you pause and verify
- ✅ Calibrate trust by type of task: "for boilerplate I trust 80%, for auth I trust 15%"
- ✅ Apply the 3 models together to a real code-generation scenario with Claude Code
- ✅ Adapt the models to your specific context (they're not rigid rules, they're frameworks)
- ✅ Document your validation process in a reproducible way
Connection to the Project
How it connects to the capstone project (Module 8)
The mental models are the foundation of the capstone project. In module 8 you'll receive a FastAPI codebase with real planted problems and your job will be to do a professional code review. You'll use these models like this:
- Managing an Intern: To decide which parts of the codebase to review in depth and which only need a glance. You're not going to review every import — you're going to focus on business logic and architecture decisions.
- Circuit Breaker: To structure your review into checkpoints. File by file, not all at once. If you find something serious, you stop and document it before continuing.
- Trust Calibration: To adjust the review depth by module. Basic CRUD gets a quick review; the auth module gets an exhaustive review.
Anticipation
Without these models, the module 8 project becomes chaotic — you review everything with the same depth and it takes you 3x longer without finding the issues that matter. With them, your review is efficient and effective: more issues found in less time.
The quantifiable difference:
Without mental models (module 8):
├── Time: 3-4 hours
├── Issues found: 8-10 of 20
├── Prioritization: none
└── Result: incomplete and exhausting review
With mental models (module 8):
├── Time: 1.5-2 hours
├── Issues found: 15-18 of 20
├── Prioritization: critical first, minor later
└── Result: complete and efficient review
Limits: What this module does NOT cover
- ❌ Specific detection techniques — Detecting hallucinations is module 3. Here you build thinking frameworks, not detection techniques.
- ❌ Code review checklist — The complete professional checklist of 15+ items is module 4. Here you learn the judgment to prioritize which checklist items to apply.
- ❌ Debugging errors — Debugging with Claude Code is module 6. Here you learn to think about AI code, not to debug it.
- ❌ Rigid rules — The mental models aren't rules. They're lenses for thinking. If you treat them as rules, you lose their value because they don't adapt to your context.
Before You Start: A Self-Assessment
Before getting into the models, evaluate how you supervise AI code today:
How do you review Claude Code's code currently?
A. "I review everything with the same depth"
→ You're spending time where it doesn't add value
→ You need: Trust Calibration (capsule 04)
B. "Sometimes I review a lot, sometimes nothing — it depends on the day"
→ Your supervision is inconsistent
→ You need: The 3 models to have stable judgment
C. "I review what feels important"
→ Your intuition might be good, but it's not communicable
→ You need: To turn intuition into a process
D. "I accept if it works, I review if it fails"
→ You're in reactive mode — the bugs reach production
→ You need: Circuit Breaker (capsule 03)
E. "I have a differentiated process by type of task"
→ You already have a foundation. The models will formalize it
→ Use the exercises to refine your process
There's no "bad" answer. What matters is that by the end of the module, your answer is E — with a process you can explain, teach, and improve with experience.
What you need for this module
Requirements:
├── ✅ Having completed module 1 (calibrated trust)
├── ✅ Basic experience with Claude Code or AI coding tools
├── ✅ Familiarity with Python/FastAPI (for the exercises)
└── ✅ Willingness to change how you think about code review
You don't need:
├── ❌ Experience as a manager (the metaphor is intuitive)
├── ❌ Knowledge of the Circuit Breaker pattern in software
└── ❌ To have worked with all the types of code that are covered
A Note on Mental Models
What they are and what they aren't
Mental models aren't rules you follow mechanically. They're thinking frameworks you internalize with practice. The difference matters:
Rule: "Always review the imports."
→ You apply it without thinking.
→ It doesn't adapt to the context.
→ It can be excessive (standard imports) or insufficient
(imports of libraries that could be hallucinations).
Mental model: "Supervise the way a good manager supervises an intern."
→ You interpret it according to the context.
→ It adapts to any new situation.
→ It improves with experience — every review teaches you something.
A developer with mental models can navigate situations they've never seen before, because the model gives them a framework to think. A developer with only rules freezes when the situation doesn't fit an existing rule.
How to internalize them
Mental models are internalized with practice, not with reading. That's why:
- Each technical capsule (02, 03, 04) has 4-5 exercises with real code
- Capsule 05 is a complete integrative exercise with 3 scenarios of increasing complexity
- The extra exercise in capsule 05 asks you to generate real code with Claude Code and apply the 3 models
Reading gives you understanding. The exercises give you internalization. The module 8 project gives you mastery.
Internalization progression:
Reading (capsules 02-04):
"I understand the models conceptually"
Exercises (capsules 02-04):
"I can apply each model separately"
Integrative exercise (capsule 05):
"I can apply the 3 models together"
Extra exercise (capsule 05):
"I can apply the models to MY code"
Project (module 8):
"The models are part of how I think"
Signs of success
By the end of this module, you'll know you succeeded if:
- ✅ You can explain each model in one sentence and give a concrete example
- ✅ When Claude Code generates code, you automatically think in terms of the 3 models
- ✅ Your review of AI code is more efficient: less total time, more issues found
- ✅ You can justify why you review something in depth and why you trust something else
- ✅ You applied the 3 models to a real scenario and documented the process
- ✅ You can adapt the models to situations that weren't covered in the capsules
The definitive test: if someone asks you "why did you accept this code without an exhaustive review?", you can give an articulated answer: "It's standard CRUD (Trust Calibration: 70%), I reviewed validations and error handling (MIT Level 2), and my checkpoint passed with no issues (Circuit Breaker)."
Comparison: before and after the module
Before the module (review without models):
├── You review "whatever comes to mind"
├── You spend 20 min on a README
├── You spend 5 min on auth middleware
├── You can't explain why you reviewed X and not Y
├── Your process changes with your energy that day
└── Result: inconsistent review, issues slip through
After the module (review with models):
├── Trust Calibration tells you the depth
├── 2 min on the README (85% trust)
├── 25 min on the auth middleware (15% trust)
├── You can justify every review decision
├── Your process is stable regardless of the day
└── Result: efficient review, critical issues detected
Summary
- This module gives you 3 mental models for supervising AI-generated code
- The models are complementary: how to supervise (MIT), when to pause (Circuit Breaker), how much to trust (Trust Calibration)
- They're thinking frameworks, not rules — they adapt to your context and improve with experience
- The mental models are the "operating system" on which all the techniques in modules 3-7 run
- In the capstone project (module 8) you'll use the 3 models to do an efficient code review of a complete codebase
- The module progression: how to supervise → when to pause → how much to trust → apply it all together
- They're internalized with practice: exercises in each capsule + integrative exercise + project
Additional resources
- Mental Models — Farnam Street - A curated collection of mental models for clear thinking and decision-making
- The Manager's Path — Camille Fournier - How effective managers supervise without micro-managing
- Circuit Breaker Pattern — Martin Fowler - The original software engineering pattern adapted to code review
- Thinking in Bets — Annie Duke - Trust calibration and decision-making under uncertainty
- Anthropic — Claude Code Best Practices - Official Claude Code documentation
Next capsule: Managing an Intern (MIT) — the most intuitive model for supervising AI code.
Debugging & Code Review with Claude Code — Module 2, Capsule 01 Claude Code Agentic Development Path — Guide #6 of 11