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.
67 lines
2.8 KiB
Markdown
67 lines
2.8 KiB
Markdown
# Design It Twice
|
||
|
||
When the user wants to explore alternative interfaces for a chosen deepening
|
||
candidate, use this parallel sub-agent pattern. Based on "Design It Twice"
|
||
(Ousterhout) — your first idea is unlikely to be the best.
|
||
|
||
Uses the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**,
|
||
**seam**, **adapter**, **leverage**.
|
||
|
||
## Process
|
||
|
||
### 1. Frame the problem space
|
||
|
||
Before spawning sub-agents, write a user-facing explanation of the problem
|
||
space for the chosen candidate:
|
||
|
||
- The constraints any new interface would need to satisfy.
|
||
- The dependencies it would rely on, and which category they fall into
|
||
(see [DEEPENING.md](DEEPENING.md)).
|
||
- A rough illustrative code sketch to ground the constraints — not a
|
||
proposal, just a way to make the constraints concrete.
|
||
|
||
Show this to the user, then immediately proceed to Step 2. The user reads and
|
||
thinks while the sub-agents work in parallel.
|
||
|
||
### 2. Spawn sub-agents
|
||
|
||
Spawn 3+ sub-agents in parallel using the Agent tool — **one message with
|
||
multiple Agent tool uses** so they run concurrently. Each must produce a
|
||
**radically different** interface for the deepened module. Use
|
||
`subagent_type: claude` (general-purpose) so each has full read + search.
|
||
|
||
Prompt each sub-agent with a separate technical brief (file paths, coupling
|
||
details, dependency category from [DEEPENING.md](DEEPENING.md), what sits
|
||
behind the seam). The brief is independent of the user-facing problem-space
|
||
explanation in Step 1. Give each agent a different design constraint:
|
||
|
||
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise
|
||
leverage per entry point."
|
||
- Agent 2: "Maximise flexibility — support many use cases and extension."
|
||
- Agent 3: "Optimise for the most common caller — make the default case
|
||
trivial."
|
||
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam
|
||
dependencies."
|
||
|
||
Include both [SKILL.md](SKILL.md) vocabulary and `CONTEXT.md` vocabulary in
|
||
the brief so each sub-agent names things consistently with the architecture
|
||
language and the project's domain language.
|
||
|
||
Each sub-agent outputs:
|
||
|
||
1. Interface (types, methods, params — plus invariants, ordering, error modes).
|
||
2. Usage example showing how callers use it.
|
||
3. What the implementation hides behind the seam.
|
||
4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md)).
|
||
5. Trade-offs — where leverage is high, where it's thin.
|
||
|
||
### 3. Present and compare
|
||
|
||
Present designs sequentially so the user can absorb each one, then compare
|
||
them in prose. Contrast by **depth** (leverage at the interface),
|
||
**locality** (where change concentrates), and **seam placement**.
|
||
|
||
After comparing, give your own recommendation: which design you think is
|
||
strongest and why. If elements from different designs would combine well,
|
||
propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
|