| 1 | # Interface Design |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | Uses the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**, **leverage**. |
| 6 | |
| 7 | ## Process |
| 8 | |
| 9 | ### 1. Frame the problem space |
| 10 | |
| 11 | Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate: |
| 12 | |
| 13 | - The constraints any new interface would need to satisfy |
| 14 | - The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md)) |
| 15 | - A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete |
| 16 | |
| 17 | Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel. |
| 18 | |
| 19 | ### 2. Spawn sub-agents |
| 20 | |
| 21 | Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module. |
| 22 | |
| 23 | 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: |
| 24 | |
| 25 | - Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point." |
| 26 | - Agent 2: "Maximise flexibility — support many use cases and extension." |
| 27 | - Agent 3: "Optimise for the most common caller — make the default case trivial." |
| 28 | - Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies." |
| 29 | |
| 30 | Include both [LANGUAGE.md](LANGUAGE.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. |
| 31 | |
| 32 | Each sub-agent outputs: |
| 33 | |
| 34 | 1. Interface (types, methods, params — plus invariants, ordering, error modes) |
| 35 | 2. Usage example showing how callers use it |
| 36 | 3. What the implementation hides behind the seam |
| 37 | 4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md)) |
| 38 | 5. Trade-offs — where leverage is high, where it's thin |
| 39 | |
| 40 | ### 3. Present and compare |
| 41 | |
| 42 | 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**. |
| 43 | |
| 44 | 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. |
| 45 |