跳转到内容

prototype

prototype 是用来回答某个问题的一次性代码。要回答的问题决定 prototype 的形式。

根据用户的提示、周边代码,或在用户在线时询问,判断要回答什么问题:

  • 「这套逻辑或状态模型用起来感觉对吗?」→ LOGIC.md。构建一个可分享的 HTML 文件,包含自由操作按钮和带标签页的引导演示,用纸面上难以推演的情况推动状态机运行,并让非开发者也能操作。
  • 「它应该长什么样?」→ UI.md。在同一个路由上生成几种截然不同的 UI 方案,通过 URL 查询参数和悬浮底栏切换。

这两个分支会产出完全不同的东西,选错会让整个 prototype 白做。如果问题确实模糊,而且联系不上用户,就根据周边代码选择更合适的分支:后端模块选 logic,页面或组件选 UI。并在 prototype 顶部写明这个假设。

  1. 从第一天起就把它当作一次性代码,并清楚标明这一点。把 prototype 代码放在实际使用位置附近,也就是被原型验证的模块或页面旁边,让人一眼看懂上下文;命名也要让普通读者看出它是 prototype,而非正式产品代码。对于一次性 UI 路由,遵循项目现有的路由约定,不要另造顶层结构。
  2. 运行要简单。UI prototype 应通过项目任务运行器中的一条命令启动,例如 pnpm <name>、python <path>、bun <path> 等。logic 演示则做成一个 HTML 文件,用户双击即可打开。启动时不需要额外思考。
  3. 默认不要持久化。状态放在内存里。prototype 要验证的内容如果是持久化机制,那就使用临时数据库或本地文件,并起一个明显标有「PROTOTYPE, wipe me」的名字。如果问题明确涉及数据库,就按此处理。
  4. 不用打磨细节。不要写测试,不要处理超出「能运行」所需的错误,也不要加抽象。目的是快速学到东西。
  5. 展示状态。每次操作后(logic),或每次切换方案时(UI),都打印或渲染完整的相关状态,让用户看清发生了什么变化。
  6. 完成后留档。把验证通过的决策合并进正式代码,再把 prototype 本身作为主要来源留存:提交到一个一次性分支,不要放进 main,并在实现 issue 里留下指向该分支的上下文指针。同时把结论也记在 issue 或提交里,包括最终判断和它回答的问题。main 分支只保留验证通过的决策。

读者可以点名用它,模型也可以自己调用它。它在 Claude Code 插件里。

用一次性代码快速验证逻辑、状态模型或 UI 方案,并把验证通过的决策带回正式代码。

Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
英文 SKILL.md
---
name: prototype
description: Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
---
# 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.

非官方学习站,与 Matt Pocock 和 AI Hero 没有隶属关系。本站不提供可安装的中文技能包。

技能原文采用 MIT 许可。Copyright (c) 2026 Matt Pocock

鲁ICP备2025189036号