prototype
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrototype
原型
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.
- 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.
- 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.
- 从一开始就明确标记为一次性代码。将原型代码放在其实际应用位置附近(紧邻它所原型化的模块或页面),以便上下文清晰——但命名要让普通读者一眼就能看出这是原型而非生产代码。对于一次性UI路由,遵循项目已有的路由约定;不要创建新的顶级结构。
- 一键运行。使用项目现有任务运行器支持的方式——、
pnpm <name>、python <path>等。用户无需思考即可启动它。bun <path> - 默认不持久化。状态存储在内存中。持久化是原型需要验证的内容,而非其依赖项。如果问题明确涉及数据库,使用临时数据库或带有清晰“PROTOTYPE — wipe me”名称的本地文件。
- 跳过打磨环节。无需测试,除了保证原型可运行之外无需额外错误处理,也无需抽象设计。核心目标是快速获取信息。
- 展示状态。每次操作(逻辑原型)或切换变体(UI原型)后,打印或渲染完整的相关状态,让用户能看到发生了哪些变化。
- 完成后留存记录。将经过验证的决策整合到正式代码中,然后将原型本身作为原始资料留存:提交到一个临时分支(而非主分支),并在实现问题中留下指向该分支的上下文链接。同时留存答案——即结论以及它所解决的问题——到问题记录或提交信息中。主分支仅保留经过验证的决策。