Design It Twice

当用户想为选定的 deepening 候选探索 alternative interface 时,使用此并行 sub-agent 模式。基于 "Design It Twice"(Ousterhout)— 第一个想法 unlikely 是最好的。

使用 SKILL.md 中的词汇 — moduleinterfaceseamadapterleverage

Process

1. Frame the problem space

spawn sub-agent 前,为选定候选写面向用户的 problem space 说明:

  • 任何新 interface 须满足的 constraint
  • 将依赖什么,属于哪类(见 DEEPENING.md
  • 粗略示意代码 sketch 以 ground constraint — 非提案,只是让 constraint 具体

展示给用户,然后立即进行 Step 2。用户阅读思考时 sub-agent 并行工作。

2. Spawn sub-agents

用 Agent tool 并行 spawn 3+ sub-agent。每个须为 deepened module 产出 radically different 的 interface。

给每个 sub-agent 独立 technical brief(file path、coupling 细节、DEEPENING.md 的 dependency category、seam 后是什么)。brief 与 Step 1 面向用户的 problem-space 说明独立。给每个 agent 不同设计 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(若适用):"Design around ports & adapters for cross-seam dependencies."

brief 中同时包含 SKILL.md 词汇与 CONTEXT.md 词汇,使各 sub-agent 与架构语言和项目领域语言一致命名。

每个 sub-agent 输出:

  1. Interface(types、methods、params — 加 invariant、ordering、error mode)
  2. Usage example 展示 caller 如何用
  3. implementation 在 seam 后藏什么
  4. Dependency strategy 与 adapter(见 DEEPENING.md
  5. Trade-offs — leverage 高处在哪、薄处在哪

3. Present and compare

依次呈现设计以便用户吸收,再用 prose 比较。按 depth(interface 处 leverage)、locality(change 集中处)、seam placement 对比。

比较后给出你的推荐:哪个设计最强及 why。若不同设计的元素可组合,提出 hybrid。要有主见 — 用户要的是强判断,不是菜单。