cs-feat-design
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecs-feat-design
cs-feat-design
这一阶段的产出是一份方案文件 ,加上从中抽出的行动清单 。这两份东西后面会被两个阶段消费——implement 照着推进、acceptance 照着核对,所以这里写错或写漏,下游就跟着错。
{slug}-design.md{slug}-checklist.yaml共享路径和命名约定看。本阶段一般 feature 目录已经由 brainstorm 创建好了;没有的话在这一步建。codestable/reference/shared-conventions.md
本阶段有三个入口:
- 正式起草:用户已经能讲清楚需求(或已经填好 ),直接进"流程"一节走完整起草。
{slug}-intent.md - 初始化模式:用户说"开一个新需求 / 起个草稿 / 新建一个 feature",但想自己先写半成品方案而不是口述。走下一节"初始化模式",建好目录和空 就结束本轮,等用户填完再回来。
{slug}-intent.md - 从 roadmap 条目起头:用户说"开始做 roadmap 里的 {子 feature slug}"或"推进 {roadmap} 的下一条"。slug 从 roadmap items.yaml 取,不另起;动笔前要读 roadmap 主文档和 items.yaml 了解上下文和依赖状态;落盘时 frontmatter 要带 /
roadmap两个字段,同时回写 items.yaml 把对应条目roadmap_item改为status、in-progress填为 feature 目录名。详见下文"从 roadmap 条目起头"。feature
The output of this phase is a design document , plus an action checklist extracted from it. These two artifacts will be used by the next two phases — implement phase follows it for development, acceptance phase uses it for verification. So any mistakes or omissions here will lead to errors downstream.
{slug}-design.md{slug}-checklist.yamlSeefor shared paths and naming conventions. Generally, the feature directory has already been created by brainstorm phase; if not, create it in this step.codestable/reference/shared-conventions.md
There are three entry points for this phase:
- Formal drafting: The user can clearly explain the requirements (or has already filled out ), directly proceed to the "Workflow" section for complete drafting.
{slug}-intent.md - Initialization mode: The user says "Start a new requirement / Create a draft / Add a new feature", but wants to write a semi-finished design themselves instead of dictating. Proceed to the next section "Initialization mode", create the directory and empty , then end this round. Wait for the user to fill it out before returning.
{slug}-intent.md - Start from roadmap item: The user says "Start working on {sub-feature slug} in the roadmap" or "Move forward with the next item in {roadmap}". The slug is taken from roadmap items.yaml, do not create a new one; before drafting, read the roadmap main document and items.yaml to understand the context and dependency status; when finalizing, add /
roadmaptwo fields to the frontmatter, and update items.yaml to change the corresponding item'sroadmap_itemtostatusand fillin-progresswith the feature directory name. See "Start from roadmap item" below for details.feature
初始化模式:帮用户建目录和 intent 草稿
Initialization mode: Help user create directory and intent draft
触发:用户想自己写一份半成品方案()作为后续 design 的输入,但不想手动建目录。
{slug}-intent.md动作:
-
和用户快速对齐两件事——一句话需求概要 + 敲定 slug(小写字母、数字、连字符;、
user-auth这种)。日期取当天(frontmatter 用export-csv即可)。feature 目录命名是currentDate。YYYY-MM-DD-{slug} -
创建目录。
codestable/features/{YYYY-MM-DD}-{slug}/ -
写一份空的作为草稿骨架,内容就是下面这段:
{slug}-intent.mdmarkdown--- doc_type: feature-intent feature: {YYYY-MM-DD}-{slug} status: draft summary: {一句话需求,AI 按和用户对齐的结果填} --- # {slug} intent ## 背景 / 为什么做 (一句话就够) ## 大致怎么做 (100 字左右描述想法,含关键步骤 / 数据流) ## 相关数据结构 / 类型 (贴相关 types、接口签名、或指向代码位置) ## 已知不做 / 待定 (可选:明确的边界或自己也没想清楚的地方) -
告知用户"骨架已建好,填完后再来找我,我基于 intent 写正式 design",然后本轮结束,不继续推进 design 流程。
为什么在这里停?intent 的价值就是让用户离线思考、把脑子里的东西落到纸面。AI 继续问会把 intent 模式退化成 brainstorm,失去意义。
Trigger: The user wants to write a semi-finished design () as input for subsequent design, but doesn't want to create the directory manually.
{slug}-intent.mdActions:
-
Quickly align two things with the user — one-sentence requirement summary + finalize the slug (lowercase letters, numbers, hyphens; e.g.,,
user-auth). Use the current date (useexport-csvin frontmatter). The feature directory is namedcurrentDate.YYYY-MM-DD-{slug} -
Create the directory.
codestable/features/{YYYY-MM-DD}-{slug}/ -
Write an emptyas a draft skeleton, with the following content:
{slug}-intent.mdmarkdown--- doc_type: feature-intent feature: {YYYY-MM-DD}-{slug} status: draft summary: {One-sentence requirement, filled by AI based on alignment with user} --- # {slug} intent ## Background / Why do this (One sentence is enough) ## Rough implementation plan (Approximately 100 words describing the idea, including key steps / data flow) ## Related data structures / types (Paste related types, interface signatures, or point to code locations) ## Known scope exclusions / pending items (Optional: Clear boundaries or areas you haven't figured out yet) -
Inform the user "The skeleton has been created. Come back to me after filling it out, and I'll write the formal design based on the intent", then end this round and do not proceed with the design workflow.
Why stop here? The value of intent is to let the user think offline and put their thoughts on paper. If AI continues to ask, it will degrade the intent mode into brainstorm, losing its meaning.
从 roadmap 条目起头
Start from roadmap item
触发:用户说"开始做 roadmap 里的 {子 feature slug}"、"推进 {roadmap-slug} 的下一条",或指向 里某条 条目。
codestable/roadmap/{roadmap-slug}/{roadmap-slug}-items.yamlplanned动作:
- 读 roadmap 上下文——打开 和
{roadmap-slug}-roadmap.md:{roadmap-slug}-items.yaml- 目标条目 必须是
status——是planned说明 design 已经在做(回去续作);是in-progress/done停下来问用户dropped - 目标条目的 里的前置条目必须全部
depends_on——有done/planned的说明顺序错了,停下来告诉用户"前置 {X} 还没完成,建议先做它,或者确认要不要调整 roadmap 顺序"in-progress - 读主文档里这条的"备注"和整体"排期思路",理解它在大需求里的定位
- 目标条目
- slug 从 roadmap 取——feature 目录命名 ,日期用当天。不要另起 slug,否则 items.yaml 和 feature 对不上
YYYY-MM-DD-{roadmap 条目的 slug} - 建 feature 目录,照常走"流程"一节
- design frontmatter 额外带两个字段:
yaml
roadmap: {roadmap-slug} roadmap_item: {子 feature slug} - 落盘 design 的同时,回写 items.yaml:
status: approved- 找到 的条目
slug: {roadmap_item} - →
status: plannedin-progress - →
feature: null(feature 目录名)feature: YYYY-MM-DD-{slug} - 用 校验
python codestable/tools/validate-yaml.py --file {path} --yaml-only
- 找到
- 汇报:告诉用户 roadmap 已回写,下一步进 implement 阶段
完整衔接协议看 第 2.5 节。
codestable/reference/shared-conventions.mdTrigger: The user says "Start working on {sub-feature slug} in the roadmap", "Move forward with the next item in {roadmap-slug}", or points to a item in .
plannedcodestable/roadmap/{roadmap-slug}/{roadmap-slug}-items.yamlActions:
- Read roadmap context — Open and
{roadmap-slug}-roadmap.md:{roadmap-slug}-items.yaml- The target item's must be
status— if it'splanned, the design is already underway (continue the existing work); if it'sin-progress/done, stop and ask the user.dropped - All prerequisite items in the target item's must be
depends_on— if any aredone/planned, the order is wrong. Stop and tell the user "Prerequisite {X} is not completed yet. It is recommended to finish it first, or confirm whether to adjust the roadmap order".in-progress - Read the "Notes" of this item in the main document and the overall "Scheduling ideas" to understand its position in the large requirement.
- The target item's
- Take the slug from the roadmap — The feature directory is named , using the current date. Do not create a new slug, otherwise items.yaml and the feature will not match.
YYYY-MM-DD-{slug of the roadmap item} - Create the feature directory and proceed to the "Workflow" section as usual.
- Add two additional fields to the design frontmatter:
yaml
roadmap: {roadmap-slug} roadmap_item: {sub-feature slug} - When finalizing the design with , update items.yaml:
status: approved- Find the item with .
slug: {roadmap_item} - Change →
status: planned.in-progress - Change →
feature: null(feature directory name).feature: YYYY-MM-DD-{slug} - Validate with .
python codestable/tools/validate-yaml.py --file {path} --yaml-only
- Find the item with
- Report: Inform the user that the roadmap has been updated, and the next step is the implement phase.
See Section 2.5 of for the complete handover protocol.
codestable/reference/shared-conventions.mddesign 写什么、不写什么
What to include and exclude in the design
design 只管一件事:把这次 feature 里"拍错了事后补救很贵"的那部分定死。项目代码可能有 1 万行,其中逻辑层(编排 + 实体)也就 100 行——design 覆盖的是这 100 行那一侧,剩下的实现细节交给 implement 自己决定。
具体写三类东西:
- 名词——新增 / 变化的实体、数据结构、对外契约、类型定义。这是 implement 和 acceptance 共用的语言,漏了就对不上话。
- 动词骨架——关键编排、主流程、推进步骤、关键分支。不是伪代码,是"这件事按什么顺序、经过哪几步发生"。
- 跨层纪律——那些看起来像实现细节、拍错了却只能靠人肉 review 才能发现的约束:错误语义(失败是回滚还是重试、对外返回什么)、幂等性、并发 / 顺序、扩展点位置、可观测点。挂载点清单另见下文第 3 条"每个 feature 都要能被卸载"——它是这一类在 feature 维度的具体落地形式。
不写:循环怎么写、辅助函数怎么拆、捕获异常的代码、日志格式、缩进风格、非关键的库选型。这些归 implement 自己拍板——拍错了 acceptance 的测试能抓出来,不用在 design 里占篇幅。涉及长期架构约束或对外契约的库选型仍属关键决策,要写进第 1 节。
判据:一段内容如果 implement 拍错了 acceptance 能通过测试抓出来,就不用写进 design;如果拍错了 acceptance 只能靠人肉 review 才能发现,就必须写进 design。
The design only focuses on one thing: Lock down the parts of this feature that would be very expensive to fix if decided incorrectly. The project code may have 10,000 lines, but the logic layer (orchestration + entities) is only about 100 lines — the design covers this 100-line side, leaving the remaining implementation details to the implement phase.
Specifically, include three types of content:
- Nouns — New/changed entities, data structures, external contracts, type definitions. This is the shared language for implement and acceptance phases; omitting them will lead to misalignment.
- Verb skeleton — Key orchestration, main workflow, progress steps, critical branches. Not pseudocode, but "what order this thing happens in, which steps it goes through".
- Cross-layer disciplines — Constraints that seem like implementation details but can only be found through manual review if decided incorrectly: error semantics (rollback or retry on failure, what to return externally), idempotency, concurrency/order, extension point locations, observability points. See the third item below "Every feature must be uninstallable" for the specific implementation of this category at the feature level.
Exclude: How to write loops, how to split helper functions, exception-catching code, log formats, indentation styles, non-critical library selections. These are decided by the implement phase — if decided incorrectly, acceptance tests can catch them, so they don't need to take up space in the design. Library selections involving long-term architectural constraints or external contracts are still critical decisions and should be included in Section 1.
Criteria: If a piece of content can be caught by acceptance tests if implemented incorrectly, it does not need to be included in the design; if it can only be found through manual review if implemented incorrectly, it must be included in the design.
方案文件是给人扫的,不是给人读的
The design document is for scanning, not reading
整个 design 的写作风格都围绕这个原则。读者打开 是想 5 分钟内抓到要点,需要细节时知道去哪查——不是要逐字精读。这条原则推出几条具体做法:
{slug}-design.md- 每节超过 1 屏就该砍或拆。一屏装不下意味着读者会失去定位感。
- 术语先锁死。所有新增术语在动笔前做一遍 grep,覆盖代码、架构中心目录、所有 feature 的方案文件。术语冲突的代价是后面别人查代码找错地方——预防的成本远低于事后理顺的成本。
- 示例优先于定义。接口行为先用具体示例(API 用输入→输出,组件用 Props→渲染 / Events 示例),复杂时再补正式类型。读者看到具体输入输出比看一段抽象描述更快建立模型。
- 推进按"功能可见度"走,不按代码文件顺序。先做最小闭环(一条端到端能跑通的路径),再叠细节。这样每一步都能独立验证,途中发现走偏也只损失一步。
- 新逻辑默认放新文件。新增的内聚逻辑单元默认建独立文件,而不是往已有文件追加。改动计划里每条都标"新建文件"或"追加到已有文件(理由)"。原因是文件越大越难分清职责,往老文件加东西会让后人查 git blame 时把不相关的改动也读一遍。
- 同一条信息只在最自然的位置出现一次。重复表述会让读者反复确认"这两条是不是同一件事",比缺一条还烦。
- 流程归流程,模板归模板。先按下文流程走完再按模板填内容,不要边写边切流程。
The entire writing style of the design revolves around this principle. Readers open to grasp the key points within 5 minutes, and know where to look for details when needed — not to read every word carefully. This principle leads to several specific practices:
{slug}-design.md- Cut or split any section that exceeds one screen. If it can't fit on one screen, readers will lose their sense of orientation.
- Lock down terms first. Run a grep for all new terms before drafting, covering code, architecture central directory, and design documents of all features. The cost of term conflicts is that others will look in the wrong place when checking code — the cost of prevention is far lower than the cost of sorting it out afterwards.
- Examples take precedence over definitions. First use specific examples for interface behavior (input→output for APIs, Props→rendering/Events examples for components), then supplement with formal types if complex. Readers can build a model faster by seeing specific input and output than by reading an abstract description.
- Progress by "feature visibility", not by code file order. First build the minimal closed loop (an end-to-end runnable path), then add details. This way, each step can be independently verified, and if a deviation is found along the way, only one step is lost.
- New logic is placed in new files by default. New cohesive logic units are placed in independent files by default, instead of appending to existing files. Each item in the change plan is marked as "Create new file" or "Append to existing file (reason)". The reason is that larger files make it harder to distinguish responsibilities, and adding things to old files will make future developers read irrelevant changes when checking git blame.
- The same information appears only once in the most natural location. Repetitive statements will make readers repeatedly confirm "Are these two the same thing?", which is more annoying than missing one.
- Workflow first, template second. Complete the workflow below first, then fill in the content according to the template. Don't switch workflows while writing.
起草时的两条判断纪律
Two judgment disciplines during drafting
写作风格之外还有两条更前置的纪律,决定了这份方案能不能真撑得起 implement / acceptance——不是看起来像方案、实际全是模糊承诺。
In addition to writing style, there are two more fundamental disciplines that determine whether this design can truly support implement/acceptance — not just looking like a design but actually being full of vague commitments.
1. 别替用户做决定,把不确定明着写出来
1. Don't make decisions for the user; explicitly state uncertainties
写方案时碰到"用户没说清的角落",默认动作是停下来问,不是自己挑一个填上去。具体落在几件事上:
- 声明假设:每条不是用户原话讲过的判断(输入边界、错误处理、边角行为)都写成"假设:……",让用户能精确反驳。
- 给选项不要自选:发现一个点有 2-3 种合理做法,先把候选都摆出来再讲自己的倾向,让用户在 review 时能换。
- 顺手提一句更简的可能:用户给的方向看起来能用更轻的方式达到同样目标时,明着说"还有一种更简的做法是 ……,要不要先排除它"。别因为用户已经说了方向就闭嘴。
- 看不懂就停下来:碰到自己也没把握理解对的需求,直接说"这一段我没把握",不要硬猜着写下去。
代价很具体:偷偷做的决定到了 implement 会变成"AI 自作主张引入的特殊逻辑",到了 acceptance 阶段对不上验收点。design 是把所有"以为大家都懂"的事翻到台面上的最后一道关。
When encountering "unclear corners that the user didn't explain" while writing the design, the default action is to stop and ask, not to pick one and fill it in yourself. Specifically, this applies to several things:
- State assumptions: Every judgment that is not directly stated by the user (input boundaries, error handling, edge behaviors) is written as "Assumption: ...", allowing the user to refute it precisely.
- Provide options instead of choosing yourself: If there are 2-3 reasonable approaches for a point, first list all candidates and then explain your preference, allowing the user to switch during review.
- Mention simpler alternatives: When the user's direction seems to achieve the same goal in a lighter way, explicitly say "There is a simpler approach: ..., should we rule it out first?". Don't stay silent just because the user has already stated the direction.
- Stop if you don't understand: If you are not sure you understand the requirement correctly, directly say "I'm not sure about this section", don't guess and continue writing.
The cost is concrete: Decisions made secretly will become "special logic introduced by AI on its own" during implementation, and will not match the acceptance criteria during the acceptance phase. Design is the last checkpoint to bring all "things everyone thinks they understand" to the surface.
2. 目标和约束都写成可验证的
2. Write both goals and constraints in verifiable terms
design 的产出要被 implement 照着推进、被 acceptance 照着核对——所以方案里每一条目标和约束都得能独立验证:
- 不写"让它能跑"这种弱标准。"完成 X 功能" / "处理好错误" / "用户体验顺畅"这类话本质上是把验证责任推回下游。改写成"输入 A 时返回 B"、"错误 X 时显示提示 Y"。
- 每一步推进顺序都带退出信号。光写"实现 XX"不够,要写"完成后能通过 {具体测试 / 操作步骤}"。
- "明确不做"也要可验证。"不做 XX"要具体到能被 grep 或测试反向核对,不能写成"不过度设计"这种空话。
退出条件里"每步可独立验证"、"测试设计按功能点组织"就是这条纪律落实下来的检查项——这两节写虚了,等于这条纪律没落地。
The output of the design will be followed by the implement phase and checked by the acceptance phase — so every goal and constraint in the design must be independently verifiable:
- Don't use weak standards like "Make it work". Phrases like "Complete X function" / "Handle errors properly" / "Smooth user experience" essentially push the verification responsibility downstream. Rewrite them as "Return B when input is A" / "Display prompt Y when error X occurs".
- Every progress step has an exit signal. Just writing "Implement XX" is not enough; write "After completion, it can pass {specific test / operation steps}".
- "Explicitly not doing" must also be verifiable. "Not doing XX" must be specific enough to be checked reversely via grep or tests, not empty phrases like "Avoid over-design".
The check items "Each step is independently verifiable" and "Test design is organized by feature points" in the exit conditions are the implementation of this discipline — if these sections are written vaguely, it means this discipline has not been implemented.
3. 每个 feature 都要能被卸载
3. Every feature must be uninstallable
一个 feature 从加进项目的第一天就得回答一个问题:如果后面想把它拔掉,要拔哪些地方?不能回答清楚,就说明它和现有代码的边界没想明白——这种 feature 一旦上线,就变成"拆不动的既成事实",哪怕没人再用也只能留着。
落到 design 上是一件具体的事:在第 1 节"决策与约束"里列一份挂载点清单,逐条列出本 feature 往项目哪些位置挂入——新增 / 修改的路由、模块导入、配置项、数据库字段和表、定时任务、事件订阅、公共 UI 注入点、特性开关等。每条要具体到文件或配置 key,粒度达到"照这份清单逆向可以完整拔除"。
这份清单还顺带起两个作用:一是帮你在 design 阶段就发现自己不小心往太多地方插桩了(挂载点越多代表耦合越散,是个信号);二是 implement 阶段改动计划每条都能对上一个挂载点,漏了就知道少做了事。
看得见挂载点不等于一定要支持动态开关——大多数 feature 不需要 feature flag,但每个 feature 都要能被人工有序地逆向移除,这是底线。
From the first day a feature is added to the project, it must answer one question: If we want to remove it later, which parts need to be removed? If this cannot be clearly answered, it means the boundary between it and existing code has not been thought through — once such a feature goes online, it becomes an "immovable fact" that can only be kept even if no one uses it anymore.
In terms of design, this is a specific task: List a mount point checklist in Section 1 "Decisions and Constraints", listing where this feature is mounted into the project — new/modified routes, module imports, configuration items, database fields and tables, scheduled tasks, event subscriptions, public UI injection points, feature flags, etc. Each item must be specific to a file or configuration key, with granularity sufficient for the acceptance phase to verify complete removal reversely according to this checklist.
This checklist also serves two additional purposes: First, it helps you discover during the design phase that you have accidentally inserted too many stakes (more mount points mean more scattered coupling, which is a signal); second, each item in the change plan during the implement phase can be mapped to a mount point, so you know if you have missed something.
Visible mount points do not mean dynamic switching must be supported — most features do not need feature flags, but every feature must be able to be manually and orderly removed, which is the bottom line.
流程:什么时候做什么
Workflow: What to do when
1. 启动检查
1. Startup check
动笔前先过这些。结构是前置 gate + 必做 4 条 + 按信号触发的 4 条——把"每次都要做"和"看情况才做"分开,避免启动阶段变成 12 步仪式。
Go through these before drafting. The structure is Pre-gate + 4 mandatory items + 4 signal-triggered items — separating "things to do every time" and "things to do only when needed" to avoid the startup phase becoming a 12-step ritual.
前置 gate:需求输入清晰吗
Pre-gate: Is the requirement input clear?
确认至少有用户目标、核心行为、成功标准、明确不做这四项(来源可以是 intent / brainstorm / 对话任意来源汇总)。缺了先补;用户自己也说不清就回退到 brainstorm。
Confirm at least these four items are present (source can be intent / brainstorm / conversation summary): User goals, core behaviors, success criteria, explicit scope exclusions. If any are missing, supplement them first; if the user can't explain clearly, roll back to brainstorm phase.
必做 4 条
4 mandatory items
- 续作检查——Glob /
codestable/features/{feature}/{slug}-design.md/{slug}-intent.md:{slug}-brainstorm.md- 有 :当作用户方案输入读入,不再重复问已讲清的部分,只追问没覆盖的角落
{slug}-intent.md - 有 :当作对话沉淀输入读入
{slug}-brainstorm.md - design 文件不存在、或只有空模板 / frontmatter → 当新建处理
- design 且各节基本完整 → 上次写完没 review,跳到本流程"5. 整体 review"
status=draft - design 部分节缺失 → 只补缺失节,汇报"上次写到第 X 节,补齐剩下的统一给你 review"
- design → 不要默默覆盖,问用户接着改还是另起 slug
status=approved
- 有
- 读 architecture——架构总入口 + 索引 + 与需求相关的子系统架构 doc。重点看已有的名词(能不能复用 / 会不会冲突)和跨层纪律(本 feature 要遵守什么)。不读直接动手大概率写出脱离实际的方案。
codestable/architecture/DESIGN.md - 对齐 requirement——到 Glob + grep:
codestable/requirements/- 已有对应 req:slug 记进方案 frontmatter 的 字段;动笔前读一遍 req 的"用户故事"和"边界"两节,方案不能冲突
requirement - 没有对应 req,但本 feature 新增 / 改变用户可感能力:停下来,提示用户先触发 起草或更新 req
cs-req - 纯内部重构 / 技术债 / 工具链:frontmatter 留空,第 1 节写"本 feature 不新增能力,无对应 requirement"
requirement
- 已有对应 req:slug 记进方案 frontmatter 的
- 读需求相关的现有代码——具体读哪些文件由需求线索决定。这是方案能和现有代码接得上的前提。
- Continuation check — Glob /
codestable/features/{feature}/{slug}-design.md/{slug}-intent.md:{slug}-brainstorm.md- If exists: Treat it as the user's design input, do not repeat questions about already clarified parts, only follow up on uncovered areas.
{slug}-intent.md - If exists: Treat it as conversation input.
{slug}-brainstorm.md - If the design file does not exist, or only has an empty template / frontmatter → Treat as new creation.
- If design and each section is basically complete → Last time it was written but not reviewed, jump to "5. Overall review" in this workflow.
status=draft - If some sections of the design are missing → Only supplement the missing sections, report "Last time we wrote up to Section X, we'll complete the rest and send you a unified review".
- If design → Do not overwrite silently, ask the user whether to continue modifying or create a new slug.
status=approved
- If
- Read architecture — Architecture main entry + index + subsystem architecture docs related to the requirement. Focus on existing nouns (can they be reused / will there be conflicts) and cross-layer disciplines (what this feature must comply with). Writing without reading will most likely result in a design that is disconnected from reality.
codestable/architecture/DESIGN.md - Align requirement — Glob + grep in :
codestable/requirements/- If a corresponding req exists: Record the slug in the field of the design frontmatter; read the "User story" and "Boundaries" sections of the req before drafting, the design must not conflict.
requirement - If no corresponding req exists, but this feature adds/changes user-perceivable capabilities: Stop, prompt the user to trigger to draft or update the req.
cs-req - For pure internal refactoring / technical debt / toolchain: Leave the field in frontmatter empty, write in Section 1 "This feature does not add new capabilities, no corresponding requirement".
requirement
- If a corresponding req exists: Record the slug in the
- Read existing code related to the requirement — Specific files to read are determined by requirement clues. This is the prerequisite for the design to connect with existing code.
按信号触发 4 条
4 signal-triggered items
下面 4 件事默认会被偷懒跳过,又不是每次都必要。有信号才做,没信号跳过——硬塞进必做会让小 feature 启动阶段变仪式。
- 术语 grep 防冲突
- 触发:本 feature 要引入的关键概念名看起来没在代码 / 架构 / 历史 feature 里见过
- 动作:grep 覆盖代码 + + 所有 feature 方案文件。冲突了换名,或在第 0 节明确"本文里 X 指 Y,和代码里的 X' 不是一回事"
codestable/architecture/
- 复杂度档位对齐
- 触发:需求里出现可能偏离默认档位的信号——"对外 SDK"(可读性从 team 升到 public)、"高并发 / 低延迟"(性能从 reasonable 升到 budgeted)、"纯探索脚本 / 一次性工具"(健壮性从 L2 降到 L1)
- 动作:打开 ,按场景匹配默认组合,把偏离点和理由列给用户确认。确认后写进第 1 节"复杂度档位"子节,只记偏离默认的维度
codestable/reference/code-dimensions.md - 无信号:第 1 节写一句"本 feature 走 {场景} 默认档位,无偏离",不必打开档位表
- grep 找"叫法不同的类似模块"
- 触发:直觉本 feature "可能已经有人做过但命名不同"——常见于通用工具、抽象能力、跨模块功能
- 动作:grep 几个同义词找候选模块,确认要不要扩展已有实现而不是另起一份
- 归档检索
- 触发:关键词明显像以前沉淀过的东西(某决策、某坑、某探索结论、某历史 feature)
- 动作:先一把搜 ,命中后按
python codestable/tools/search-yaml.py --dir codestable/compound --query "{关键词}"过滤细看;历史 feature 同理——doc_type=decision/trick/learning/explorepython codestable/tools/search-yaml.py --dir codestable/features --filter doc_type=feature-design --query "{关键词}" - 命中后优先复用,方案文件里记下引用来源
详细规则看 第 5 节。
codestable/reference/shared-conventions.mdThe following 4 things are usually skipped due to laziness, and are not necessary every time. Do them only when there is a signal; skip if no signal — forcing them into mandatory items will turn the startup phase of small features into a ritual.
- Grep terms to prevent conflicts
- Trigger: The key concept name to be introduced by this feature does not seem to exist in code / architecture / historical features.
- Action: Grep covers code + + design documents of all features. If there is a conflict, change the name, or explicitly state in Section 0 "In this document, X refers to Y, which is not the same as X' in the code".
codestable/architecture/
- Align complexity tiers
- Trigger: Signals in the requirement that may deviate from the default tier — "External SDK" (readability rises from team to public), "High concurrency / low latency" (performance rises from reasonable to budgeted), "Pure exploration script / one-time tool" (robustness drops from L2 to L1).
- Action: Open , match the default combination according to the scenario, list the deviation points and reasons for user confirmation. After confirmation, write into the "Complexity tiers" subsection of Section 1, only record dimensions that deviate from the default.
codestable/reference/code-dimensions.md - No signal: Write one sentence in Section 1 "This feature follows the default tier for {scenario}, no deviations", no need to open the tier table.
- Grep for "similar modules with different names"
- Trigger: Intuition that this feature "may have been done before but with a different name" — common in general tools, abstract capabilities, cross-module functions.
- Action: Grep several synonyms to find candidate modules, confirm whether to extend the existing implementation instead of creating a new one.
- Archive retrieval
- Trigger: Keywords clearly look like something that has been documented before (a decision, a pitfall, an exploration conclusion, a historical feature).
- Action: First run , then filter and read carefully by
python codestable/tools/search-yaml.py --dir codestable/compound --query "{keyword}"; do the same for historical features —doc_type=decision/trick/learning/explore.python codestable/tools/search-yaml.py --dir codestable/features --filter doc_type=feature-design --query "{keyword}" - If hit, prioritize reuse, record the reference source in the design document.
See Section 5 of for detailed rules.
codestable/reference/shared-conventions.md2. 想清楚这功能该放在哪儿
2. Figure out where this feature should be placed
动笔写改动计划前,先想清楚一个更根本的问题:这次要加的东西,在项目整体结构里属于哪儿?
具体问几件事:
- 这件事是某个现有模块本该承担的吗?是的话在那个模块里扩展,别在外面另起一份。
- 这件事横跨多个模块——是不是该抽出一层公共的东西放在中间,还是让某一方主导、其他方依赖它?
- 这件事和现有任何模块都不太像?那可能要新建一个独立模块 / 子系统——新模块放哪儿、对外暴露什么、跟别人怎么交互,得提前想清楚。
- 已经有模块在做类似的事但名字不一样、你没注意到?grep 项目一下,别因为叫法不同就重复造轮子。
错的放置方式代价很具体:放进本不该承担这件事的模块,那个模块慢慢变成"什么都装的筐",职责越来越糊;每次都新建平行实现,几个版本的同一件事在项目里共存,后人维护时得猜用哪个。
结论写进方案文件第 1 节"决策与约束"——至少明确一句"本 feature 放在 {模块/层} 里,原因是 {简述}"。涉及新建模块或跨模块接口时,同步写进第 4 节"与项目级架构文档的关系",并提示要在架构总入口 里加指向。
DESIGN.mdAI 在这一步默认会翻的车是不思考就往眼前最顺手的文件里加——绕过这步直接进步骤 3 就会掉进去。
Before writing the change plan, first think about a more fundamental question: Where does the thing we are adding belong in the overall project structure?
Specifically, ask several questions:
- Is this something that an existing module should be responsible for? If yes, extend that module, don't create a new one outside.
- Does this span multiple modules — should we extract a common layer and place it in the middle, or let one party lead and others depend on it?
- Does this not fit well with any existing module? Then we may need to create a new independent module / subsystem — we need to figure out in advance where to place the new module, what to expose externally, and how to interact with others.
- Is there already a module doing similar things but with a different name that you didn't notice? Grep the project, don't reinvent the wheel just because of different naming.
The cost of wrong placement is concrete: Putting it in a module that shouldn't be responsible for it will make that module gradually become a "basket for everything", with increasingly vague responsibilities; creating parallel implementations every time will result in multiple versions of the same thing coexisting in the project, making future maintenance require guessing which one to use.
Write the conclusion into Section 1 "Decisions and Constraints" of the design document — at least clearly state "This feature is placed in {module/layer}, because {brief reason}". When involving new modules or cross-module interfaces, simultaneously write into Section 4 "Relationship with project-level architecture documents", and prompt to add a link to the architecture main entry .
DESIGN.mdThe default mistake AI will make in this step is adding it to the most convenient file in front without thinking — skipping this step and directly entering Step 3 will lead to this mistake.
3. 扫一眼要改的文件现在什么状况
3. Check the current state of the files to be modified
步骤 2 想清楚了放在哪个模块,动手写改动计划前再下沉一层,看这个文件(或类)现在的状态——能不能干净地接住新代码?
看几个维度:
- 这个文件现在多长?承担了几件事?新加的东西是已有职责的延伸,还是第 N+1 件事?
- 这个类有多少方法?新加的方法是同一个职责的自然扩展,还是把这个类推向"什么都能干"?
- 涉及前端时还要看组件树层级是不是过深、状态归属是不是清晰(本地 state / props 传递 / 全局 store)。
按严重程度分流:
| 情况 | 处理 |
|---|---|
| 状态健康,直接加 | 正常推进,不用额外动作 |
| 该先收拾一下(把一个太长的文件拆成几个、把一个太重的函数抽出来) | 纳入第 3 节"实现提示"里推进顺序子节的第 1 步,范围锁死为"只搬不改行为",退出信号是"搬完后既有功能不变" |
| 结构性问题(职责需要重划、模块需要拆合、接口需要重设计) | 在第 1 节记为前置依赖,建议拆成独立 feature 先解决;当前 feature 暂缓或标"等前置完成后再推进" |
为什么要做这一步?硬塞功能进一个本来就长得不干净的文件,得到的是一个更长更不干净的文件,下一次改动就更难。提前把"该不该先收拾一下"放到台面上,让用户做决定,而不是 AI 偷偷在 PR 里夹带。
结论写进方案文件第 3 节"实现提示"里改动计划子节开头(具体格式见同目录 )。"健康,直接加"的情况不用写——只在有动作时才记。
reference.mdAfter figuring out which module to place it in Step 2, before writing the change plan, go one level deeper to see the current state of this file (or class) — can it cleanly accept the new code?
Look at several dimensions:
- How long is this file now? How many responsibilities does it take on? Is the new content an extension of existing responsibilities, or the N+1th thing?
- How many methods does this class have? Is the new method a natural extension of the same responsibility, or does it push this class towards "can do everything"?
- For frontend-related content, also check if the component tree hierarchy is too deep, and if the state ownership is clear (local state / props passing / global store).
Divert according to severity:
| Situation | Handling |
|---|---|
| Healthy state, can add directly | Proceed normally, no additional actions |
| Should clean up first (split a too-long file into several, extract a too-heavy function) | Include it as Step 1 in the "Progress order" subsection of Section 3 "Implementation hints", lock the scope to "Only move without changing behavior", the exit signal is "Existing functions remain unchanged after moving" |
| Structural issues (responsibilities need to be redefined, modules need to be split/merged, interfaces need to be redesigned) | Record it as a prerequisite dependency in Section 1, suggest splitting into an independent feature to solve first; the current feature is suspended or marked "Proceed after prerequisites are completed" |
Why do this step? Forcing features into already messy files will result in even messier files, making the next change even harder. Putting "Should we clean up first" on the table in advance allows the user to make the decision, instead of AI secretly including it in the PR.
Write the conclusion at the beginning of the "Change plan" subsection in Section 3 "Implementation hints" of the design document (see in the same directory for specific format). No need to write for "Healthy, add directly" — only record when there are actions.
reference.md4. 补齐剩下各节,整稿一次性给 review
4. Complete the remaining sections, submit the full draft for review at once
步骤 2 和 3 已经把第 1 节"决策与约束"、第 3 节"实现提示"的关键结论先写进文件了。这一步把剩下的节(第 0 / 2 / 4 节,以及第 1 / 3 节里步骤 2/3 没覆盖的部分)按下文模板补齐,整稿成型后再交给用户看,不要分批让用户看半成品。初稿的 YAML frontmatter 里 写 。
statusdraft注意"一次性"是指给用户的 review 次数,不是指写文件的次数——文件本身可以分几轮写完,但只在整稿都齐了之后才发出去。
为什么不分批 review?分批的问题是用户每次只看到局部,发现不了"第 1 节的范围跟第 3 节的推进步骤对不上"这种跨节问题。只有完整初稿摆出来,用户才能扫到全局一致性。
Step 2 and 3 have already written the key conclusions of Section 1 "Decisions and Constraints" and Section 3 "Implementation hints" into the document. In this step, complete the remaining sections (Sections 0 / 2 / 4, and parts of Sections 1 / 3 not covered in Steps 2/3) according to the template below, submit the full draft to the user only after it is complete, do not let the user review semi-finished products in batches. Set to in the YAML frontmatter of the first draft.
statusdraftNote that "at once" refers to the number of review times for the user, not the number of times to write the file — the file itself can be written in several rounds, but only sent out after the full draft is complete.
Why not review in batches? The problem with batches is that the user only sees parts each time, and cannot find cross-section issues like "The scope in Section 1 does not match the progress steps in Section 3". Only when the complete first draft is presented can the user scan for global consistency.
5. 整体 review
5. Overall review
向用户发一次整体 review 提示。用户对任意部分提修改意见,你按意见改完再次确认,反复直到用户明确"方案可以了"。用户放行后把 frontmatter 的 从 改成 。
statusdraftapprovedSend one overall review prompt to the user. If the user provides modification suggestions for any part, revise according to the suggestions and confirm again, repeating until the user explicitly says "The design is okay". After the user approves, change the in the frontmatter from to .
statusdraftapproved6. 生成 {slug}-checklist.yaml
6. Generate {slug}-checklist.yaml
方案确认后,从 里抽出行动清单,落到同目录 。这份清单的生命周期看 :本阶段负责生成,implement 只推进 ,acceptance 只核对 。三个阶段各管一段,互不越界——这样每个阶段都能从 yaml 上看出自己的工作进度。
{slug}-design.md{slug}-checklist.yamlcodestable/reference/shared-conventions.mdstepschecks{slug}-design.md{slug}-checklist.yamlreference.md- :从第 3 节"实现提示"里推进顺序子节逐步抽,一步一条
steps - :从这几处综合抽——
checks- 第 1 节"明确不做"的每条 → 范围守护检查项
- 第 1 节"挂载点清单"每条 → 可卸载性检查项(,acceptance 阶段据此反向核对"照清单能否完整拔除")
source: 挂载点 - 第 2 节关键接口契约 → 接口一致性检查项
- 第 3 节"实现提示"里测试设计子节的每条测试约束 → 测试验证检查项
落盘后用 校验语法。
validate-yaml.py --file {slug-checklist.yaml 路径} --yaml-onlyAfter the design is confirmed, extract the action checklist from and save it as in the same directory. See for the lifecycle of this checklist: This phase is responsible for generating it, the implement phase only progresses , the acceptance phase only checks . Each of the three phases manages its own part, without crossing boundaries — this way, each phase can see its work progress from the yaml.
{slug}-design.md{slug}-checklist.yamlcodestable/reference/shared-conventions.mdstepschecksThe complete templates, frontmatter examples, section anchors, and extraction formats for and are in in the same directory. This skill only retains the extraction principles:
{slug}-design.md{slug}-checklist.yamlreference.md- : Extract step by step from the "Progress order" subsection of Section 3 "Implementation hints", one step per entry.
steps - : Extract comprehensively from these places —
checks- Each item in Section 1 "Explicit scope exclusions" → Scope guard check items.
- Each item in Section 1 "Mount point checklist" → Uninstallability check items (, the acceptance phase uses this to verify reversely "Can it be completely removed according to the checklist").
source: mount point - Key interface contracts in Section 2 → Interface consistency check items.
- Each test constraint in the "Test design" subsection of Section 3 "Implementation hints" → Test verification check items.
After saving, validate the syntax with .
validate-yaml.py --file {path to slug-checklist.yaml} --yaml-only7. 退出
7. Exit
按下文退出条件清单核对完,引导用户进入阶段 2 实现。
After checking against the exit condition list below, guide the user to enter Phase 2 (implementation).
模板和格式
Templates and formats
{slug}-design.md{slug}-checklist.yamlreference.md- YAML frontmatter 示例
- 顶层节锚点要求
- 完整格式与状态语义
{slug}-checklist.yaml - 第 0-4 节各自该写什么
本技能只保留流程层面的约束:按那份参考一次性起草完整初稿,不分批吐半成品。
整体 review 的提示词同样在 。规则不变:只发一次整体 review,不要逐节拆开确认。
reference.mdThe complete references for / are split into in the same directory:
{slug}-design.md{slug}-checklist.yamlreference.md- YAML frontmatter examples
- Top-level section anchor requirements
- Complete format and status semantics of
{slug}-checklist.yaml - What each section 0-4 should include
This skill only retains workflow-level constraints: Draft the complete first draft at once according to that reference, do not output semi-finished products in batches.
The prompt for overall review is also in . The rule remains: Send only one overall review, do not confirm section by section.
reference.md退出条件
Exit conditions
用户整体 review 通过,并且下面这些都满足:
- 做过术语 grep 防冲突并记录结果
- 已对齐复杂度档位:偏离默认的维度已记入第 1 节"复杂度档位"子节,或明确确认全部走默认
- 已对齐 requirement:要么 frontmatter 的 填了对应 slug,要么方案里明确写了"本 feature 不新增能力,无对应 requirement"
requirement - YAML frontmatter 存在,/
doc_type/feature/status/summary都填了tags - 需求摘要含"不做什么",且后文没有偷偷扩范围
- 挂载点清单已列齐:每条具体到文件或配置 key,粒度够 acceptance 阶段照此反向核对可拔除
- 记录了关键决策和被拒方案
- 每个关键接口有具体示例(API:输入→输出;组件:Props→渲染 / Events),覆盖正常路径和主要错误路径
- 示例通过注释标了来源位置(文件路径 + 函数 / 组件名)
- 推进步骤 4-8 步,每步可独立验证
- 测试设计按功能点组织,每个功能点都有测试约束 / 验证方式 / 关键用例骨架
- 记录了高风险实现约束
- 用户确认通过后,frontmatter 的 改成了
statusapproved - 已从
{slug}-checklist.yaml抽出生成,且通过{slug}-design.md校验validate-yaml.py - 的 steps 条目数和第 3 节"实现提示"里推进顺序子节一致
{slug}-checklist.yaml - 如果本 feature 从 roadmap 条目起头:frontmatter 带 /
roadmap字段;roadmap_item里对应条目codestable/roadmap/{roadmap}/{roadmap}-items.yaml已改为status、in-progress已填为 feature 目录名,且 yaml 已通过feature校验validate-yaml.py
文件路径:方案文件在 下;feature 目录不存在就在这一步建。命名约定看 第 0 节。
codestable/features/{feature}/codestable/reference/shared-conventions.mdThe user has approved the overall review, and all of the following are satisfied:
- Term grep for conflict prevention has been done and results recorded
- Complexity tiers have been aligned: Deviated dimensions have been recorded in the "Complexity tiers" subsection of Section 1, or it has been explicitly confirmed that all follow the default
- Requirements have been aligned: Either the field in frontmatter is filled with the corresponding slug, or the design explicitly states "This feature does not add new capabilities, no corresponding requirement"
requirement - YAML frontmatter exists, and /
doc_type/feature/status/summaryare all filledtags - The requirement summary includes "what not to do", and there is no secret scope expansion later
- The mount point checklist is complete: Each item is specific to a file or configuration key, with sufficient granularity for the acceptance phase to verify uninstallability reversely
- Key decisions and rejected solutions have been recorded
- Each key interface has specific examples (API: input→output; component: Props→rendering/Events), covering normal paths and main error paths
- Examples are marked with source locations (file path + function/component name) via comments
- Progress steps are 4-8 steps, each can be independently verified
- Test design is organized by feature points, each feature point has test constraints / verification methods / key use case skeleton
- High-risk implementation constraints have been recorded
- After user confirmation, the in frontmatter has been changed to
statusapproved - has been extracted from
{slug}-checklist.yamland validated with{slug}-design.mdvalidate-yaml.py - The number of steps entries in matches the "Progress order" subsection of Section 3 "Implementation hints"
{slug}-checklist.yaml - If this feature starts from a roadmap item: Frontmatter includes /
roadmapfields; the corresponding item inroadmap_itemhas been updated tocodestable/roadmap/{roadmap}/{roadmap}-items.yaml,status: in-progressfilled with the feature directory name, and the yaml has been validated withfeaturevalidate-yaml.py
File path: The design document is under ; if the feature directory does not exist, create it in this step. See Section 0 of for naming conventions.
codestable/features/{feature}/codestable/reference/shared-conventions.md容易踩的坑
Common pitfalls
下面这些是过去反复出现的反模式,遇到就停一下问自己是不是又掉进去了:
- 没读相关架构文档就动笔——写出来的方案大概率跟现有代码对不上
- 术语没做防冲突检查——冲突之后 git blame 找原因要花十倍时间
- 用散文描述接口行为,没给具体示例——读者建不起模型,review 时没法判断
- 把契约层写成全字段百科——已经存在且不变的接口别重复抄
- 强行画图——模块就 ≤ 2 个、调用又是线性的,画图反而模糊重点
- 推进步骤拆得太细(>8 步)——细到每步都没什么独立价值
- 只给半份文档让用户先 review——用户看不出全局一致性
- 在需求摘要或改动计划里偷偷扩范围——后面验收时对不上
The following are recurring anti-patterns from the past. When encountering them, stop and ask yourself if you have fallen into them again:
- Starting to write without reading relevant architecture documents — the resulting design will most likely not match existing code
- Not doing term conflict prevention checks — it will take ten times longer to find the reason via git blame after conflicts occur
- Describing interface behavior with prose without providing specific examples — readers cannot build a model and cannot judge during review
- Writing the contract layer as a full-field encyclopedia — do not copy existing and unchanged interfaces repeatedly
- Forcing to draw diagrams — if there are ≤2 modules and the calls are linear, drawing diagrams will blur the focus instead
- Splitting progress steps too finely (>8 steps) — so fine that each step has no independent value
- Only providing half the document for user review first — the user cannot see global consistency
- Secretly expanding the scope in the requirement summary or change plan — will not match during later acceptance