Defines the format, structure, and quality standards for SPEC.md documents. Used by the spec-writer agent in Phase 1 to transform RESEARCH.md into a precise, testable specification with requirements, interfaces, behavior scenarios, and traceability.
REQ-XX-NNN where XX is a category code and NNN is sequential (e.g., REQ-CA-001, REQ-CRL-001).Good requirement: : The system shall generate a self-signed root CA certificate with a configurable subject name, key algorithm (RSA-2048 or RSA-4096), and validity period.
REQ-CA-001Bad requirement: "The system should handle certificates properly." (Not testable, not specific.)
Good scenario:
Scenario: Generate root CA certificate
Given no existing CA state
When the user runs `ca init --subject "CN=MyRootCA" --key-algo RSA-2048 --validity-days 3650`
Then a root CA certificate is created with subject "CN=MyRootCA"
And the certificate is self-signed (issuer equals subject)
And the key algorithm is RSA-2048
And the certificate validity is 3650 days from the current date
And the certificate has the CA:TRUE basic constraint
Bad scenario: "When you create a certificate, it should work correctly." (No concrete data, no observable outcome.)
# SPEC.md — [Project Name]
## §1 — Core Principle
[Carried forward from RESEARCH.md §1. Restated for self-containment.]
## §2 — Scope Summary
[Carried forward from RESEARCH.md §5. Restated for self-containment. What's in, what's out, what's mocked.]
## §3 — Requirements
### §3.1 — [Category Name]
[Requirements in this category, each with REQ-XX-NNN identifier.]
### §3.2 — [Category Name]
[Requirements in this category.]
(Continue for all requirement categories.)
## §4 — Domain Model
[Key entities, their attributes, and relationships. This is not a database schema — it's the conceptual model that requirements operate on.]
## §5 — Interface Contracts
### §5.1 — CLI Interface
[Every command, its arguments, its output format, its exit codes.]
### §5.2 — Data Formats
[Input and output data structures. Concrete examples in the format the system will use (JSON, PEM, etc.).]
## §6 — Behavior Scenarios
### §6.1 — [Feature/Flow Name]
[Scenarios in Given/When/Then format with concrete data.]
### §6.2 — [Feature/Flow Name]
[Scenarios in Given/When/Then format with concrete data.]
(Continue for all features/flows. Include success and failure scenarios.)
## §7 — Error Catalog
[Every expected error condition. For each: trigger condition, error message/code, system behavior after the error.]
## §8 — Assumptions
[Carried forward from RESEARCH.md §6, refined. These are facts the spec treats as true.]
## §9 — Traceability Matrix
| Requirement | Scenarios | Interface |
|-------------|-----------|-----------|
| REQ-XX-NNN | §6.N | §5.N |
[Every requirement must appear. Every requirement must map to at least one scenario.]