prototype
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrototype
Prototype
A prototype is throwaway code that answers a question. The question decides the shape.
原型是用于解答问题的可丢弃代码。问题决定了原型的形态。
Pick a branch
选择分支
Identify which question is being answered — from the user's prompt, the surrounding code, or by asking if the user is around:
- "Does this logic / state model feel right?" → LOGIC.md. Build a tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper.
- "What should this look like?" → 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 — 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.
确定需要解答的问题——可以从用户的提示、现有代码中获取,或者询问用户是否在场:
- “这个逻辑/状态模型是否合理?” → LOGIC.md。构建一个小型交互式终端应用,让状态机运行那些难以在纸上推理的场景。
- “这个应该是什么样子?” → UI.md。在单个路由上生成多种截然不同的UI变体,可通过URL搜索参数和浮动底部栏进行切换。
这两个分支会产出完全不同的成果——选错分支会浪费整个原型。如果问题确实不明确且无法联系到用户,则默认选择与现有代码更匹配的分支(后端模块→逻辑分支;页面或组件→UI分支),并在原型顶部说明该假设。
Rules that apply to both
适用于两个分支的规则
- 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.
- One command to run. Whatever the project's existing task runner supports — ,
pnpm <name>,python <path>, etc. The user must be able to start it without thinking.bun <path> - 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.
- Skip the polish. No tests, no error handling beyond what makes the prototype runnable, no abstractions. The point is to learn something fast and then delete it.
- 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.
- Delete or absorb when done. When the prototype has answered its question, either delete it or fold the validated decision into the real code — don't leave it rotting in the repo.
- 从一开始就明确标记为可丢弃。 将原型代码放在其实际使用位置附近(紧邻它所原型化的模块或页面),以便上下文清晰——但命名要让普通读者一眼就能看出这是原型而非生产代码。对于可丢弃的UI路由,遵循项目已有的路由约定;不要创建新的顶级结构。
- 一键运行。 支持项目现有任务运行器的任意命令——、
pnpm <name>、python <path>等。用户无需思考即可启动原型。bun <path> - 默认不持久化。 状态存储在内存中。持久化是原型需要验证的内容,而非其依赖项。如果问题明确涉及数据库,则使用临时数据库或命名为“PROTOTYPE — wipe me”的本地文件。
- 跳过优化环节。 不编写测试,仅保留让原型可运行的必要错误处理,不做抽象封装。核心是快速获取信息,随后即可删除原型。
- 展示状态。 每次操作(逻辑分支)或切换变体(UI分支)后,打印或渲染完整的相关状态,以便用户查看变化。
- 完成后删除或整合。 当原型解答了问题后,要么删除它,要么将验证后的决策整合到正式代码中——不要让它在仓库中闲置。
When done
完成后
The answer is the only thing worth keeping from a prototype. Capture it somewhere durable (commit message, ADR, issue, or a next to the prototype) along with the question it was answering. If the user is around, that capture is a quick conversation; if not, leave the placeholder so they (or you, on the next pass) can fill in the verdict before deleting the prototype.
NOTES.md答案是原型中唯一值得保留的内容。将答案连同它所解答的问题一起记录在持久化的位置(提交信息、架构决策记录ADR、Issue,或原型旁的文件)。如果用户在场,可以通过简短沟通记录;如果不在,则留下占位符,以便他们(或下次迭代时的你)在删除原型前填写结论。
NOTES.md