plan-from-spec
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlan From Spec
从规格生成计划
Produce a high-level plan that an executor can carry out, and keep that plan true as reality diverges from it.
This skill is domain-neutral. It plans code work, research, writing, operations, and physical-world tasks. Nothing here assumes a web page, a repository, or a programming language.
制定执行者可执行的高级计划,并在实际情况与计划偏离时保持计划的有效性。
本技能与领域无关,可用于规划代码开发、研究、写作、运营及现实世界中的各类任务。本技能不预设任何网页、代码仓库或编程语言相关场景。
What this skill owns
本技能负责的内容
| Owns | Does not own |
|---|---|
| Task decomposition | Deciding what counts as success — the contract does |
| Task ordering and dependencies | Performing the work — the executor does |
| Postconditions that make a task checkable | Recording what happened — the ledger does |
| Regenerating the plan when it stops being true | Reporting to the user — |
The single most important boundary: replanning may change how the goal is reached; it may never redefine what counts as success. See "Contract invariant" below.
| 负责事项 | 不负责事项 |
|---|---|
| 任务分解 | 定义成功标准——由契约负责 |
| 任务排序与依赖关系 | 执行具体工作——由执行者负责 |
| 制定可验证任务的后置条件 | 记录执行过程——由ledger负责 |
| 当计划失效时重新生成计划 | 向用户汇报——由 |
最重要的边界规则:重规划可调整达成目标的路径,但绝不能重新定义成功的标准。 详见下文的「契约不变性」部分。
Working directory
工作目录
All artifacts for one piece of work live in , the same folder creates:
spec-interview/<slug>/spec-from-scratchspec-interview/<slug>/
SPEC.md input (optional — see below)
PLAN.md output (this skill)
LEDGER.md input in replan mode (written by execute-plan)
REPORT.md written by completion-report同一工作项的所有产物均存储在目录下,与创建的目录一致:
spec-interview/<slug>/spec-from-scratchspec-interview/<slug>/
SPEC.md input (optional — see below)
PLAN.md output (this skill)
LEDGER.md input in replan mode (written by execute-plan)
REPORT.md written by completion-reportWhen there is no SPEC
无SPEC文件的情况
A stated goal is enough. Derive the slug yourself — short kebab-case, from the goal (, ) — create the folder, and:
cache-product-endpointmove-office- write the goal verbatim in the plan header as ;
Goal: - set ;
Spec: none — the contract is this plan - omit from every task.
Covers:
With no SPEC, the union of every task's is the acceptance contract. Downstream stages read it from instead of . That makes the contract mutable by replanning, which is exactly the risk a SPEC removes — so say this out loud to the user once.
Done whenPLAN.mdSPEC.mdNever invent a SPEC. If the goal is too vague to produce checkable postconditions, stop and run first.
spec-from-scratch仅明确的目标即可开展工作。自行生成slug(简短的短横线分隔格式,基于目标生成,例如、),创建对应目录,并执行以下操作:
cache-product-endpointmove-office- 在计划头部将目标原文写入字段;
Goal: - 设置;
Spec: none — the contract is this plan - 所有任务中省略字段。
Covers:
无SPEC文件时,所有任务的字段共同构成验收契约。后续阶段将从而非中读取契约。这意味着契约可通过重规划修改,而这正是SPEC文件要规避的风险——因此需向用户明确说明这一点。
Done whenPLAN.mdSPEC.md切勿自行创建SPEC文件。若目标过于模糊,无法生成可验证的后置条件,请先执行技能。
spec-from-scratchStep 1 — Ground the plan in observation, never in assumption
步骤1 — 基于实际观察制定计划,而非假设
Before writing any task, inspect the actual current state. A plan written from the goal alone is a guess.
Inspect whatever the domain makes observable: existing files and structure, current configuration, a running system's behavior, available tooling, data already present, prior work, the state of external services or people. Spend real effort here — this is the cheapest place in the whole workflow to be wrong.
The reasoning of task 1 must contain a concrete observation of the current state: what exists now, what is missing, and which of the goal's assumptions the observation confirms or contradicts.
If the observation contradicts the contract, stop and say so. Do not plan around a contradiction silently.
在编写任何任务之前,先检查当前实际状态。 仅基于目标制定的计划只是猜测。
检查领域内所有可观察的内容:现有文件与结构、当前配置、运行系统的行为、可用工具、已存在的数据、过往工作成果、外部服务或人员的状态。在此环节投入精力是整个工作流程中纠错成本最低的环节。
任务1的推理内容必须包含对当前状态的具体观察:当前已存在哪些内容、缺少哪些内容,以及该观察验证或否定了目标中的哪些假设。
若观察结果与契约矛盾,请立即停止并告知用户,切勿默默绕过矛盾制定计划。
Already-satisfied goals
目标已达成的情况
If the observation shows the goal is already true, write a plan with zero tasks and hand straight to . Do not manufacture tasks to make the plan look substantial. The whole file is then:
completion-reportmarkdown
undefined若观察结果显示目标已达成,请制定一个包含零任务的计划,并直接提交给。切勿为了让计划看起来充实而虚构任务。此时整个文件内容如下:
completion-reportmarkdown
undefinedPLAN: <slug>
PLAN: <slug>
Spec: ./SPEC.md
Goal: <one sentence>
Plan version: 1
Status: no-op
Already true because: <the observation that establishes it>
Evidence: <how you observed it>
`Status: no-op` appears only in this case. A plan with tasks omits the field.Spec: ./SPEC.md
Goal: <一句话描述>
Plan version: 1
Status: no-op
Already true because: <验证目标已达成的观察内容>
Evidence: <观察方式>
`Status: no-op`仅在上述情况中出现。包含任务的计划需省略该字段。Step 2 — Choose task granularity
步骤2 — 选择合适的任务粒度
A task is a meaningful unit of work with a single verifiable outcome. It normally requires several low-level actions.
Cluster related actions that serve one sub-goal into one task. Prefer fewer, denser tasks.
TOO FINE RIGHT
- Open the config file - Add Redis connection settings to the
- Add a redis section application config, reading host and
- Save the file port from environment variables
- Search for papers - Identify the three most-cited papers on
- Open each result retrieval-augmented generation published
- Note the citation counts since 2023, with citation countsTOO COARSE RIGHT
- Implement caching - Add a cache abstraction with get/set/invalidate
- Wire the product endpoint through the cache
- Add invalidation on product updateCalibration rules:
- If a task cannot fail in an interesting way, it is too fine — merge it.
- If a task has more than one postcondition, it is too coarse — split it.
- A task must carry enough context to stand alone, because it may be handed to a separate agent or person.
任务是具有单一可验证成果的有意义工作单元,通常需要多个底层操作来完成。
将服务于同一子目标的相关操作整合为一个任务。优先选择数量更少、内容更集中的任务。
过于细化 合理粒度
- 打开配置文件 - 为应用配置添加Redis连接设置,从环境变量中读取
- 添加Redis配置段 主机地址与端口
- 保存文件
- 搜索论文 - 找出2023年以来发表的被引用次数最多的三篇
- 打开每个搜索结果 检索增强生成相关论文,并记录引用次数
- 记录引用次数过于粗糙 合理粒度
- 实现缓存功能 - 添加包含get/set/invalidate方法的缓存抽象层
- 将产品端点接入缓存层
- 添加产品更新时的缓存失效机制校准规则:
- 若任务不会出现有意义的失败情况,则过于细化——需合并;
- 若任务包含多个后置条件,则过于粗糙——需拆分;
- 任务必须包含足够的上下文以独立存在,因为它可能被分配给独立的Agent或人员执行。
Step 3 — Be specific about WHAT, silent about HOW
步骤3 — 明确描述成果,无需说明实现方式
State the intended outcome and its concrete parameters. Do not prescribe the mechanics.
VAGUE Add the timeout setting.
SPECIFIC Set the HTTP client request timeout to 30 seconds for all
outbound calls to the payment provider.
HOW Open PaymentClient.cs, find the HttpClient constructor, add
a Timeout property.
WHAT The payment client fails a request after 30 seconds instead
of hanging.Conditional tasks in plain language are allowed when the branch is genuinely unknown at plan time: "If the existing migration tool supports rollback, use it; otherwise write the rollback script by hand." Avoid nested or ambiguous conditions.
说明预期成果及具体参数,不必规定执行机制。
模糊描述 添加超时设置。
具体描述 将所有向支付提供商发起的出站调用的HTTP客户端请求超时时间设置为30秒。
实现方式 打开PaymentClient.cs,找到HttpClient构造函数,添加
Timeout属性。
成果描述 支付客户端在30秒后终止请求,而非无限挂起。若在计划制定时确实存在未知分支,可使用自然语言描述条件任务:"若现有迁移工具支持回滚,则使用该工具;否则手动编写回滚脚本。" 避免嵌套或模糊的条件判断。
Step 4 — Give every task a postcondition
步骤4 — 为每个任务设置后置条件
This is the addition that makes the plan work outside of environments where state is observable for free.
Every task states Done when as an observable condition, and Verify by as the concrete way to check it.
Done when: the product endpoint returns a cached response on the second
identical request within the TTL window
Verify by: run the integration test ProductCacheTests
Done when: every interviewee has confirmed the scheduled slot in writing
Verify by: each of the six invitations shows an accepted responseRules:
- describes state, never activity. Not "the cache code is written" — that is activity. "A repeated request is served from cache" is state.
Done when - names something that produces evidence: a command, a test, a file check, an API response, a document, a direct observation.
Verify by - When no automatic check exists, write . That is valid evidence once the user actually confirms — weaker than a machine check, and the report will label it
Verify by: user confirmationrather than measured. A postcondition merely awaiting confirmation is not yet satisfied.attested - A task with no possible postcondition is not a task. It is either a detail of another task or it does not belong in the plan.
Postconditions are what let the executor detect divergence. Without them, "replan when needed" is a subjective judgment the executor will not make.
这是让计划在无法自由观察状态的环境中依然有效的关键。
每个任务需明确Done when(可观察的完成条件)和Verify by(具体验证方式)。
Done when: 相同请求在TTL窗口内的第二次调用时,产品端点返回缓存响应
Verify by: 运行集成测试ProductCacheTests
Done when: 所有受访者均已书面确认预约时间
Verify by: 六份邀请均显示已接受状态规则:
- 描述状态,而非操作。不能写"缓存代码已编写"(这是操作),而应写"重复请求从缓存中获取响应"(这是状态)。
Done when - 指定可生成证据的方式:命令、测试、文件检查、API响应、文档、直接观察等。
Verify by - 若不存在自动验证方式,可写。这在用户实际确认后是有效证据——虽弱于机器验证,报告会将其标记为
Verify by: user confirmation(已确认)而非measured(已测量)。仅等待确认的后置条件不算已满足。attested - 无法设置后置条件的内容不能作为任务。它要么是其他任务的细节,要么不属于计划范畴。
后置条件是执行者检测计划偏离的依据。没有后置条件,"必要时重规划"就成了执行者无法判断的主观决策。
PLAN.md format
PLAN.md格式
Write to :
spec-interview/<slug>/PLAN.mdmarkdown
undefined写入:
spec-interview/<slug>/PLAN.mdmarkdown
undefinedPLAN: <slug>
PLAN: <slug>
Spec: ./SPEC.md
Goal: <one sentence, restated from the spec or from the user's words verbatim>
Plan version: 1
Replanned because: <trigger — omit on version 1>
Spec: ./SPEC.md
Goal: <一句话,从规格或用户原话中复述>
Plan version: 1
Replanned because: <触发原因——版本1时省略>
T1 — <outcome-shaped title>
T1 — <成果导向的标题>
Reasoning: <why this task exists, why these actions group together, and — in T1 only —
the concrete observation of the current state that grounds this plan>
Task: <what must be accomplished, with concrete parameters>
Done when: <observable postcondition>
Verify by: <how to check it>
Covers: FR-001, AC-003
Depends on: —
Reasoning: <该任务存在的原因、操作整合的依据,且仅在T1中需包含
用于锚定计划的当前状态具体观察内容>
Task: <需完成的内容,包含具体参数>
Done when: <可观察的后置条件>
Verify by: <验证方式>
Covers: FR-001, AC-003
Depends on: —
T2 — <outcome-shaped title>
T2 — <成果导向的标题>
Reasoning: ...
Task: ...
Done when: ...
Verify by: ...
Covers: FR-002
Depends on: T1
Field rules:
- **Task IDs are stable and never reused.** `T3` refers to the same unit of work across every plan version. A replan that keeps a task keeps its ID; a new task takes the next unused number. This is what lets the ledger join to the plan across replans.
- **Covers** maps to SPEC requirement and acceptance-criterion IDs. Omit entirely when there is no SPEC. When a SPEC exists, every acceptance criterion must be covered — see the quality gate.
- **Depends on** lists task IDs that must complete first. Use `—` when none. Order tasks so dependencies precede dependents.
- **Plan version** is a label for ledger entries, not an archive. Prior plan text lives in version control, not in this folder.
---Reasoning: ...
Task: ...
Done when: ...
Verify by: ...
Covers: FR-002
Depends on: T1
字段规则:
- **任务ID保持稳定且永不重复。** `T3`在所有计划版本中均指代同一工作单元。重规划时保留的任务将沿用原ID;新任务使用下一个未被使用的编号。这确保ledger可跨版本关联到计划中的任务。
- **Covers**映射到SPEC中的需求和验收标准ID。无SPEC文件时需完全省略该字段。存在SPEC文件时,所有验收标准必须被覆盖——详见质量检查环节。
- **Depends on**列出必须先完成的任务ID。无依赖时使用`—`。任务顺序需遵循依赖关系,前置任务排在依赖任务之前。
- **Plan version**是ledger条目标签,而非存档。历史计划文本存储在版本控制系统中,而非此目录。
---Mode: initial plan
模式:初始规划
Trigger: a contract or goal exists and does not.
PLAN.md- Read the SPEC in full, or capture the user's goal verbatim.
- Observe the current state (step 1 above).
- Decompose into tasks (steps 2–4).
- Run the plan quality gate.
- Write at version 1.
PLAN.md
触发条件:存在契约或目标,且不存在。
PLAN.md- 完整读取SPEC文件,或准确记录用户目标。
- 观察当前状态(详见上文步骤1)。
- 分解任务(详见上文步骤2-4)。
- 执行计划质量检查。
- 写入版本1的。
PLAN.md
Mode: replan
模式:重规划
Trigger: the executor's replan gate fired. Reaching the end of a task is a checkpoint for that gate, not by itself a reason to replan. A run in which no plan ever changes is a correct run.
Inputs: the contract, the current , , and the observed current state.
PLAN.mdLEDGER.md触发条件:执行者的重规划触发条件被触发。任务完成是该触发条件的检查点,但任务完成本身并非重规划的理由。全程未修改计划的执行也是正确的执行。
输入内容:契约、当前、及观察到的当前状态。
PLAN.mdLEDGER.mdReflect before replanning
重规划前的反思
Start the reasoning of the first future task with an explicit reflection:
- What was actually done, according to the ledger?
- Did it succeed? How do you know from the current observable state — not from the executor's claim?
- What did execution discover that the previous plan could not have known?
在第一个后续任务的推理内容开头添加明确反思:
- 根据ledger记录,实际完成了哪些工作?
- 工作是否成功?你如何从当前可观察状态得知——而非仅凭执行者的声明?
- 执行过程发现了哪些原计划无法预知的信息?
Then refine
然后进行优化
- Identify which remaining tasks are now possible, and which have become impossible.
- Make remaining tasks specific using information now observable. This is the main job: a task that said "contact the site owner" becomes "email Alice Nguyen, the listed maintainer".
- Remove tasks that are no longer needed.
- Add tasks the current state revealed as necessary.
- Fix errors and assumptions in the previous plan.
- Adapt when an expected element, file, result, person, or capability was not found.
- 确定哪些剩余任务现在可执行,哪些已无法执行。
- 利用当前可观察信息细化剩余任务。这是核心工作:例如原任务"联系站点所有者"可细化为"联系列出的维护者Alice Nguyen"。
- 删除不再需要的任务。
- 添加当前状态显示必要的新任务。
- 修正原计划中的错误与假设。
- 适配未找到预期元素、文件、结果、人员或能力的情况。
Rules
规则
- Plan only future work. Completed tasks leave the plan; the ledger holds them. Do not renumber survivors.
- No attempted task survives. Any task with a ,
partial, orblockedledger entry is finished as an instruction: whatever remains of it becomes a new task with a new ID. Reusing the ID would make the executor re-run side effects that already happened — and because the executor never redispatches a task that has a ledger entry, a reused ID would simply never run again. Say in the new task's reasoning which prior task it continues.failed - Carry discovered facts forward into the plan text. The plan is the working memory of the run. If execution learned that the top contributor is Alice, later tasks say "Alice", not "the top contributor". This is why the loop needs no separate memory mechanism.
- Increment and fill
Plan versionwith the concrete trigger.Replanned because - If nothing material changed, say so and leave the plan untouched.
- 仅规划未来工作。 已完成的任务从计划中移除,由ledger记录。不要重新编号剩余任务。
- 已尝试的任务不再保留。 任何标记为(部分完成)、
partial(受阻)或blocked(失败)的任务将作为指令终止:剩余工作需作为新任务,使用新ID。复用ID会导致执行者重复执行已产生副作用的操作——且由于执行者不会重新调度已有ledger条目的任务,复用ID的任务将永远不会被执行。需在新任务的推理内容中说明其承接的原任务。failed - 将发现的事实纳入计划文本。 计划是执行过程的工作记忆。若执行过程得知核心贡献者是Alice,后续任务需直接写"Alice",而非"核心贡献者"。这也是整个流程无需单独记忆机制的原因。
- 递增,并在
Plan version中填写具体触发原因。Replanned because - 若未发生实质性变化,需明确说明并保持计划不变。
Contract invariant
契约不变性
Replanning changes the strategy. It never changes the definition of success.
If reaching the goal now requires relaxing, dropping, or reinterpreting an acceptance criterion, stop. Do not write a plan that quietly satisfies a weaker goal. Instead report to the user:
- which acceptance criterion cannot be met as written;
- what execution discovered that makes it unreachable;
- the options — change the contract, change the approach, or accept partial completion.
Amending the contract is the user's decision, not the planner's. A plan that silently redefines success is the failure mode this whole workflow exists to prevent.
On a run with no SPEC, the contract is the union of the conditions accepted so far — those already satisfied in the ledger, plus those in the current plan. Replanning may add conditions and may restate a pending one more precisely. It may not weaken or drop one, and it may never touch a condition the ledger already records as satisfied. Dropping a pending condition is a contract change and takes the same escalation as above. The invariant is not suspended just because the contract lives in the plan file.
Done when重规划可调整策略,但绝不能修改成功的定义。
若当前达成目标需要放宽、删除或重新解释验收标准,请立即停止。切勿制定悄悄满足更低标准目标的计划。应向用户汇报:
- 哪些验收标准无法按原定义达成;
- 执行过程发现了哪些导致其无法达成的信息;
- 可选方案——修改契约、调整方法或接受部分完成。
修改契约是用户的决策,而非规划者的决策。悄悄重新定义成功的计划正是整个工作流程要避免的失败模式。
在无SPEC文件的执行流程中,契约是ledger中已满足的条件与当前计划中条件的合集。重规划可添加条件,也可更精确地重述待完成的条件,但不得弱化或删除条件,且绝不能修改ledger已记录为满足的条件。删除待完成条件属于契约变更,需按上述流程升级处理。即使契约存储在计划文件中,不变性规则依然适用。
Done whenDone whenPlan quality gate
计划质量检查
Run before writing , in either mode:
PLAN.mdmarkdown
- Grounded in an actual observation of current state: Pass / Missing
- Every acceptance criterion covered by a completed ledger entry or a remaining task: Pass / Missing / N/A
- Every task has an observable Done when: Pass / Missing
- Every task has a Verify by: Pass / Missing
- No task describes HOW instead of WHAT: Pass / Missing
- Dependencies ordered correctly, no cycles: Pass / Missing
- Task IDs stable against the previous version (replan only): Pass / Missing / N/A
- Success criteria unchanged from the contract (replan only): Pass / Missing / N/A
Verdict: Ready / Not readyCoverage is evaluated against the ledger plus the remaining plan, never the remaining plan alone. A criterion satisfied by a completed task stays covered after that task leaves the plan.
Not ready在两种模式下,写入前需执行以下检查:
PLAN.mdmarkdown
- 基于当前状态的实际观察:通过/缺失
- 每个验收标准均已被ledger中已完成条目或剩余任务覆盖:通过/缺失/不适用
- 每个任务均有可观察的Done when条件:通过/缺失
- 每个任务均有Verify by验证方式:通过/缺失
- 无任务描述实现方式而非成果:通过/缺失
- 依赖关系排序正确,无循环:通过/缺失
- 任务ID与上一版本保持稳定(仅重规划时):通过/缺失/不适用
- 成功标准与契约一致(仅重规划时):通过/缺失/不适用
结论:就绪/未就绪覆盖范围需结合ledger与剩余计划评估,而非仅评估剩余计划。已完成任务覆盖的标准在任务从计划中移除后仍保持已覆盖状态。
"未就绪"意味着需修正计划,而非附带警告交付。
Anti-patterns
反模式
Action lists. A plan whose tasks are "open X", "edit Y", "run Z" is a trajectory, not a plan. The executor produces those; the planner does not.
Unfalsifiable tasks. "Improve error handling" has no postcondition, so nothing can detect its failure. Name the observable behavior instead.
Planning from the goal alone. Skipping observation produces a plan that is coherent and wrong. Most replans are caused by a planner that never looked.
Renumbering on replan. Every ledger entry points at a task ID. Renumber and those references now point at different work.
Silent scope drift. Quietly dropping a hard requirement during replan because it turned out to be difficult. Escalate instead.
Padding. A three-task goal gets a three-task plan. Do not manufacture tasks to make the plan look thorough.
操作清单。 任务为"打开X"、"编辑Y"、"运行Z"的计划是执行轨迹,而非真正的计划。这些内容由执行者生成,而非规划者。
无法证伪的任务。 "改进错误处理"没有后置条件,因此无法检测其失败。应改为描述可观察的行为。
仅基于目标制定计划。 跳过观察环节会生成看似连贯但实际错误的计划。大多数重规划都是由于规划者未做观察导致的。
重规划时重新编号任务。 每个ledger条目都指向特定任务ID。重新编号会导致这些引用指向不同的工作。
悄悄变更范围。 因执行难度大而在重规划时悄悄删除硬性要求。应升级处理而非自行决定。
凑数任务。 原本只需三个任务的目标却制定包含更多任务的计划。切勿为了让计划看起来全面而虚构任务。",