设计两遍
当用户想为选定的深模块候选项探索不同接口时,使用这种并行子代理模式。这个做法源自「Design It Twice」(Ousterhout):你的第一个想法很可能不是最佳方案。
使用 SKILL.md 中的词汇:module、interface、seam、adapter、leverage。
1. 梳理问题空间
Section titled “1. 梳理问题空间”启动子代理之前,先面向用户说明选定候选项的问题空间:
- 新接口需要满足哪些约束
- 它依赖哪些内容,以及这些依赖属于哪一类(见 DEEPENING.md)
- 用一段粗略的示意代码说明这些约束。这不是方案,只是让约束更具体
把这些内容展示给用户,然后立即进入第 2 步。用户可以一边阅读和思考,子代理一边并行工作。
2. 启动子代理
Section titled “2. 启动子代理”并行启动至少 3 个子代理,每个都使用全新的上下文窗口。每个子代理都必须为深化后的模块设计一个截然不同的接口。
分别给每个子代理一份独立的技术简报,说明文件路径、耦合情况、依赖类别(见 DEEPENING.md),以及 seam 背后的内容。这份简报独立于第 1 步面向用户的问题空间说明。给每个子代理不同的设计约束:
- 子代理 1:「尽量精简接口,最多设计 1 到 3 个入口。让每个入口都尽可能发挥作用。」
- 子代理 2:「尽量提高灵活性,支持多种用法和扩展。」
- 子代理 3:「优先满足最常见的调用方,让默认情况简单易用。」
- 子代理 4(如适用):「围绕 ports & adapters 设计跨 seam 依赖。」
在简报中同时纳入 SKILL.md 和 GLOSSARY.md 中的词汇,确保每个子代理都能使用统一的架构语言和项目领域词汇。
每个子代理都要输出:
- 接口(类型、方法、参数,以及不变量、顺序和错误模式)
- 使用示例,展示调用方如何使用
- 实现中隐藏在 seam 后面的内容
- 依赖策略和 adapters(见 DEEPENING.md)
- 权衡:哪些地方 leverage 高,哪些地方作用有限
3. 展示并比较
Section titled “3. 展示并比较”依次展示各个设计,让用户能逐一理解,再用文字进行比较。从深度(接口带来的 leverage)、局部性(变更集中在哪里)和 seam 的位置这几个方面进行对比。
比较之后,给出你自己的建议:你认为哪个设计最强,以及理由。如果不同设计中的某些部分适合组合,就提出一个混合方案。明确表达观点:用户想听有力的判断,而不是选项列表。
原文链接和 commit
Section titled “原文链接和 commit”英文 DESIGN-IT-TWICE.md
# 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, each with a fresh context window. Each must produce a **radically different** interface for the deepened module.
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 GLOSSARY.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 it3. What the implementation hides behind the seam4. 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.非官方学习站,与 Matt Pocock 和 AI Hero 没有隶属关系。本站不提供可安装的中文技能包。
技能原文采用 MIT 许可。Copyright (c) 2026 Matt Pocock