add-functional-specs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Add Functional Specs

添加功能规格

Always use the skill
load-plain-reference
to retrieve the ***plain syntax rules — but only if you haven't done so yet.
请务必使用
load-plain-reference
技能获取***plain语法规则——但仅在你尚未获取过时使用。

When to Use

使用场景

  • The user asks for several functional specs to be added in one go (e.g. "add these three specs", "spec out this feature in a few bullets").
  • A higher-level skill or workflow (
    forge-plain
    ,
    add-feature
    ,
    debug-specs
    ) needs to author a tight group of related specs.
  • Anywhere you would otherwise be tempted to write more than one functional spec without running per-spec analysis.
If you only need to add a single spec, use the
add-functional-spec
skill instead. Either way, never edit the
***functional specs***
section by hand — every new entry must go through one of these two skills so the complexity and conflict checks actually run.
  • 用户要求一次性添加多个功能规格(例如:“添加这三个规格”、“用几个要点描述这个功能的规格”)。
  • 更高级别的技能或工作流(
    forge-plain
    add-feature
    debug-specs
    )需要编写一组紧密关联的规格。
  • 任何你原本想要一次性编写多个功能规格而不进行单规格分析的场景。
如果仅需添加单个规格,请改用
add-functional-spec
技能。无论哪种情况,绝对不要手动编辑
***functional specs***
部分——每一条新条目都必须通过这两个技能之一添加,以确保运行复杂度和冲突检查。

Workflow

工作流

This skill is
add-functional-spec
applied one spec at a time, in order, with no shortcuts. The batch never escapes per-spec rigor.
  1. Identify the target
    .plain
    file.
    If ambiguous, ask the user.
  2. Read the entire file to understand existing definitions, implementation reqs, and all current functional specs (including those reachable via
    import
    /
    requires
    ).
  3. Draft all the specs you intend to add, in the chronological order they should appear. Keep the drafts in a working list — nothing is inserted yet.
  4. For each drafted spec, in order:
    1. Analyze complexity. Run
      analyze-if-func-spec-too-complex
      on the spec. If the verdict is
      TOO COMPLEX
      , run
      break-down-func-spec
      , replace the entry in the working list with the resulting smaller specs (preserving order), and restart this step on the first of the replacements.
    2. Check for conflicts. Run
      analyze-func-specs
      once with this single input set:
      • the new spec, plus
      • every existing functional spec in the file and its
        requires
        chain, plus
      • every spec from this batch that has already been inserted.
      The batched analyzer returns every conflicting pair in one call — do not loop over pairs invoking a per-pair analyzer. For each conflicting pair it reports, run
      resolve-spec-conflict
      . Apply the resolution — which may revise the new spec, an existing spec, or both — then re-run
      analyze-func-specs
      once over the touched set until the verdict is
      COMPATIBLE
      .
    3. Append the spec to the
      ***functional specs***
      section. Specs are chronological; the new entry goes at the end (unless an earlier existing spec must come after it — in that rare case, insert at the correct position).
  5. Read the file again to confirm correct placement, ordering, and syntax for the full batch.
Order matters: each new spec is inserted only after its complexity and conflict checks pass, so subsequent specs in the batch are always checked against an already-validated file.
本技能是将
add-functional-spec
按顺序逐个应用于每条规格,无任何捷径。批量操作绝不会跳过单规格的严谨检查。
  1. 确定目标
    .plain
    文件
    。若存在歧义,请询问用户。
  2. 读取整个文件,以理解现有定义、实现要求以及所有当前功能规格(包括通过
    import
    /
    requires
    可访问的规格)。
  3. 草拟所有拟添加的规格,按应出现的时间顺序排列。将草稿保存在工作列表中——暂不插入任何内容。
  4. 按顺序处理每条草拟的规格
    1. 分析复杂度。对该规格运行
      analyze-if-func-spec-too-complex
      。如果判定结果为
      TOO COMPLEX
      ,运行
      break-down-func-spec
      ,将工作列表中的该条目替换为拆分后的更小规格(保留顺序),并从第一个替换后的规格开始重新执行此步骤。
    2. 检查冲突。使用以下单一输入集一次性运行
      analyze-func-specs
      • 新规格,加上
      • 文件及其
        requires
        链中的所有现有功能规格,加上
      • 本次批量中已插入的每条规格。
      批量分析器会一次性返回所有冲突对——不要循环调用成对分析器处理每一对冲突。对于报告的每一对冲突,运行
      resolve-spec-conflict
      。应用解决方案(可能修改新规格、现有规格或两者),然后重新对受影响的集合运行
      analyze-func-specs
      ,直到判定结果为
      COMPATIBLE
    3. 追加规格
      ***functional specs***
      部分。规格按时间顺序排列;新条目放在末尾(除非有更早的现有规格必须排在它之后——这种罕见情况下,插入到正确位置)。
  5. 再次读取文件,确认整个批量规格的位置、顺序和语法正确。
顺序至关重要:每条新规格仅在通过复杂度和冲突检查后才会插入,因此批量中的后续规格始终会针对已验证的文件进行检查。

Rules

规则

All the rules from
add-functional-spec
apply per individual spec. They are restated here so this skill is self-contained.
add-functional-spec
的所有规则均适用于单条规格。此处重新列出是为了让本技能自成体系。

Complexity Limit (per spec)

复杂度限制(单条规格)

Each functional spec must imply a maximum of 200 changed lines of code. If a spec is too large, use
break-down-func-spec
to split it into multiple smaller, independent specs. Do not include LOC estimates in the spec text.
每条功能规格对应的代码变更行数最多为200行。如果规格过大,请使用
break-down-func-spec
将其拆分为多个更小的独立规格。不要在规格文本中包含代码行数估算。

Chronological Ordering

按时间顺序排列

Specs are rendered incrementally, top to bottom. The renderer has no knowledge of future specs — only previously rendered specs are in context.
  • A new spec can reference behavior defined by earlier specs.
  • A new spec cannot assume anything about specs that come after it.
  • Order the batch so that each spec only depends on specs that precede it. If two new specs would otherwise reference each other, the dependent one comes second.
规格从上到下逐步呈现。渲染器不了解未来的规格——仅会参考之前已呈现的规格。
  • 新规格可以引用早期规格定义的行为。
  • 新规格不得依赖后续规格的任何内容。
  • 对批量规格排序时,确保每条规格仅依赖于排在它之前的规格。如果两条新规格互相引用,依赖方应排在后面。

Language Agnosticism

语言无关性

Write in terms of behavior, concepts, and domain logic — not implementation constructs. Avoid language-specific types, generics syntax, framework annotations, or other constructs tied to a particular language or framework. General technical terms (null values, JSON types, HTTP status codes) are fine. Language-specific guidance belongs in
***implementation reqs***
.
以行为、概念和领域逻辑来编写,而非实现结构。避免特定语言的类型、泛型语法、框架注解或其他与特定语言/框架绑定的结构。通用技术术语(空值、JSON类型、HTTP状态码)是允许的。特定语言的指导内容应放在
***implementation reqs***
中。

No Conflicts (full coverage via one batched call per spec)

无冲突(每条规格通过一次批量调用实现全覆盖)

The new specs must not contradict each other and must not contradict any existing functional spec. Conflicting specs are the most costly outcome. The conflict check must cover:
  • every (new × existing) pair, and
  • every (new × new) pair within the batch.
That coverage is achieved by running
analyze-func-specs
once per spec being inserted, with the new spec plus every existing spec plus every already-inserted spec from this batch passed in as a single set. The batched analyzer lists every conflicting pair in one call — do not invoke a pair-by-pair analyzer. If ambiguity exists, add explicit detail to eliminate any conflicting interpretation. For each conflicting pair the batched analyzer reports, use the
resolve-spec-conflict
skill to diagnose and fix it before proceeding.
新规格之间不得相互矛盾,不得与任何现有功能规格矛盾。冲突规格是代价最高的结果。冲突检查必须覆盖:
  • 每一对(新规格 × 现有规格),以及
  • 批量中每一对(新规格 × 新规格)。
通过**针对每条待插入的规格运行一次
analyze-func-specs
**来实现全覆盖,传入的集合包含新规格、所有现有规格以及本次批量中已插入的所有规格。批量分析器会一次性列出所有冲突对——不要调用成对分析器。若存在歧义,添加明确细节以消除任何冲突解读。对于批量分析器报告的每一对冲突,在继续操作前使用
resolve-spec-conflict
技能诊断并修复。

Disambiguation (per spec)

消除歧义(单条规格)

Each functional spec must be unambiguous — the renderer should have only one reasonable interpretation. If a single line is not enough to fully disambiguate the behavior, use nested sub-bullets to add detail. Nested lines clarify the parent spec; they do not introduce separate functionality. Even with nested detail, the spec must still imply ≤ 200 LOC.
plain
- :User: should be able to send a :Message: to a :Conversation:.
  - A :Message: must have non-empty content.
  - The :Message: is appended to the end of the :Conversation:.
  - All :Participant: members of the :Conversation: can see the new :Message:.
每条功能规格必须明确无误——渲染器应只有一种合理的解读。如果单行内容不足以完全明确行为,请使用嵌套子项目符号添加细节。嵌套行用于澄清父规格,而非引入独立功能。即使有嵌套细节,规格对应的代码变更行数仍必须≤200行。
plain
- :User: should be able to send a :Message: to a :Conversation:.
  - A :Message: must have non-empty content.
  - The :Message: is appended to the end of the :Conversation:.
  - All :Participant: members of the :Conversation: can see the new :Message:.

Deterministic Interface

确定性接口

Specs must be detailed enough that a developer can use the built software without reading the generated code. All external interfaces must be explicit — REST endpoint paths and HTTP methods, CLI command names and arguments, file formats, message schemas, etc. Never leave interface details up to the renderer's discretion.
规格必须足够详细,以便开发人员无需阅读生成的代码即可使用构建的软件。所有外部接口必须明确——REST端点路径和HTTP方法、CLI命令名称和参数、文件格式、消息模式等。绝不能将接口细节留给渲染器自行决定。

Encapsulation

封装性

Functionality must be self-contained in the spec text.
requires
modules only import functional specs, so do not rely on implementation reqs to convey behavior — they won't be visible in downstream modules.
功能必须在规格文本中自包含。
requires
模块仅导入功能规格,因此不要依赖实现要求来传达行为——下游模块无法看到这些内容。

Acceptance Tests

验收测试

If any of the newly added functional specs need verification, use the
add-acceptance-test
skill to add acceptance tests after the batch has been inserted. Do this per spec, not as part of the bulk pass.
如果任何新添加的功能规格需要验证,请在批量插入完成后使用
add-acceptance-test
技能添加验收测试。请逐条规格进行,不要作为批量操作的一部分。

Anti-Patterns

反模式

  • Don't skip per-spec checks because the batch "feels" small. Even two specs require two complexity checks and a batched conflict check that includes both new specs.
  • Don't fall back to pair-by-pair conflict analysis. Use
    analyze-func-specs
    with the full relevant set once per inserted spec — not
    analyze-2-func-specs
    across every pair.
  • Don't run all complexity checks first and all conflict checks last. Interleave them per spec, as described in the Workflow — a failed complexity check earlier would otherwise waste later conflict checks.
  • Don't insert every spec first and then analyze. A bad spec already in the file pollutes subsequent conflict analyses.
  • Don't fall back to hand-authoring because there are "a lot" of specs to add. The right answer is more analyzer calls, not fewer.
  • Don't use this skill for a single spec. Use
    add-functional-spec
    — it's the same checks without the bulk bookkeeping.
  • 不要因为批量“看起来”小就跳过单规格检查。即使是两条规格,也需要两次复杂度检查和一次包含两条新规格的批量冲突检查。
  • 不要退回到成对冲突分析。针对每条插入的规格,使用完整的相关集合运行一次
    analyze-func-specs
    ——不要对每一对冲突调用
    analyze-2-func-specs
  • 不要先运行所有复杂度检查,最后再运行所有冲突检查。按照工作流描述的那样,逐条规格交替进行——否则早期的复杂度检查失败会浪费后续的冲突检查。
  • 不要先插入所有规格再进行分析。已插入文件的不良规格会污染后续的冲突分析。
  • 不要因为要添加“很多”规格就退回到手动编写。正确的做法是增加分析器调用次数,而非减少。
  • 不要将本技能用于单个规格。请使用
    add-functional-spec
    ——它会执行相同的检查,无需批量管理工作。

Validation Checklist

验证清单

  • Every spec in the batch implies ≤ 200 lines of code changes (verified via
    analyze-if-func-spec-too-complex
    )
  • No conflict between any new spec and any existing spec (verified via batched
    analyze-func-specs
    calls)
  • No conflict between any two new specs in the batch (covered by the same batched
    analyze-func-specs
    calls)
  • Every conflicting pair the batched analyzer reported was resolved via
    resolve-spec-conflict
    before the batch completed
  • All specs written in language-agnostic terms (no language/framework specifics)
  • All external interfaces explicit (endpoint paths, methods, CLI args, formats, etc.)
  • All referenced
    :Concepts:
    are defined in
    ***definitions***
  • Sentences are short, clear, and unambiguous
  • No redundancy with existing specs or within the batch
  • Specs placed in correct chronological positions
  • 批量中的每条规格对应的代码变更行数≤200行(通过
    analyze-if-func-spec-too-complex
    验证)
  • 新规格与现有规格之间无冲突(通过批量
    analyze-func-specs
    调用验证)
  • 批量中任意两条新规格之间无冲突(通过相同的批量
    analyze-func-specs
    调用覆盖)
  • 批量分析器报告的每一对冲突都已通过
    resolve-spec-conflict
    解决,然后才完成批量操作
  • 所有规格均以语言无关的术语编写(无特定语言/框架内容)
  • 所有外部接口均明确(端点路径、方法、CLI参数、格式等)
  • 所有引用的
    :Concepts:
    均在
    ***definitions***
    中定义
  • 句子简短、清晰且明确
  • 与现有规格或批量内部无冗余内容
  • 规格放置在正确的时间顺序位置