@prd — PRD Generation Skill
Generate and maintain PROJECT_MAP.md PRD documents with automatic diagram generation.
Usage
code
@prd "hw-checker"
What This Skill Does
- •Detects project type (service/library/cli) from file structure
- •Scaffolds PRD with appropriate sections for the project type
- •Generates diagrams from @prd annotations in code
- •Validates section limits and format
- •Updates frontmatter with diagrams_hash
Workflow
Initial Creation (@prd "project-name")
- •Analyze project structure for type detection
- •Present detected type and allow override
- •Guide through filling each PRD section interactively
- •Create
docs/PROJECT_MAP.mdwith frontmatter - •Generate initial diagram templates
- •Validate output
Update Mode (@prd "project-name" --update)
- •Parse all @prd annotations from code
- •Regenerate diagrams from annotations
- •Calculate new diagrams_hash
- •Update PROJECT_MAP.md frontmatter
- •Run validation checks
- •Report changes
Project Types
| Type | Trigger | Sections |
|---|---|---|
| service | docker-compose.yml exists | 7 sections with API, DB, Monitoring |
| library | default (no docker/cli) | 7 sections with Public API, Usage Examples |
| cli | cli.py with Click/Typer | 7 sections with Command Reference, Exit Codes |
Section Limits
The following limits are enforced during validation:
- •"Назначение": max 500 characters
- •"Модель БД": 1 line per field (max 120 chars per line)
- •Other sections: format-specific limits
Diagram Generation
Diagrams are generated from code annotations:
Python
python
from sdp.prd import prd_flow, prd_step
@prd_flow("submission-processing")
@prd_step(1, "Receive submission from queue")
async def process_submission(self, job: Job) -> RunResult:
"""Process single submission through SAGA orchestrator."""
...
Bash/YAML
bash
# @prd: flow=submission-processing, step=2, desc=Clone repository git clone "$url" "$workspace"
Generated Files
- •
docs/diagrams/sequence-{flow_name}.mmd- Mermaid diagram - •
docs/diagrams/sequence-{flow_name}.puml- PlantUML diagram - •
docs/diagrams/component-overview.mmd- Component template - •
docs/diagrams/deployment-production.puml- Deployment template
Validation Rules
The following validation checks are performed:
- •Frontmatter completeness: project_type, prd_version, last_updated
- •Section limits: Character counts and format rules
- •Diagram freshness: diagrams_hash matches current annotations
Implementation
The skill uses the following modules:
- •
sdp.src.sdp.prd.profiles- PRD profiles and sections - •
sdp.src.sdp.prd.detector- Project type auto-detection - •
sdp.src.sdp.prd.scaffold- PRD template generation - •
sdp.src.sdp.prd.validator- Section validation - •
sdp.src.sdp.prd.parser_python- Python annotation parser - •
sdp.src.sdp.prd.parser_bash- Bash annotation parser - •
sdp.src.sdp.prd.generator_mermaid- Mermaid diagram generator - •
sdp.src.sdp.prd.generator_plantuml- PlantUML diagram generator
Quality Gates
Before considering a PRD complete:
- • All 7 sections filled for detected project type
- • "Назначение" section ≤ 500 characters
- • Frontmatter contains project_type, prd_version, last_updated
- • diagrams_hash set (after diagram generation)
- • All diagrams generated and saved to docs/diagrams/
- • Validation passes without errors
Related Commands
- •
/codereview- Checks PRD freshness via diagrams_hash - •
/design- Creates feature design (can use PRD as input) - •
/build- Implements workstreams (can reference PRD sections)
Example Session
code
User: @prd "hw-checker" Assistant: Let me help you create a PRD for hw-checker. Analyzing project structure... ✓ Detected: service (docker-compose.yml found) I'll create a PRD with 7 sections for a service profile: 1. Назначение (max 500 chars) 2. Глоссарий 3. Внешний API 4. Модель БД 5. Sequence Flows 6. Внешние зависимости 7. Мониторинги Let's start with section 1: Назначение What is the primary purpose of hw-checker? Please describe in 1-2 sentences. [Interactive dialog continues for all sections...] ✓ PRD created: tools/hw_checker/docs/PROJECT_MAP.md ✓ Diagrams generated: 4 files in docs/diagrams/ ✓ Validation passed Next steps: 1. Add @prd annotations to key code files 2. Run @prd "hw-checker" --update to regenerate diagrams
Context Files
- •
docs/PROJECT_MAP.md- The PRD document - •
docs/diagrams/*.mmd- Mermaid diagrams - •
docs/diagrams/*.puml- PlantUML diagrams - •
docs/workstreams/backlog/00-011-*.md- Feature F011 workstreams