Adds engineering/codebase-design/ — shared vocabulary for designing deep
modules (module, interface, seam, adapter, depth, leverage, locality).
Three files: SKILL.md (glossary + principles + R+Py testability examples +
rejected framings); DEEPENING.md (4 dependency categories, seam discipline,
replace-don't-layer); DESIGN-IT-TWICE.md (parallel sub-agent pattern for
exploring 3+ radically different interface designs).
Retargets existing bdd siblings as language-flavored leaves:
- bdd/SKILL.md gains a Vocabulary anchor pointing at codebase-design
- interface-design-{r,py}.md and deep-modules-r.md get "vocab lives
upstream" headers; "deep modules" mention dropped from the py
interface-design description (codebase-design owns it now)
- mocking-{r,py}.md swap "boundary" -> "seam" throughout — upstream
rejects "boundary" as overloaded with DDD's bounded context
- refactoring-r.md cross-links Shallow-modules to DEEPENING.md
Cross-references added in sieve/SKILL.md (Minimal invokes depth),
winnow/SKILL.md (deletion test formalised there), diagnose/SKILL.md
(seam definition for Phase 5's "no correct seam" finding),
domain-modeling/SKILL.md (sibling — vocabulary for solution structure
vs problem domain). README gains a codebase-design bullet.
Source: mattpocock/skills@main engineering/codebase-design/. R+Py
testability examples replace upstream TS originals.
4.3 KiB
name, description
| name | description |
|---|---|
| codebase-design | Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary. |
codebase-design
Design deep modules: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. The aim is leverage for callers, locality for maintainers, and testability for everyone.
Glossary
Use these exactly; don't substitute "component", "service", "API", "boundary".
Module — anything with an interface and an implementation. Scale-agnostic: function, class, package, tier-spanning slice. Avoid: unit, component, service.
Interface — everything a caller must know to use the module correctly: type signature, invariants, ordering, error modes, configuration, performance. Avoid: API, signature (type-level only).
Implementation — what's inside a module. Distinct from Adapter: a small adapter can wrap a large implementation (a Postgres repo), or vice versa.
Depth — leverage at the interface: behaviour a caller exercises per unit of interface learned. Deep = much behaviour behind a small interface; shallow = interface nearly as complex as impl.
Seam (Michael Feathers) — a place where you can alter behaviour without editing in that place; the location at which a module's interface lives. Avoid: boundary (overloaded with DDD's bounded context).
Adapter — a concrete thing that satisfies an interface at a seam. Role, not substance.
Leverage — what callers get from depth: more capability per unit of interface learned. One impl pays back across N call sites, M tests.
Locality — what maintainers get from depth: change, bugs, knowledge, verification concentrate in one place. Fix once, fixed everywhere.
Deep vs shallow
A deep module = small interface (few methods, simple params) over large implementation (complex logic hidden). Shallow = the inverse, mostly pass-through. Avoid shallow: reduce methods, simplify params, hide more inside.
Principles
- Depth is a property of the interface, not the implementation. A deep module can be composed of small mockable parts internally; internal seams (private, used by its own tests) coexist with the external seam.
- 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. To test past the interface is to find the module is the wrong shape.
- One adapter = hypothetical seam; two = real one. Don't introduce a seam unless something actually varies across it.
Designing for testability
Accept dependencies, don't create them.
# R: pass the client; default keeps callers ergonomic
fetch_orders <- function(order_id, client = modb_client()) client$get(order_id)
# Python: optional parameter, same shape
def fetch_orders(order_id: str, client: ModbClient | None = None) -> Order:
return (client or ModbClient()).get(order_id)
Constructing the client inside buries the dependency past the interface.
Return results, don't produce side effects.
# R: return the new value
calculate_discount <- function(cart) cart$total - discount(cart)
# Python: return the new value
def calculate_discount(cart: Cart) -> Decimal:
return cart.total - discount(cart)
Mutating in place hides the effect and couples every test to caller state.
Rejected framings
- Depth as impl-lines ÷ interface-lines (Ousterhout): rewards padding. Use depth-as-leverage instead.
- "Interface" = the TypeScript
interfacekeyword or a class's public methods: too narrow — interface here is every fact a caller must know. - "Boundary": overloaded with DDD's bounded context. Say seam or interface.
DEEPENING.md — dependency categories, seam discipline, replace-don't-layer testing. DESIGN-IT-TWICE.md — parallel sub-agents to design the interface several radically different ways; compare on depth, locality, seam placement.