The skill follows a 4-phase workflow: CREATE STRUCTURE β SMART DOCUMENT CREATION β VALIDATE STRUCTURE β VALIDATE CONTENT. Phase 2 creates documents only for justified technology choices.
---
Phase 1: Create Structure
Objective: Establish reference documentation directories and README hub.
Process:
1.1 Check & create directories:
- Check if
docs/reference/adrs/ exists β create if missing - Check if
docs/reference/guides/ exists β create if missing - Check if
docs/reference/manuals/ exists β create if missing - Check if
docs/reference/research/ exists β create if missing - Log for each: "β Created docs/reference/[name]/" or "β docs/reference/[name]/ already exists"
1.2 Check & create README:
- Check if
docs/reference/README.md exists - If exists:
- Skip creation
- Log: "β docs/reference/README.md already exists, proceeding to validation"
- Copy template: ln-112-reference-docs-creator/references/reference_readme_template.md β docs/reference/README.md
- Replace placeholders:
- {{VERSION}} β "1.0.0"
- {{DATE}} β current date (YYYY-MM-DD)
- {{ADR_LIST}} β kept as placeholder (filled in Phase 4)
- {{GUIDE_LIST}} β kept as placeholder (filled in Phase 4)
- {{MANUAL_LIST}} β kept as placeholder (filled in Phase 4)
- Log: "β Created docs/reference/README.md from template"
1.3 Output:
```
docs/reference/
βββ README.md # Created or existing
βββ adrs/ # Empty, ready for ADRs
βββ guides/ # Empty, ready for guides
βββ manuals/ # Empty, ready for manuals
βββ research/ # Empty, ready for research documents
```
---
Phase 2: Smart Document Creation
Objective: Create ADRs, Guides, and Manuals for justified technology choices. Skip trivial/obvious selections.
2.1 Check Context Store:
- If no
context_store provided β skip Phase 2, proceed to Phase 3 - If no
TECH_STACK in context_store β skip Phase 2, proceed to Phase 3 - Log: "Context Store received with TECH_STACK: [categories count]"
2.2 Load Justification Rules:
- Read
references/tech_justification_rules.md - Parse category β justified/skip conditions
2.3 Analyze TECH_STACK for ADRs:
For each category in TECH_STACK (frontend, backend, database, orm, auth, cache):
- Check if justified (from justification rules):
- frontend: Justified if React/Vue/Angular/Svelte (multiple options exist)
- backend: Justified if Express/Fastify/NestJS/Koa (multiple options exist)
- database: Justified if PostgreSQL/MySQL/MongoDB (multiple options exist)
- auth: Justified if JWT/OAuth/Session (decision required)
- orm: Justified if Prisma/TypeORM/Sequelize (multiple options exist)
- cache: Justified if Redis/Memcached (decision required)
- Skip if trivial:
- jQuery-only frontend (no framework choice)
- Simple http server (no framework)
- SQLite for dev only
- No auth required
- Raw SQL only
- In-memory cache only
- Create ADR if justified:
- Determine next ADR number: adr-NNN-{category}.md
- Use template: shared/templates/adr_template.md
- MCP Research: mcp__context7__resolve-library-id(technology)
- Fill template:
- Title: "ADR-NNN: {Category} Selection"
- Context: Why decision was needed
- Decision: Technology chosen with version
- Rationale: 3 key reasons from research
- Alternatives: 2 other options with pros/cons
- Save: docs/reference/adrs/adr-NNN-{category}.md
- Log: "β Created ADR for {category}: {technology}"
- Skip if not justified:
- Log: "β Skipped ADR for {category}: trivial choice"
2.4 Analyze TECH_STACK for Guides:
For each technology with complex configuration:
- Check if justified:
- Has config file with >20 lines
- Uses custom hooks/middleware/decorators
- Has 3+ related dependencies
- Create Guide if justified:
- Determine next guide number: NN-{technology-slug}-patterns.md
- Use template: shared/templates/guide_template.md
- MCP Research: mcp__Ref__ref_search_documentation("{technology} patterns 2025")
- Fill template:
- Principle: Industry standard from research
- Our Implementation: How project uses it
- Patterns table: 3 Do/Don't/When rows
- Save: docs/reference/guides/NN-{technology}-patterns.md
- Log: "β Created Guide for {technology}"
- Skip if standard usage:
- Log: "β Skipped Guide for {technology}: standard usage"
2.5 Analyze TECH_STACK for Manuals:
For each package with complex API:
- Check if justified:
- Package has >10 exported methods
- Has breaking changes in current version
- NOT in trivial list: lodash, uuid, dotenv
- Create Manual if justified:
- Use template: shared/templates/manual_template.md
- MCP Research: mcp__context7__get-library-docs(topic: "API")
- Fill template:
- Package info with version
- 2-3 most used methods
- Configuration section
- Save: docs/reference/manuals/{package}-{version}.md
- Log: "β Created Manual for {package}"
- Skip if trivial API:
- Log: "β Skipped Manual for {package}: trivial API"
2.6 Report Smart Creation:
```
β
Smart Document Creation complete:
- ADRs created: [count] (justified: frontend, backend, database)
- ADRs skipped: [count] (trivial: cache=in-memory)
- Guides created: [count]
- Guides skipped: [count]
- Manuals created: [count]
- Manuals skipped: [count]
```
---
Phase 3: Validate Structure
Objective: Ensure reference/README.md complies with structural requirements and auto-fix violations.
Process:
2.1 Check SCOPE tag:
- Read
docs/reference/README.md (first 5 lines) - Check for
tag - Expected:
- If missing:
- Use Edit tool to add SCOPE tag at line 1 (after first heading)
- Track violation: scope_tag_added = True
2.2 Check required sections:
- Load expected sections from
references/questions.md - Required sections:
- "Architecture Decision Records (ADRs)"
- "Project Guides"
- "Package Manuals"
- "Research"
- Check if ## [Section Name] header exists
- If missing:
- Use Edit tool to add section with placeholder:
```markdown
## [Section Name]
{{PLACEHOLDER}}
```
- Track violation: missing_sections += 1
2.3 Check Maintenance section:
- Search for
## Maintenance header - If missing:
- Use Edit tool to add at end of file:
```markdown
## Maintenance
Last Updated: [current date]
Update Triggers:
- New ADRs added to adrs/ directory
- New guides added to guides/ directory
- New manuals added to manuals/ directory
Verification:
- [ ] All ADR links in registry are valid
- [ ] All guide links in registry are valid
- [ ] All manual links in registry are valid
- [ ] Placeholders {{ADR_LIST}}, {{GUIDE_LIST}}, {{MANUAL_LIST}} synced with files
```
- Track violation: maintenance_added = True
2.4 Check POSIX file endings:
- Check if file ends with single blank line
- If missing:
- Use Edit tool to add final newline
- Track fix: posix_fixed = True
2.5 Report validation:
```
β
Structure validation complete:
- SCOPE tag: [added/present]
- Missing sections: [count] sections added
- Maintenance section: [added/present]
- POSIX endings: [fixed/compliant]
```
- If violations found: "β οΈ Auto-fixed [total] structural violations"
---
Phase 4: Validate Content
Objective: Ensure each section answers its questions with meaningful content and populate registries from auto-discovery (including documents created in Phase 2).
Process:
4.1 Load validation spec:
- Read
references/questions.md - Parse questions and validation heuristics for all 3 sections
4.2 Validate sections (parametric loop):
Define section parameters:
```
sections = [
{
"name": "Architecture Decision Records (ADRs)",
"question": "Where are architecture decisions documented?",
"directory": "docs/reference/adrs/",
"placeholder": "{{ADR_LIST}}",
"glob_pattern": "docs/reference/adrs/*.md",
"heuristics": [
"Contains link: [ADRs](adrs/) or [adrs](adrs/)",
"Mentions 'Architecture Decision Record' or 'ADR'",
"Has placeholder {{ADR_LIST}} or actual list",
"Length > 30 words"
]
},
{
"name": "Project Guides",
"question": "Where are reusable project patterns documented?",
"directory": "docs/reference/guides/",
"placeholder": "{{GUIDE_LIST}}",
"glob_pattern": "docs/reference/guides/*.md",
"heuristics": [
"Contains link: [Guides](guides/) or [guides](guides/)",
"Has placeholder {{GUIDE_LIST}} or actual list",
"Length > 20 words"
]
},
{
"name": "Package Manuals",
"question": "Where are third-party package references documented?",
"directory": "docs/reference/manuals/",
"placeholder": "{{MANUAL_LIST}}",
"glob_pattern": "docs/reference/manuals/*.md",
"heuristics": [
"Contains link: [Manuals](manuals/) or [manuals](manuals/)",
"Has placeholder {{MANUAL_LIST}} or actual list",
"Length > 20 words"
]
},
{
"name": "Research",
"question": "Where are research/investigation documents stored?",
"directory": "docs/reference/research/",
"placeholder": "{{RESEARCH_LIST}}",
"glob_pattern": "docs/reference/research/*.md",
"heuristics": [
"Contains link: [Research](research/) or [research](research/)",
"Has placeholder {{RESEARCH_LIST}} or actual list",
"Length > 20 words"
]
}
]
```
For each section in sections:
- Read section content:
- Extract section from reference/README.md
- Check if content answers question:
- Apply validation heuristics
- If ANY heuristic passes β content valid, skip to next section
- If ALL fail β content invalid, continue
- Auto-discovery (if content invalid or placeholder present):
- Scan directory using Glob tool (section.glob_pattern)
- If files found:
- Extract filenames
- Generate dynamic list:
```markdown
- [ADR-001: Frontend Framework](adrs/adr-001-frontend-framework.md)
- [02-Repository Pattern](guides/02-repository-pattern.md)
- [Axios 1.6](manuals/axios-1.6.md)
```
- Use Edit tool to replace placeholder with generated list
- Track change: sections_populated += 1
- If NO files:
- Keep placeholder as-is
- Track: placeholders_kept += 1
- Skip external API calls:
- Do NOT use MCP Ref search (template already has format examples)
4.3 Report content validation:
```
β
Content validation complete:
- Sections checked: 4
- Populated from auto-discovery: [count]
- Placeholders kept (no files): [count]
- Already valid: [count]
```
---