Sd spec templates

From developzoneio/specwright · View interactive version

Sd spec templates is an AI agent skill from the GitHub repository developzoneio/specwright. Per-template authoring rules for specwright. Used by `sd-spec-architect` when `TASK = create`.

How to use this skill

Skill file

sd-spec-templates

Per-template authoring rules for specwright. Used by sd-spec-architect when TASK = create.

Each template has a dedicated section below. Read only the section matching the spec type being authored.


Common rules (apply to all templates)

not pre-fill it, do not delete it. Phase N of the owning workflow replaces it with measured

evidence. /sd:spec validate fails a draft or approved spec whose phase-deferred tokens are

already filled, so pre-filling is caught, not just discouraged.

Required frontmatter fields

| Type | Fields |

|---|---|

| All | id, type, status: draft, created, linked_specs |

| Feature | jira (or none), complexity (S \| M \| L) |

| Bug | severity (P0–P3), jira |

| Refactor | smell |

| Perf | target_metric |

| RCA | severity, incident_started, incident_resolved |

| Port | jira (or none), scope (endpoint\|module\|feature\|pattern), source_repo, source_commit, source_license, snapshot (contract\|contract+source) |

linked_specs is always [] at authoring time. Cross-references are written later by

/sd:spec link, which maintains the inverse entry on the other spec — never hand-write the list,

and never add a "Linked specs" body section. A one-sided link fails /sd:spec validate.


feature.template.md

Fill:

rationale in the trailing comment. See "Complexity estimate" below.

Leave empty: ## Spawned specs — header + separator only, no rows and no <<...>> token. It

mirrors rca.template.md's four-column table and is filled at close-out by the owning workflow,

not at create time. A reserved ID is a placeholder, never an .specs/index.md row.

never renumbered or reused after a scenario is deleted - downstream Covers fields and

/sd:verify reports reference them.

before /sd:verify can pass (see sd-atomic-task-format).

Constitution check: list applicable §N.M references. Flag any potential violation as an Open question.

Complexity estimate (feature only)

The complexity frontmatter field is the architect's whole-spec size estimate. It exists to route

oversized work into the regime the engine handles well: at Gate 2, /sd:feature measures the real

plan against the thresholds below and, if the plan exceeds them, refuses a single oversized plan and

forces a decompose into medium child specs (see commands/feature.md, Gate Complexity).

**complexity is a spec-level field. It is NOT the same as a task's Estimated complexity

field in 02-tasks.md.** The task field sizes one line item; this field sizes the whole feature.

They share the S | M | L vocabulary on purpose (one house currency) but answer different

questions. Never conflate them.

Estimate at create, measure at plan. At create the architect has only Why / What / SC / AC /

Open questions — no plan yet — so complexity is an honest estimate, written with a one-line

rationale. It is not a measured field, so it is a plain author-fill token, not a <<PHASE-N: ...>>

token, and it is filled at create time. Phase 3 is where the plan is measured against the

thresholds; the create-time estimate does not have to be re-derived, but it must be a genuine

judgement, not always M.

Rubric for the estimate:

| Value | Guideline (estimate) |

|---|---|

| S | One layer, a handful of tasks (≈1-4), single subsystem, no unresolved Open questions. |

| M | Up to 2 layers, ≈5-8 tasks, one boundary crossing. The regime the engine plans well. |

| L | Spans > 2 production layers/subsystems, likely > 8 tasks, or carries unresolved Open questions at plan time. Candidate for decomposition. |

Decompose thresholds (measured at Gate 2). A plan is over-threshold when any of these hold:

exclude Tests and Config: they cross-cut nearly every change, so counting them would make

an ordinary 2-layer feature (e.g. Application + Domain + Tests) read as 3 and over-fire

The > 8 task line is set from the only live corpus (asian-sportsbook-v2): real feature specs

cluster at 3-4 tasks (medium) and 10-12 tasks (the two specs a human had already hand-split into a

parent + child), with nothing in between — > 8 sits in that canyon, so mediums pass untouched and

the genuinely large trip the gate. The Tests/Config exclusion is set from the same corpus: the

3-4-task mediums touch Application + Domain + Tests, so a naive layer count would have tripped

the gate on exactly the specs that must pass with zero friction.

Count tasks with the tolerant grammar, never a naive regex. When measuring the task count, use

the Field label / heading grammar the way sd-atomic-task-format describes — live specs write

task headings as ### T01, ### ✅ T01, and other drifted forms. A counter that matches only

^### T<NN> undercounts real specs and the gate silently never fires. Match tolerantly: a task

heading is an H3 (or deeper) whose text contains a T<digits> token.

A create-time estimate of L also escalates models — /sd:feature applies the

sd-model-escalation rules that read it. That is a main-thread action; the architect only writes

the estimate.


bug.template.md

Fill:

Leave empty: Root cause section, Fix approach section, ## Spawned specs (header + separator

only, no <<...>> token) — the first two are filled in Phase 3 (debugger) and Phase 5 (main thread

breaks the workflow gate discipline.


refactor.template.md

Fill:

Leave TBD:

owning workflow, not at create time.

Public API: preserved by default. Any public API change requires explicit mention in the spec.


perf.template.md

Fill:

Leave empty:


rca.template.md

Produce skeleton only. The following are filled interactively by the main thread with user input in Phase 1 — do NOT pre-fill them:

Leave TBD (filled by later phases):

Spec ID format: RCA-<slug>-<YYYYMMDD> using UTC date.


port.template.md

source_repo / source_commit are required values, not just present fields, when scope is

not pattern (write none for pattern). The three fidelity tables - Path mapping table, Member

manifest, Deviation table - and the mandatory fidelity acceptance criterion (AC-1, pre-filled,

never reworded or renumbered) are owned by sd-port-fidelity: read that skill for the column

schemas and completeness conditions rather than re-deriving them here.

Fill:

AC-2 onward, Out of scope, Open questions.

deleted - it is the single highest-value section in the spec.

reproduced deliberately, not per sanctioned deviation.

No <<PHASE-N: ...>> tokens exist for this template (same as feature.template.md) - the

fidelity tables and Frozen: line are progressively filled by sd-spec-architect refine calls

and main-thread edits across /sd:port's phases, not gated by phase-deferred tokens. Do not invent

one.

Spec ID format: PORT-<slug>-<YYYYMMDD> using UTC date.


Anti-patterns

04-artifacts/source/MANIFEST.md, keyed by (Snapshot path, Ordinal).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.