Generate a detailed design document via `tx doc add design`. Covers architecture, interfaces, data model, invariants, failure modes, verification, and testing strategy. References plan via file path instead of embedding. Plan lives in ~/.codex/plans/<name>.md. Reads companion PRD automatically to map EARS requirements to invariants. Output lands in specs/design/<name>.md.
Standardmรครig ist der Prompt ausgewรคhlt, der zuerst die Quelle prรผft. Sie kรถnnen zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prรผfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich fรผr eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fรผgen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prรผfen und installieren.
Ein direkter Befehl รผberspringt den Prรผf-Prompt. Prรผfen Sie die Quelle, bevor Sie ihn ausfรผhren.
Generate a detailed design document via `tx doc add design`. Covers architecture, interfaces, data model, invariants, failure modes, verification, and testing strategy. References plan via file path instead of embedding. Plan lives in ~/.codex/plans/<name>.md. Reads companion PRD automatically to map EARS requirements to invariants. Output lands in specs/design/<name>.md.
argument-hint
<feature-or-component-name>
Generate Design Document
Create a comprehensive technical design document using the tx doc primitive. Design docs specify HOW the system implements requirements, with traceable invariants and a concrete testing strategy.
Design Doc + PRD are companions. A PRD defines WHAT and WHY. A design doc defines HOW. If a PRD exists for this feature, the design doc reads it automatically and maps every must-priority EARS requirement to an invariant + verification entry.
Workflow State Machine
START
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 0: PLAN GATE โ
โ โ
โ Is there an active plan in this conversation? โ
โ โ
โ โโ YES โ Save plan to `~/.codex/plans/<name>.md` if not โ
โ โ already saved. Set `plan: ~/.codex/plans/<name>.md` โ
โ โ in frontmatter. โ
โ โ โ Continue to Step 0.5 โ
โ โ โ
โ โโ NO โ Tell the user to run /plan first. โ
โ If enough detail provided, generate plan, โ
โ save to `~/.codex/plans/<name>.md`. โ
โ โ Continue to Step 0.5 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 0.5: CHECK FOR COMPANION PRD โ
โ โ
โ Run: tx doc list --kind prd โ
โ โ
โ โโ PRD exists for this feature? โ
โ โ โ tx doc show <prd-name> --md โ
โ โ โ Extract ALL EARS requirements โ
โ โ โ Each `must` EARS req MUST get an invariant โ
โ โ and a verification entry in this design doc โ
โ โ โ Set `implements: <prd-name>` in frontmatter โ
โ โ โ Continue to Step 1 โ
โ โ โ
โ โโ No companion PRD? โ
โ โ Continue to Step 1 (design doc stands alone) โ
โ โ Suggest creating PRD after: /prd <name> โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 1: SCAFFOLD via tx โ
โ โ
โ tx doc add design <name> --title "<title>" โ
โ โโ SUCCESS โ Continue to Step 2 โ
โ โโ FAIL (exists) โ Edit existing doc โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 2: DEEP CONTEXT GATHERING โ
โ โ
โ Read: ARCHITECTURE.md, QUALITY.md, CLAUDE.md, โ
โ domain code, schema.ts, effect-schemas, โ
โ API routes, workflows, activities, โ
โ existing designs (tx doc list --kind design) โ
โ โ Continue to Step 3 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 3: FILL DOCUMENT โ
โ โ
โ Write `# Plan` first (reference to plan file from โ
โ Step 0). โ
โ Then fill all sections from plan + PRD + codebase. โ
โ โ
โ MINIMUM THRESHOLDS: โ
โ - Invariants: โฅ 5 โ
โ - Failure modes: โฅ 3 โ
โ - Verification entries: โฅ 5 โ
โ - Integration test files: โฅ 2 (HARD REQUIREMENT) โ
โ - Unit test files: โฅ 1 (recommended, not hard) โ
โ - Sequence diagrams: โฅ 2 (happy + error) โ
โ - Design decisions: โฅ 1 โ
โ โ
โ Integration tests are the primary verification โ
โ mechanism. Unit tests complement but do not replace โ
โ integration tests. โ
โ โ
โ RULE: No section may be left as a template/stub. โ
โ โ
โ COMPREHENSIVENESS: The design doc must cover EVERY โ
โ item from the plan. Every implementation step, โ
โ constraint, risk, and decision in the plan must โ
โ appear in the design doc with full technical detail. โ
โ The design doc is the single source of truth for HOW โ
โ the feature is built โ it should be detailed enough โ
โ that an engineer can implement from it alone. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 4: SELF-AUDIT โ
โ โ
โ Check: โ
โ โโ Every plan item captured in a section? โ
โ โโ Every PRD `must` EARS req has an invariant? โ
โ โโ Every invariant has a verification entry? โ
โ โโ Minimums met? โ
โ โโ No stubs/placeholders? โ
โ โโ All diagrams complete? โ
โ โโ Plan file exists at frontmatter path and is โ
โ consistent with doc sections? โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 5: VALIDATE โ
โ โ
โ tx spec lint โ
โ โโ PASS โ Continue to Step 6 โ
โ โโ WARN/FAIL โ Fix, re-validate โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 5.5: SYNC PLAN FILE โ
โ โ
โ Read the plan file from frontmatter `plan:` path. โ
โ Compare with what the doc now contains. โ
โ UPDATE the plan file to incorporate: โ
โ - Architecture decisions, component inventory โ
โ - Interface contracts, data model details โ
โ - Invariants, failure modes, error handling โ
โ - Implementation sequence, testing strategy โ
โ The plan file must reflect the FULL current state โ
โ of the feature โ not just the initial draft. โ
โ This is a MANDATORY step, not optional. โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Step 6: DISCOVER + LINK + REPORT โ
โ โ
โ tx spec discover --doc <name> โ
โ tx doc link <prd> <design> (if PRD exists) โ
โ tx doc show <name> โ
โ tx spec gaps --doc <name> โ
โ Print summary โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
DONE
Step 0 โ Plan Gate
The plan is the primary input. Check for plan content in the conversation:
The plan is saved as a standalone file at ~/.codex/plans/<name>.md (relative to repo root).
If a plan already exists in the conversation, write it to that file.
If a plan file already exists at that path, read it instead.
If no plan and vague request, ask user to run /plan first.
The doc's frontmatter gets plan: ~/.codex/plans/<name>.md and the # Plan section contains a reference link + brief summary, not the full verbatim content.
Step 0.5 โ Check for Companion PRD
tx doc list --kind prd
If a PRD exists for this feature:
Read it: tx doc show <prd-name> --md
Extract every EARS requirement
Every must-priority EARS requirement MUST become:
An invariant in invariants: YAML block
A verification entry in verification: YAML block
Set implements: <prd-name> in frontmatter
If no PRD exists, the design doc stands alone. Suggest creating one after.
Body Structure โ ALL sections MUST have real content
# Plan comes first (as a reference to the plan file). Then all technical sections. No section may be a stub.
If a companion PRD exists, every must EARS requirement maps to an invariant + verification entry.
# Plan> Full plan: [~/.codex/plans/<name>.md](../~/.codex/plans/<name>.md)
<2-3 sentence summary of what the plan covers. The full plan lives in the file referenced above.>
# Summary
2-3 sentences on design approach and key technical decisions.
# Architecture## System Context
Where this feature sits in the existing system. Reference `docs/ARCHITECTURE.md`.
## Component Diagram
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ organizations โโโโโ<โ teams โโโโโ<โ <entity> โ
โ โ 1:N โ โ 1:N โ โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
Invariants
MINIMUM: โฅ 5 invariants. If companion PRD exists, every must EARS req MUST map to an invariant.
invariants:-id:INV-<SCOPE>-001statement:<whatmustbetrue>
enforcement: <lint script | test | pgTAP>
traces_to: REQ-<SCOPE>-001 # link to PRD requirement if applicable
## Step 4 โ Self-Audit
Re-read the plan file and verify:
1. **Comprehensiveness check**: Read the plan file. For EVERY item (implementation steps, constraints, risks, decisions), confirm it has full technical detail in the design doc. The design doc must be detailed enough to implement from alone.
2. If PRD exists: every `must` EARS req has an invariant. Every invariant has a verification entry.
3. HARD: โฅ2 integration test files (blocking requirement). SOFT: โฅ1 unit test file (recommended).
4. Minimums met: โฅ5 invariants, โฅ3 failure modes, โฅ5 verifications, โฅ2 sequence diagrams, โฅ1 decision.
5. No stubs, no empty tables, no "..." placeholders.
6. All diagrams complete.
7. Implementation sequence lists real file paths.
8. Verify plan file exists at the path in frontmatter and its content is consistent with the doc sections.
## Step 5 โ Validate
```bash
tx spec lint
Step 5.5 โ Sync Plan File (MANDATORY)
After filling and validating the doc, update the plan file at the plan: frontmatter path to reflect everything the design doc surfaced. The plan file must be the living source of truth โ not a stale initial draft.
What to add to the plan file:
Architecture decisions and their rationale
Component inventory and file paths
Interface contracts (API endpoints, port signatures, event payloads)
Data model details (tables, indexes, constraints)
Implementation sequence with specific file paths
Invariants, failure modes, and error handling strategies
Testing strategy and test file locations
Read the current plan file, merge in the new information, and write it back. Preserve the plan's structure but ensure it now covers the full technical design.
Step 6 โ Discover, Link & Report
tx spec discover --doc <name>
tx doc link <prd> <design> # if PRD exists
tx doc show <name>
tx spec gaps --doc <name>
If PRD exists, show EARSโinvariant mapping coverage.
List open questions.
Run tx spec lint.
If the plan file is modified later, update the # Plan summary and derived sections in this doc. If this doc's scope changes, update the plan file to stay consistent.