Spec Writing & Review
Design and review specifications (SPECs) against Open Mercato architecture and quality rules.
Workflow
- Load Context: Read
AGENTS.md for module conventions and .ai/specs/ for existing specs.
- Initialize: Create
SPEC-{number}-{date}-{title}.md in .ai/specs/.
- Start Minimal: Write a Skeleton Spec (TLDR + 2-3 key sections). Do NOT write the full spec in one pass.
- Scan for critical unknowns — decisions that block data model, scope, or architecture.
- If unknowns exist, add a numbered Open Questions block (
Q1, Q2, …) after the TLDR.
- STOP after presenting the skeleton. Do not proceed until the user answers all questions.
- Iterate: Apply answers, remove Open Questions block. Repeat if new unknowns surface.
- Research: Challenge requirements against open-source market leaders.
- Design: Create architecture, data models, API contracts.
- Implementation Breakdown: Break into Phases (stories) and Steps (testable tasks).
- Review: Apply the Spec Checklist.
- Output: Finalize the specification file.
Output Formats
1. New Specification
Use the Specification Template. Adapt if needed, but ensure core concerns are addressed.
Required sections: TLDR, Problem Statement, Proposed Solution, Data Models, API Contracts, Risks, Changelog.
2. Architectural Review
# Architectural Review: {SPEC-0XX: Title}
## Summary
{1-3 sentences: what the spec proposes and overall health}
## Findings
### Critical
{Cross-module ORM, tenant isolation leaks, missing auth guards}
### High
{Missing undo logic, incorrect module placement, missing phase strategy}
### Medium
{Missing failure scenarios, inconsistent terminology}
### Low
{Style suggestions, nits}
Review Heuristics
- Command Graph vs. Independent Ops: Graph Save (coupled calculation) or Compound Command (independent steps)?
- Architectural Diff: Cut standard CRUD noise. Focus on what's unique.
- Singularity Law: Singular naming for entities, commands, events, feature IDs.
- Undo Contract: Is the "Undo" logic as detailed as the "Execute"?
- Module Isolation: Using Event Bus for side effects or cheating with direct imports?
Quick Rule Reference
- Singular naming for entities, commands, events, feature IDs.
- FK IDs only for cross-module links — no ORM relationships.
organization_id is mandatory for all tenant-scoped entities.
- Undoability is the default for state changes.
- Zod validation for all API inputs.
Reference Materials
1---2name: spec-writing-33description: Guide for creating high-quality specifications for test. Use when starting a new SPEC or reviewing specs against architectural standards.4---56# Spec Writing & Review78Design and review specifications (SPECs) against Open Mercato architecture and quality rules.910## Workflow11121. **Load Context**: Read `AGENTS.md` for module conventions and `.ai/specs/` for existing specs.132. **Initialize**: Create `SPEC-{number}-{date}-{title}.md` in `.ai/specs/`.143. **Start Minimal**: Write a Skeleton Spec (TLDR + 2-3 key sections). Do NOT write the full spec in one pass.15 - Scan for **critical unknowns** — decisions that block data model, scope, or architecture.16 - If unknowns exist, add a numbered **Open Questions** block (`Q1`, `Q2`, …) after the TLDR.17 - **STOP after presenting the skeleton.** Do not proceed until the user answers all questions.184. **Iterate**: Apply answers, remove Open Questions block. Repeat if new unknowns surface.195. **Research**: Challenge requirements against open-source market leaders.206. **Design**: Create architecture, data models, API contracts.217. **Implementation Breakdown**: Break into **Phases** (stories) and **Steps** (testable tasks).228. **Review**: Apply the [Spec Checklist](references/spec-checklist.md).239. **Output**: Finalize the specification file.2425## Output Formats2627### 1. New Specification2829Use the [Specification Template](references/spec-template.md). Adapt if needed, but ensure core concerns are addressed.3031**Required sections**: TLDR, Problem Statement, Proposed Solution, Data Models, API Contracts, Risks, Changelog.3233### 2. Architectural Review3435```markdown36# Architectural Review: {SPEC-0XX: Title}3738## Summary39{1-3 sentences: what the spec proposes and overall health}4041## Findings4243### Critical44{Cross-module ORM, tenant isolation leaks, missing auth guards}4546### High47{Missing undo logic, incorrect module placement, missing phase strategy}4849### Medium50{Missing failure scenarios, inconsistent terminology}5152### Low53{Style suggestions, nits}54```5556## Review Heuristics57581. **Command Graph vs. Independent Ops**: Graph Save (coupled calculation) or Compound Command (independent steps)?592. **Architectural Diff**: Cut standard CRUD noise. Focus on what's unique.603. **Singularity Law**: Singular naming for entities, commands, events, feature IDs.614. **Undo Contract**: Is the "Undo" logic as detailed as the "Execute"?625. **Module Isolation**: Using Event Bus for side effects or cheating with direct imports?6364## Quick Rule Reference6566- **Singular naming** for entities, commands, events, feature IDs.67- **FK IDs only** for cross-module links — no ORM relationships.68- **`organization_id`** is mandatory for all tenant-scoped entities.69- **Undoability** is the default for state changes.70- **Zod validation** for all API inputs.7172## Reference Materials7374- [Spec Template](references/spec-template.md)75- [Spec Checklist](references/spec-checklist.md)76- [AGENTS.md](../../../AGENTS.md)