原型

工程开发 社区

技能解读

设计思路

prototype 是 mattpocock 的「快速原型」skill——把「我们应该怎么做」拆成两个分支问题:逻辑 / 状态模型(用 LOGIC.md:建一个小交互终端 app 把状态机推过那些纸上很难推的 case)vs 视觉 / UI(用 UI.md:在单一路由上同时生成多套激进不同的 UI,通过 URL search param + 浮动底栏切换)。走错分支会浪费整个 prototype——所以要先选对枝。

选枝原则

  • "logic / state model 对不对?" → LOGIC.md
  • "这玩意应该长什么样?" → UI.md
  • 真模糊且联系不上用户 → 看周围代码默认(后端模块 → logic;页面 / 组件 → UI),并把假设写在 prototype 顶部

两枝共用规则

  1. 从第一天起就是 throwaway,并显式标记:放在它要被用的地方旁边(让 context 清楚),但命名让随便看的人都能看出来「这是 prototype,不是生产」。throwaway UI 路由遵循项目既有路由约定,别造新顶层结构。
  2. One command to run:用项目现有 task runner(pnpm <name> / python <path> / bun <path>)——用户不动脑就能跑。
  3. No persistence by default:状态住内存里。持久化是 prototype 在测的东西,不是它该依赖的东西。如果问题确实涉及 DB,挂临时 scratch DB / 本地文件,名字明确写「PROTOTYPE — wipe me」。
  4. Skip the polish:不写测试、不超出「能跑」的错误处理、不抽象——目的是快速学到东西然后删掉。
  5. Surface the state:每次动作(logic)后或每次切换(UI)时把相关完整状态打印 / 渲染出来——用户能看见到底变了啥。
  6. Delete or absorb when done:prototype 答完问题后要么删要么吸进真实代码——别让它在仓库里腐烂。

When done

答案才是 prototype 留下的唯一价值。 把它沉淀到 commit message / ADR / issue / prototype 旁边的 NOTES.md,连同它在回答的问题。删 prototype 之前,把 verdict 写下来。

适合谁

  • 拿不定主意「先做 A 还是先做 B」希望靠跑一把代码学到答案的工程师
  • 设计阶段验证状态机 / UI 假设的人
  • 想用代码替代纸上推演但不想被生产代码标准拖慢的快速决策

不适合

  • 答案已经清楚——直接写
  • 写到一半就忘了删——prototype 的反模式

配套

brainstorming(前置)、design-an-interface(接口形状专门版)、design-shotgun(UI 多版本探索的视觉版)、writing-plans(prototype 答完之后正式落实施)。

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
工程开发
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@mattpocock · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
macOS · Linux · Windows
运行环境要求
Python
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Prototype

A prototype is **throwaway code that answers a question**. The question decides the shape.

## Pick a branch

Identify which question is being answered, using the user's prompt, the surrounding code, or by asking if the user is around:

- **"Does this logic / state model feel right?"** → [LOGIC.md](LOGIC.md). Build a single shareable HTML file (free-play buttons plus tabbed guided walkthroughs) that pushes the state machine through cases that are hard to reason about on paper, and that a non-developer can drive.
- **"What should this look like?"** → [UI.md](UI.md). Generate several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar.

The two branches produce very different artifacts, so getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.

## Rules that apply to both

1. **Throwaway from day one, and clearly marked as such.** Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious, but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
2. **Trivial to run.** A UI prototype starts from one command in the project's task runner: `pnpm <name>`, `python <path>`, `bun <path>`, etc. A logic demo is a single HTML file the user double-clicks. Either way, no thinking required to start it.
3. **No persistence by default.** State lives in memory. Persistence is the thing the prototype is _checking_, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE, wipe me" name.
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype _runnable_, no abstractions. The point is to learn something fast.
5. **Surface the state.** After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
6. **Capture it when done.** Fold any validated decision into the real code, then capture the prototype itself as a **primary source**: commit it to a throwaway branch, out of main, and leave a context pointer to that branch on the implementation issue. Capture the answer too (the verdict and the question it settled) in the issue or a commit. The main branch keeps only the validated decision.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。