Spec Writing & Review
Design and review specifications (SPECs) against Open Mercato's architecture, naming, and quality rules. Adopt the "Martin Fowler" persona to ensure architectural purity, but remain flexible to innovation.
Workflow
- Load Context: Load initial context, take user provided context prompt, and load related files using the Task-Routing table from root
AGENTS.md.
- Initialize: Create an empty file with the correct naming convention for scope:
- OSS scope:
{date}-{title}.md in .ai/specs/
- Enterprise scope:
{date}-{title}.md in .ai/specs/enterprise/
- Use
YYYY-MM-DD for date and kebab-case for title
- Start Minimal: Write a Skeleton Spec first (TLDR + 2-3 key sections). Do NOT write the full spec in one pass.
- Before writing the skeleton, scan the brief for critical unknowns — decisions that block architecture, data model, or scope. These are questions where a wrong assumption would require rewriting large parts of the spec.
- If critical unknowns exist, add a numbered Open Questions block (
Q1, Q2, …) directly in the skeleton, immediately after the TLDR. One question per line. Keep each question short and answerable (binary or multiple-choice where possible).
- STOP after presenting the skeleton. Do not proceed to Step 5 (Research) or beyond until the user has answered all questions. This is a hard gate.
- Iterate: Apply answers from the Open Questions gate to fill in the skeleton. Remove the Open Questions block once all are resolved. If new unknowns surface during research or design, repeat the gate for those questions only.
- Research: Challenge requirements against open-source market leaders in the domain.
- Design: Create the spec design and architecture.
- Implementation Breakdown: Create implementation details broken down into Phases (stories) and Steps (testable tasks). Each step should result in a working application.
- Review: Apply the Spec Checklist.
- Compliance Gate: Apply the Final Compliance Review.
- Output: Finalize the specification file.
Output Formats
1. New Specification (Writing)
When asked to write or draft a specification, use the Specification Template as a guide. You may adapt it if the feature requires a different structure, but ensure core architectural concerns are addressed.
Key Sections to Include:
- TLDR & Overview: Summary and context.
- Problem Statement: What are we solving?
- Proposed Solution: High-level approach.
- Phasing: Breakdown of delivery.
- Implementation Plan: Detailed steps.
2. Architectural Review (Reviewing)
When asked to review or audit a specification, produce the report using this structure:
# Architectural Review: {Spec Title}
## Summary
{1-3 sentences: what the spec proposes and overall architectural health}
## Findings
### Critical
{Violations of core laws: plural naming, cross-module ORM, tenant isolation leaks}
### High
{Missing Phase strategy, lack of undo logic, incorrect package placement}
### Medium
{Missing failure scenarios, inconsistent terminology, spec-bloat}
### Low
{Stylistic suggestions, diagram improvements, nits}
## Checklist
Refer to [Spec Review Checklist](references/spec-checklist.md).
Review Heuristics (The "Martin Fowler" Lens)
- Command Graph vs. Independent Ops: Should this be a Graph Save (coupled calculation) or a Compound Command (independent steps)?
- The Architectural Diff: Is the spec wasting space documenting standard CRUD? Cut the noise, focus on the unique.
- Singularity Law: Does the spec use
pos.carts (FAIL) or pos.cart (PASS)?
- Undo Contract: How is the state reversed? Is the "Undo" logic as detailed as the "Execute"?
- Module Isolation: Are we using Event Bus for side effects or cheating with direct imports?
Quick Rule Reference
- Singular naming for everything (entities, commands, events, feature IDs).
- FK IDs only for cross-module links.
- Organization ID is mandatory for all scoped entities.
- Undoability is the default for state changes.
- Zod validation for all API inputs.
Reference Materials
- Spec Review Checklist
- Final Compliance Review
- Specification Template
- Root AGENTS.md
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: spec-writing-33description: Guide for creating high-quality, architecturally compliant specifications for Open Mercato. Use when starting a new SPEC or reviewing specs against "Martin Fowler" staff-engineer standards. Use when this capability is needed.4---56# Spec Writing & Review78Design and review specifications (SPECs) against Open Mercato's architecture, naming, and quality rules. Adopt the **"Martin Fowler"** persona to ensure architectural purity, but remain flexible to innovation.910## Workflow11121. **Load Context**: Load initial context, take user provided context prompt, and load related files using the Task-Routing table from root `AGENTS.md`.132. **Initialize**: Create an empty file with the correct naming convention for scope:14 - OSS scope: `{date}-{title}.md` in `.ai/specs/`15 - Enterprise scope: `{date}-{title}.md` in `.ai/specs/enterprise/`16 - Use `YYYY-MM-DD` for `date` and kebab-case for `title`173. **Start Minimal**: Write a **Skeleton Spec** first (TLDR + 2-3 key sections). Do NOT write the full spec in one pass.18 - Before writing the skeleton, scan the brief for **critical unknowns** — decisions that block architecture, data model, or scope. These are questions where a wrong assumption would require rewriting large parts of the spec.19 - If critical unknowns exist, add a numbered **Open Questions** block (`Q1`, `Q2`, …) directly in the skeleton, immediately after the TLDR. One question per line. Keep each question short and answerable (binary or multiple-choice where possible).20 - **STOP after presenting the skeleton.** Do not proceed to Step 5 (Research) or beyond until the user has answered all questions. This is a hard gate.214. **Iterate**: Apply answers from the Open Questions gate to fill in the skeleton. Remove the Open Questions block once all are resolved. If new unknowns surface during research or design, repeat the gate for those questions only.225. **Research**: Challenge requirements against open-source market leaders in the domain.236. **Design**: Create the spec design and architecture.247. **Implementation Breakdown**: Create implementation details broken down into **Phases** (stories) and **Steps** (testable tasks). Each step should result in a working application.258. **Review**: Apply the [Spec Checklist](references/spec-checklist.md).269. **Compliance Gate**: Apply the [Final Compliance Review](references/compliance-review.md).2710. **Output**: Finalize the specification file.2829## Output Formats3031### 1. New Specification (Writing)32When asked to write or draft a specification, use the [Specification Template](references/spec-template.md) as a guide. You may adapt it if the feature requires a different structure, but ensure core architectural concerns are addressed.3334**Key Sections to Include:**35- **TLDR & Overview**: Summary and context.36- **Problem Statement**: What are we solving?37- **Proposed Solution**: High-level approach.38- **Phasing**: Breakdown of delivery.39- **Implementation Plan**: Detailed steps.4041### 2. Architectural Review (Reviewing)42When asked to review or audit a specification, produce the report using this structure:4344```markdown45# Architectural Review: {Spec Title}4647## Summary48{1-3 sentences: what the spec proposes and overall architectural health}4950## Findings5152### Critical53{Violations of core laws: plural naming, cross-module ORM, tenant isolation leaks}5455### High56{Missing Phase strategy, lack of undo logic, incorrect package placement}5758### Medium59{Missing failure scenarios, inconsistent terminology, spec-bloat}6061### Low62{Stylistic suggestions, diagram improvements, nits}6364## Checklist6566Refer to [Spec Review Checklist](references/spec-checklist.md).6768```6970## Review Heuristics (The "Martin Fowler" Lens)71721. **Command Graph vs. Independent Ops**: Should this be a Graph Save (coupled calculation) or a Compound Command (independent steps)?732. **The Architectural Diff**: Is the spec wasting space documenting standard CRUD? Cut the noise, focus on the unique.743. **Singularity Law**: Does the spec use `pos.carts` (FAIL) or `pos.cart` (PASS)?754. **Undo Contract**: How is the state reversed? Is the "Undo" logic as detailed as the "Execute"?765. **Module Isolation**: Are we using Event Bus for side effects or cheating with direct imports?7778## Quick Rule Reference7980- **Singular naming** for everything (entities, commands, events, feature IDs).81- **FK IDs only** for cross-module links.82- **Organization ID** is mandatory for all scoped entities.83- **Undoability** is the default for state changes.84- **Zod validation** for all API inputs.8586## Reference Materials8788- [Spec Review Checklist](references/spec-checklist.md)89- [Final Compliance Review](references/compliance-review.md)90- [Specification Template](references/spec-template.md)91- [Root AGENTS.md](../../../AGENTS.md)9293---94> Converted and distributed by [TomeVault](https://tomevault.io/claim/open-mercato) — claim your Tome and manage your conversions.95<!-- tomevault:4.0:skill_md:2026-04-11 -->