Product Discovery & PRD Document Structure Specification
This reference specification defines the canonical directory topology, file naming conventions, YAML frontmatter schema (PRDFrontmatter), Markdown Abstract Syntax Tree (AST) section grammar, falsifiability linting rules (PRDLinter), stage-gate promotion workflows, and REGISTRY.md table schema for Product Requirements Documents (PRDs) in SpecOps (Research Area 2, governed by ADR-0001, ADR-0008, and ADR-0022).
1. Directory Topology & Lifecycle Stages
All Product Requirements Documents and product-level discovery indices reside under docs/project/product/:
docs/project/product/
βββ REGISTRY.md # Canonical index of all PRDs across stages
βββ uat-signoff.json # Customer UAT acceptance sign-off ledger (optional)
βββ idea/ # Stage 1: Raw discovery drafts & problem framing
β βββ prd-XXXX-<slug>.md
βββ shaped/ # Stage 2: Shaped scope, anti-goals & outcomes
β βββ prd-XXXX-<slug>.md
βββ accepted/ # Stage 3: Active engineering & BDD decomposition
β βββ prd-XXXX-<slug>.md
βββ shipped/ # Stage 4: 100% delivered & verified capabilities
βββ prd-XXXX-<slug>.md
Lifecycle Stages & Promotion Gates
PRDs progress monotonically through four directory-backed lifecycle stages managed by PRDLifecycleManager (src/spec_ops/prd/lifecycle.py) and ship_prd (src/spec_ops/prd/shipping.py):
| Stage Directory | Frontmatter status |
Entry / Promotion Gate Criteria | CLI Transition Command | ||
|---|---|---|---|---|---|
idea/ |
Idea |
Initial discovery draft scaffolded with target persona and initial problem context. | spec-ops prd new / spec-ops prd discover |
||
shaped/ |
Shaped |
Document must contain a user pain-point heading matching `^##\s+(Who this is for\ | Problem Statement\ | What the person cannot do today)`. | spec-ops prd promote PRD-XXXX --stage shaped |
accepted/ |
Accepted |
1. target_persona is mapped (not empty, unmapped, none, or unknown).2. ## Checkable Outcomes exists and defines at least one outcome.3. All checkable outcomes pass PRDLinter falsifiability checks with zero subjective terms. |
spec-ops prd promote PRD-XXXX --stage accepted |
||
shipped/ |
Shipped |
1. 100% of linked/governing backlog tasks (TASK-XXXX) have status Complete.2. Linked BDD user stories ( US-XXXX) pass frontdoor test verification.3. Updates REGISTRY.md, closes active horizon in ROADMAP.md, and emits dist/releases/PRD-XXXX-release-manifest.json. |
spec-ops prd ship PRD-XXXX |
When a PRD is promoted across stages, PRDLifecycleManager.promote() atomically:
- Rewrites the
status:field in YAML frontmatter to the capitalized stage name (Idea,Shaped,Accepted, orShipped). - Moves the Markdown file from its previous stage directory to
docs/project/product/and unlinks the old path./ - Synchronizes the corresponding row in
docs/project/product/REGISTRY.md.
2. File Naming & Numbering Conventions
PRD files must adhere to strict naming and numbering invariants enforced by src/spec_ops/core/numbering.py:
- Filename Pattern:
prd-XXXX-.md XXXXis a zero-padded 4-digit positive integer (0001,0002, ...,0008).is a lowercase, hyphen-separated alphanumeric slug derived from the document title (truncated to at most 45 characters during scaffolding).- Canonical Entity Identifier:
PRD-XXXX(uppercase prefixPRD-followed by the 4-digit zero-padded number). - Three-Way Numbering Extraction:
extract_numbers_for_file()inspects three locations in every PRD file underdocs/project/product/:
- Filename stem: regex
^(?:prd-)?(\d+)(case-insensitive). - YAML frontmatter
idfield: regex(?m)^\sid:\s['"]?(?:PRD-)?(\d+)['"]?\s*$. - Markdown H1 heading: regex
#\s*PRD-(\d+).
- Uniqueness Invariant: Every PRD number must be globally unique across
idea/,shaped/,accepted/, andshipped/. Furthermore, a single PRD file must not reference conflicting numbers across its filename stem, frontmatterid, and H1 header. Collisions are flagged byuv run spec-ops health --numbering. - Ignored Index Files:
REGISTRY.md,FEATURE_INVENTORY.md, andREADME.mdinsidedocs/project/product/are excluded from PRD entity parsing and schema validation.
3. YAML Frontmatter Schema (`PRDFrontmatter`)
Every PRD file must begin on line 1 with a YAML frontmatter block delimited by --- lines. Frontmatter is validated against PRDFrontmatter in src/spec_ops/core/schema_validator.py (Schema v2.0).
---
id: '0008'
title: Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine
status: Accepted
created: 2026-10-15
target_persona: Alex (The Agentic Systems Architect) & Morgan (The Autonomous Coding Agent)
component: core
---
Field Reference
| Field | Type | Required | Default | Description & Validation Rules | ||
|---|---|---|---|---|---|---|
id |
`str \ | int (Any`) |
Yes | β | 4-digit identifier string ('0008') or canonical ID ('PRD-0008'). Normalized by parse_prd() to PRD-XXXX. |
|
title |
str |
Yes | β | Human-readable title of the product capability or initiative. | ||
status |
str |
Optional | "Accepted" |
Lifecycle state (Idea, Shaped, Accepted, or Shipped). Should match the parent stage directory. |
||
created |
`date \ | str \ | None (Any`) |
Optional | None |
ISO-8601 creation date (YYYY-MM-DD). |
target_persona |
str |
Yes | β | Target user archetype(s) mapped from docs/project/user_stories/PERSONAS.md. Must not be empty, unmapped, none, or unknown. |
||
component |
str |
Yes | β | Primary target bounded context or architectural component (e.g., core, prd, security, worker, adopt). |
Strict `extra="forbid"` Policy (What Can and Cannot Be Tracked)
PRDFrontmatter configures model_config = ConfigDict(extra="forbid"). Any unrecognized YAML key triggers a SchemaDiagnosticError (extra_forbidden) with exact line and column pointers during uv run spec-ops schema check.
- Allowed in PRD Frontmatter: Only
id,title,status,created,target_persona, andcomponent. - Forbidden in PRD Frontmatter:
- Task-level execution metadata (
dependencies,claimed_by,branch,priority_rank,slice_type,mutation_scope,signed_off_by). - Story-level metadata (
persona,governing_prd,scenarios,feature). - Relational arrays (
linked_stories,implementing_tasks,governing_adrs)βtraceability links to stories and tasks must be tracked in the Markdown body sections (## Linked User Storiesand## Implementing Backlog Tasks), never in YAML frontmatter.
4. Markdown Body AST Grammar
Following the closing --- frontmatter delimiter, the Markdown body must conform to the structural AST grammar enforced by PRDLinter (src/spec_ops/prd/linter.py) and extracted by parse_prd() (src/spec_ops/core/parser.py).
Canonical Document Template
# PRD-0008 β Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine
## Who this is for
- **Alex (The Agentic Systems Architect)**: Needs a formal, self-describing grammar for project documents.
## What the person cannot do today
- Document contracts are implicitly scattered across regexes in multiple modules.
## What good looks like
1. **Declarative Grammar Engine**:
- Unified validation of YAML frontmatter and Markdown AST sections.
## What this does not do
- Does not replace standard Markdown or YAML syntax with a proprietary binary format.
## Checkable Outcomes
1. Five comprehensive reference specification documents exist under `docs/reference/specs/` and `uv run spec-ops docs build` compiles them with zero warnings.
2. Running `uv run spec-ops schema check` validates YAML frontmatter across `docs/project/` and exits with code 0.
## Linked User Stories
- `US-0133`
- `US-0134`
## Implementing Backlog Tasks
- `TASK-0259`
- `TASK-0261`
Section Grammar Rules
| Section Heading | Requirement | Linter / Parser Regex | AST Content Contract | |
|---|---|---|---|---|
# PRD-XXXX β |
Required H1 | #\s*PRD-(\d+) |
Top-level title matching the frontmatter id and title. |
|
## Who this is for (or ## Problem Statement) |
Mandatory H2 (PRDLinter) |
`^##\s+(Who this is for\ | Problem Statement)\b` | Identifies the target persona(s) from PERSONAS.md and their operational context. |
## What the person cannot do today |
Mandatory H2 (parse_prd & shaped gate) |
`^##\s+What the person cannot do today\s\n(.?)(?=\n##\ | \Z)` | Extracted verbatim into PRD.problem_statement by parse_prd(). Describes concrete user friction and pain points. |
## What good looks like |
Mandatory H2 (PRDLinter) |
^##\s+What good looks like\b |
Enumerates the core capabilities and desired end-state architecture. | |
## What this does not do |
Mandatory H2 (PRDLinter) |
^##\s+What this does not do\b |
Explicit anti-goals, non-goals, and scope boundaries preventing multi-agent scope creep. | |
## Checkable Outcomes |
Mandatory H2 (PRDLinter & parse_prd) |
^##\s+Checkable Outcomes\b |
Contains 1 or more numbered (1. ) or bulleted (- or * ) list items. Extracted into PRD.outcomes. HTML comments () are stripped prior to validation. |
|
## Linked User Stories |
Standard H2 (parse_prd) |
US-(\d+) (global document scan) |
Bullet list of US-XXXX identifiers normalized and deduplicated into PRD.linked_stories. |
|
## Implementing Backlog Tasks |
Standard H2 (parse_prd) |
TASK-(\d+) (global document scan) |
Bullet list of TASK-XXXX identifiers normalized and deduplicated into PRD.implementing_tasks. |
5. Falsifiability Linter Grammar (`spec-ops prd lint`)
To prevent vague, untestable requirements from entering engineering decomposition, PRDLinter (src/spec_ops/prd/linter.py) inspects every list item under ## Checkable Outcomes.
Outcome Extraction Grammar
- The linter locates the line matching
^##\s+Checkable Outcomes\b(case-insensitive). - It scans subsequent lines until the next
^##\s+H2 heading or end-of-file. - Blank lines and standalone HTML comment lines (
) are skipped. - Every list item matching
^(\d+\.|\-|\*)\s+(.+)$has inline HTML comments removed and is evaluated byPRDLinter.check_subjective_terms(). - If zero list items are found under
## Checkable Outcomes, the linter emits a violation:"No checkable outcomes defined".
Forbidden Compound Phrases (`COMPOUND_PHRASES`)
Checked first via case-insensitive regular expressions:
| Regex Pattern | Matched Phrase |
|---|---|
\bclean\s+and\s+modern\b |
"clean and modern" |
\bfast\s+and\s+responsive\b |
"fast and responsive" |
\bsimple\s+and\s+intuitive\b |
"simple and intuitive" |
\bintuitive\s+and\s+easy\b |
"intuitive and easy" |
\beasy\s+to\s+use\b |
"easy to use" |
\bnoticeably\s+faster\b |
"noticeably faster" |
Forbidden Subjective Words (`SUBJECTIVE_WORDS`)
Checked second via whole-word boundary regex \b( (case-insensitive):
clean,modern,intuitive,fast,faster,responsivesimple,easy,seamless,user-friendly,user friendly,robustbeautiful,elegant,smooth,frictionless,delightful
When any forbidden phrase or word is detected in a checkable outcome, PRDLinter marks is_falsifiable=False and emits a line-accurate LintViolation:
- Message:
Subjective adjective '' is unfalsifiable - Guidance:
Replace subjective adjectives with measurable frontdoor criteria or observable CLI/API assertions
6. Product Registry Specification (`docs/project/product/REGISTRY.md`)
docs/project/product/REGISTRY.md maintains the single-table index of all PRDs across idea/, shaped/, accepted/, and shipped/. It is updated atomically whenever PRDLifecycleManager.update_registry() or update_registry_shipped() executes.
Table Structure & Column Grammar
# PRD Registry
| ID | Title | Status | Target Persona | Component |
|---|---|---|---|---|
| `PRD-0001` | SpecOps Autonomous Project Management Engine | Shipped | Alex | core |
| `PRD-0003` | Product Discovery, Web PRD Studio & Living UAT Verification | Accepted | Taylor | prd |
| `PRD-0008` | Formal Specification Grammar, Document Metamodel & Project Directory Schema Engine | Accepted | Alex, Morgan, Riley | core |
| Column Index | Column Header | Format Contract | Source Field |
|---|---|---|---|
1 |
ID |
Backtick-wrapped canonical ID: ` PRD-XXXX ` |
Normalized PRDFrontmatter.id |
2 |
Title |
Plain text title | PRDFrontmatter.title |
3 |
Status |
Title-case lifecycle stage (Idea, Shaped, Accepted, Shipped) |
PRDFrontmatter.status / directory stage |
4 |
Target Persona |
Persona name(s) | PRDFrontmatter.target_persona |
5 |
Component |
Bounded context / component slug | PRDFrontmatter.component |
When parsing or updating REGISTRY.md, rows are split on | (len(parts) == 7 including leading and trailing empty cells) and matched case-insensitively by stripping backticks from Column 1 (parts[1].replace("", "").upper() == clean_id`).
7. Customer UAT Ledger & Release Manifest Artifacts
During the accepted and shipped lifecycle stages, SpecOps tracks outcome-level business acceptance and cryptographic release provenance through two companion JSON artifacts:
Customer UAT Sign-Off Ledger (`docs/project/product/uat-signoff.json`)
Recorded via uv run spec-ops prd uat sign --prd PRD-XXXX --outcome :
{
"signoffs": {
"PRD-0008:1": {
"prd_id": "PRD-0008",
"outcome_id": "1",
"status": "Approved",
"reviewer": "Taylor (The Product Manager)",
"notes": "Verified via frontdoor tests",
"signed_at": "2026-10-15T12:00:00Z"
}
}
}
reconcile_shipping_uat_status() (src/spec_ops/prd/shipping.py) matches each 1-indexed outcome extracted from ## Checkable Outcomes against keys formatted as .
Shipped Release Manifest (`dist/releases/PRD-XXXX-release-manifest.json`)
Synthesized automatically when uv run spec-ops prd ship PRD-XXXX succeeds:
$schema:"spec-ops/release-manifest-v1"prd:{ "id": "PRD-XXXX", "title": "...", "persona": "..." }completed_tasks: Array of{ "id": "TASK-XXXX", "commit_sha": "<40-hex-sha>" }test_verification:{ "status": "Passed (CI)", "total_scenarios":, "failed_scenarios": 0 } uat_verification:{ "status": "Approved" | "Pending PM", "total_outcomes":, "approved_outcomes": }
8. CLI & Programmatic Frontdoors
Command-Line Interface
Use the following public CLI commands to scaffold, lint, validate, and promote PRD specifications:
# Scaffold a new PRD in docs/project/product/idea/
uv run spec-ops prd new --title "Capability Title" --persona "Alex" --component "core" --non-interactive
# Lint all PRDs or a specific PRD file for required sections and falsifiable outcomes
uv run spec-ops prd lint
uv run spec-ops prd lint docs/project/product/accepted/prd-0008-formal-specification-grammar--document-metamo.md
# Validate PRD YAML frontmatter against PRDFrontmatter schema v2.0
uv run spec-ops schema check docs/project/product/
# Promote a PRD across lifecycle gates and ship upon completion
uv run spec-ops prd promote PRD-0008 --stage shaped
uv run spec-ops prd promote PRD-0008 --stage accepted
uv run spec-ops prd ship PRD-0008
Python Domain & Linter Frontdoors
from pathlib import Path
from spec_ops.core.parser import parse_prd
from spec_ops.core.schema_validator import validate_document
from spec_ops.prd.linter import PRDLinter
prd_path = Path("docs/project/product/accepted/prd-0008-formal-specification-grammar--document-metamo.md")
# 1. Parse PRD into domain model (PRD.id, PRD.problem_statement, PRD.outcomes, PRD.linked_stories)
prd = parse_prd(prd_path)
# 2. Validate YAML frontmatter against PRDFrontmatter (Schema v2.0, extra="forbid")
schema_errors = validate_document(prd_path.read_text(encoding="utf-8"), file_path=prd_path)
# 3. Run structural section and falsifiability outcome linting
lint_result = PRDLinter().lint_file(prd_path)
assert lint_result.is_valid