Sd pattern discipline

From developzoneio/specwright · View interactive version

Sd pattern discipline is an AI agent skill from the GitHub repository developzoneio/specwright. Pattern discovery and adherence rules for specwright. New code must read as if written by the

How to use this skill

Skill file

sd-pattern-discipline

Pattern discovery and adherence rules for specwright. New code must read as if written by the

team that wrote the surrounding code. Applied by sd-spec-architect (authoring Pattern refs),

sd-implementer (following them), and sd-reviewer (verifying conformance).

Read the section matching your role. The core rule applies to everyone.


The core rule

Before writing new code, find the precedent. The codebase - not your training data - defines what

"idiomatic" means here. Discovery is always by sampling (Glob / Grep / Read of 1-3 files), never

by stack assumption. If the precedent and your habits disagree, the precedent wins.


Discovering precedents (sd-spec-architect)

For every task that creates a new file or introduces a new public symbol:

new or sparse). Pick the 1-3 existing files closest in role to what the task creates. Those are

the Pattern refs.

the same kind. Observe the naming morphology (prefix, suffix, casing, pluralization) and cite

one representative example.

verb). If found, the ref says "reuse this - do not write a new one". If not found, state what

was searched so the implementer does not repeat the search.

before citing it - a hallucinated precedent is worse than none.

Authoring Pattern refs (sd-spec-architect)

instruction of WHAT to mirror ("mirror handler structure and registration", "name after this

precedent", "reuse this helper - do not duplicate").

itself is the precedent.


Following patterns (sd-implementer)

member ordering, naming, and where its test file lives.

Found -> use it. Not found -> write it, and note the search in your summary.

region. If the cited symbol moved, Grep its name once. If the file is gone, fall back to the

nearest sibling file and note the substitution in your summary - do NOT stop for ref drift.

constitution and surface the mismatch in your summary.


Verifying conformance (sd-reviewer)

nearest sibling file if the task has none). State explicitly what you compared against (file).

task, but a missing one is a spec-authoring defect, not a defect in the code under review - it

belongs to /sd:spec validate as SL060 (WARN), and older specs predate the requirement

entirely. Reviewing the code against the nearest sibling file is the right response; failing the

review is not.


Anti-patterns

the precedent is genuinely bad, surface it - do not silently diverge.

bounded read, not an audit.

how codebases rot.

Acceptance.

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.