Lesson 7 · Matt Pocock's Skills
Codebase Health and Retro
The main flow ships a feature. Two skills keep the next feature easy: one improves the code, the other improves the agent's environment.
Your win for this lesson
You can apply the deletion test to a module and tell a real seam from a fake one. You can also take a retro finding and say where its fix belongs: a check, a coding standard, a pointer, or wider access.
0. Warm-up
These are mixed from Lessons 3–6, with no hints about which lesson each comes from.
1. Idea one: depth is leverage at the interface
This is the fourth failure mode from Lesson 1, the ball of mud. Agents speed up entropy, because each change is local and nobody watches the shape. Pocock's fix starts with words. codebase-design is a glossary that the other skills share, and it bans loose substitutes: "don't substitute 'component,' 'service,' 'API,' or 'boundary.' Consistent language is the whole point."[1]
| Term | Meaning |
|---|---|
| Module | Anything with an interface and an implementation, at any scale: a function, a class, a package. |
| Interface | Everything a caller must know: the types, plus invariants, ordering, error modes, config, and performance. |
| Seam | The location where an interface lives, a place where you can change behaviour without editing there (from Feathers). |
| Adapter | A concrete thing that fills the slot at a seam. It's a role, so an in-memory fake and a Postgres repo are both adapters. |
| Depth | How much behaviour a caller or test gets per unit of interface it has to learn. |
| Leverage / Locality | What depth pays out. Callers get more for less (leverage). Maintainers get one place to fix (locality). |
Deep: a small interface with a lot behind it.
Shallow: the interface is nearly as big as the code.
Four principles follow from these words:[1]
- The deletion test. Imagine deleting the module. "If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep."
- The interface is the test surface. Callers and tests cross the same seam. "If you want to test past the interface, the module is probably the wrong shape."
- One adapter means a hypothetical seam. Two adapters means a real one. A port with only a production adapter, and no test adapter, is just indirection.
- Depth is a property of the interface. Inside, a deep module can be small swappable parts with their own internal seams. Callers never see them.
Two connections to earlier lessons
Lesson 4's "mock only at system boundaries" is a special case of this. DEEPENING.md sorts dependencies into four kinds, and the kind decides how you test across the seam. In-process code you merge and test directly. Local-substitutable dependencies run a stand-in, such as PGLite. For remote but owned services you define a port, with an HTTP adapter for production and an in-memory one for tests. A true external service, like Stripe, you mock.[2] The skill also departs from Ousterhout on purpose. It rejects his "implementation lines ÷ interface lines" ratio, because that "rewards padding the implementation."[1]
2. Idea two: survey, pick one, then the main flow
/improve-codebase-architecture looks for deepening opportunities: places where a cluster of shallow modules could become one deep module. "It never changes the code." The whole run produces one HTML report in $TMPDIR and a conversation.[4]
- Scope before you scan (YAGNI). If you named a direction, it takes it. Otherwise it reads
git logfor hot spots, because "a deepening in code that nobody touches is a refactor that never pays back." The best prompt is the next build: point it at the spec and ask "how can we make this change easy?"[4] - Explore with the deletion test. A subagent looks for friction: a concept that takes five files to understand, pure functions pulled out for testability while the bugs live in how callers use them, and code that's hard to test through its interface.[3]
- Report, then stop. Each card has the files, the problem, the solution, the benefit (in terms of locality and leverage), a before/after diagram, and a badge:
Strong,Worth exploring, orSpeculative. It ends with a top pick and asks "Which of these would you like to explore?" It doesn't propose interfaces yet. - Grill the one you picked. The output is "a decision, not a diff", and the decision then goes through the main flow:
/to-spec→/to-tickets→/implement. Use one candidate per session, and turn the rest into tickets.[4]
Field notes from the guide's "Common questions":[4]
- It rarely says "fine." The skill exists to produce findings. "If every candidate in a report is
Speculative, the skill found nothing." - Over-grilling is the top complaint. Weaker models skip the report and interview you about their first idea. Say "don't grill me, just show the report."
- Rejecting a candidate for a lasting reason? Accept the offer of an ADR, so the next run doesn't suggest it again. That's Lesson 2's ADR test again.
- Don't drive a session with
/codebase-designalone. It's a reference with no process. Given "go," an agent invents a process and runs for 100k tokens before asking anything (issue #449). Run a driver skill and let it use the vocabulary.[7]
3. Idea three: fix the environment, not the code
/retro is the last step of the main chain. It reads a session's own record and proposes changes to the agent's environment, so the next run goes better. It changes no code, and nothing changes until you pick a candidate.[6] The category of what went wrong decides where the fix goes:
| What went wrong in the session | Fix it with |
|---|---|
| The agent took a long time to find a file or fact | A navigation pointer in a file it already reads |
| It made a mistake a tool could have caught | An automated check: a lint rule, a type, a test, a hook, or a CI job |
| The reviewer missed a judgement-call mistake | A rule in CODING_STANDARDS.md |
| It needed information it couldn't reach | Wider access: tee the dev-server log to a file, give read-only access to a service |
AGENTS.md/CLAUDE.md is large, or full of lines that change nothing | Move steering into standards or checks, and delete the no-ops |
One rule sits under the table: classify the violation first. A mechanical one, such as a banned API, an import shape, or a file-location rule, "gets a deterministic check, full stop," because a check can fail and a sentence can't. Only real judgement calls become prose.[5]
That prose goes to the reviewer, not the implementer. The implementing agent "has the most context pressure", because it explores, writes code, and debugs. The reviewer gets a diff and nothing else, so it has room to apply standards. This is why CODING_STANDARDS.md is read during review (Lesson 4's Standards axis), and why CLAUDE.md is kept "incredibly sparingly, usually only for navigation pointers."[5]
- Check what's already there first. If a lint script exists but nothing runs it, the finding is to wire it up, not to build a new one. A repo with no guardrail at all is itself a finding.[5]
- Run it while the struggles are still in context. Run it in the same session by default. If you're past the smart zone,
/clearand point a fresh/retroat the old session's log. - Discard any candidate you can't trace to a specific moment. Generic advice that fills the categories is its known weakness. Skip it after a smooth build, because smooth sessions teach little.[6]
The two skills side by side: /improve-codebase-architecture takes code as input and improves the code. /retro takes a session as input and improves the environment. "You use both; neither replaces the other."[6]
4. Practice
Drill A: run the deletion test
These come from a BullMQ job system. Decide what you'd do with each module.
Drill B: where does the retro fix go?
Drill C: which skill now? (all on-ramps, interleaved)
Walk each scenario down the ladder. The first yes wins. This ladder is my study aid built from Lessons 6–7, not a sequence Pocock publishes.
Drill D: inside the two skills
Drill E: from memory
Write the four codebase-design principles. Then write where a mechanical retro finding goes and where a judgement-call one goes, and why the second goes there.
1. The deletion test: if complexity vanishes, the module was a pass-through; if it reappears in callers, it earns its keep. 2. The interface is the test surface. 3. One adapter is a hypothetical seam; two is a real one. 4. Depth is a property of the interface, not the implementation.
A mechanical finding becomes a deterministic check (lint, hook, or CI). A judgement call goes in CODING_STANDARDS.md, which the reviewer reads, because the reviewer has the least context pressure. Never put either in CLAUDE.md.
Optional: feel it for real (10 min, no plugin needed)
In learn-bullmq (or your Go project), run git log --name-only --format= | grep . | sort | uniq -c | sort -rn | head to find the hot spots. Pick the top file and run the deletion test on one module in it, out loud: would its complexity vanish, or reappear across its callers? You'll install the plugin and do the real run in Lesson 8.
Primary source
Read codebase-design/SKILL.md in full (6 minutes). It's the vocabulary every other design skill uses. Then read the retro guide, especially "Where the findings land" and its "Common questions."
Stuck on something?
Ask me in Claude Code. Good questions: "deletion-test this module in learn-bullmq with me", "is this Redis wrapper a real seam or a hypothetical one?", or "what would a retro on my last session find?"
The Health Card has all of this on one page. See also the On-ramps Card, the Build Card, and the Skill Map.