← 技能图谱 · LOGIC · UI
nameprototype
descriptionBuild 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.
触发词构建可抛弃的原型来回答设计问题。当用户想验证状态模型或逻辑是否合理,或探索 UI 应该长什么样时使用。

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.
  • "这个逻辑/状态模型合理吗?"LOGIC.md。构建一个小型交互式终端应用,推动状态机遍历那些在纸上难以推理的案例。
  • "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.
  • "这应该长什么样?"UI.md。在单个路由上生成几种截然不同的 UI 变体,通过 URL 搜索参数和浮动底部栏进行切换。

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;页面或组件 → UI),并在原型顶部说明这个假设。

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.
  1. 从一开始就是可抛弃的,并明确标注。 将原型代码放在实际使用位置附近(在其要原型化的模块或页面旁边),这样上下文一目了然——但命名要让随意浏览的人一眼看出是原型,而非生产代码。对于可抛弃的 UI 路由,遵循项目已有的路由约定;不要发明新的顶层结构。
  1. One command to run. Whatever the project's existing task runner supports — pnpm <name>, python <path>, bun <path>, etc. The user must be able to start it without thinking.
  1. 一条命令运行。 使用项目已有任务运行器支持的任意方式——pnpm <name>python <path>bun <path> 等。用户必须能不假思索地启动它。
  1. 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.
  1. 默认不持久化。 状态存在内存中。持久化是原型要验证的东西,而不是它应该依赖的东西。如果问题明确涉及数据库,使用临时数据库或命名中包含 "PROTOTYPE — wipe me" 的本地文件。
  1. Skip the polish. No tests, no error handling beyond what makes the prototype runnable, no abstractions. The point is to learn something fast.
  1. 跳过打磨。 不写测试,不处理错误(除非影响原型可运行性),不做抽象。目的是快速学到东西。
  1. 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.
  1. 展示状态。 每次操作后(logic)或每次变体切换时(UI),打印或渲染完整的相关状态,让用户看到变化。
  1. 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.
  1. 完成后捕获它。 将任何验证过的决策合入真实代码,然后把原型本身作为一手来源捕获:提交到一个一次性分支,离开 main,并在实现 issue 上留下指向该分支的上下文指针。同时捕获答案——结论和它解决的问题——写入 issue 或一次提交。main 分支只保留已验证的决策。