Agent skill
af-enforce-doc-standards
Enforce AgentFlow documentation standards for frontmatter, linking, and structure. Use when validating documentation compliance, checking bidirectional links, or auditing file organization and markup patterns.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/af-enforce-doc-standards
SKILL.md
Documentation Standards Expertise
Essential Reading
⚠️ BEFORE creating documentation, read this comprehensive guide:
@.claude/docs/guides/documentation-system.md
This guide explains:
- Three-layer documentation pattern (Asset → Index → Reference)
- When to create guides vs asset documentation
- Complete workflows for all documentation scenarios
- Edge cases and troubleshooting
Without reading this guide first, you will create incomplete documentation.
When to Use This Skill
Invoke this skill when:
- Creating any new
.mdfile (guides, specs, documentation) - Adding framework components (agents, skills, commands, orchestrators)
- Validating documentation before commits
- Fixing broken links or metadata issues
- Updating existing documentation after code changes
- Setting up documentation in brownfield projects
Rules: FOLLOW THESE
Frontmatter Rules
- All
.mdfiles MUST have frontmatter with required fields - Required fields:
title,created,updated,last_checked,tags - At least ONE linking field required:
parent,children,code_files, orrelated - Dates MUST be YYYY-MM-DD format
- Tags MUST be an array with at least one tag
last_checkedMUST be within 30 days (or document is stale)- Agent files NEED dual frontmatter: Claude Code registration + AgentFlow documentation
- Skill files NEED minimal frontmatter: Only Claude Code registration fields
- Quote YAML special characters: Values with
< > [ ] : { }must be quoted
Linking Rules
- Every child MUST declare its parent in frontmatter
- Every parent MUST list its children in children array
- Parent-child relationships MUST be bidirectional and reciprocal
- All referenced paths MUST exist (no broken links)
- Use relative paths only (never absolute paths)
- Only these files can have no parent:
.claude/README.md,.claude/docs/README.md,docs/README.md,README.md - Use
relatedfield for peer relationships (not parent-child) - Cross-directory links use
relatedfield not parent-child
Code Documentation Rules
- All TypeScript/JavaScript MUST have JSDoc comment blocks
- All code MUST include
@documentationtag pointing to guide - Use
@requirementstag to link to BDD feature files (when applicable) - Use
@adrtag to reference architecture decisions (when applicable)
Quality Rules
- Complete over concise - No artificial size limits on documentation
- Update
updateddate when changing content - Update
last_checkedeven if content unchanged (proves review happened) - README.md files MUST list all children in their directory
- Files in
.claude/work/are exempt from linking and freshness rules
Workflows
Workflow: Creating Documentation for New Features
When implementing a new feature (BDD workflow):
- Refinement Phase - BDD scenarios, mini-PRD, visual specs
- Implementation Phase - Write code with JSDoc, include
@documentationtags - Documentation Phase - Create guides in
/docs/guides/, API docs in/docs/api/ - Validation Phase - Run validation scripts and docs-quality-agent
Key principle: Documentation created BEFORE code (Refinement), then enhanced DURING implementation, then validated AFTER completion.
Example structure:
docs/requirements/mini-prd/auth.md # Refinement phase (contains Markdown scenarios)
src/lib/auth.ts # Implementation phase (with TSDoc)
docs/guides/authentication.md # Documentation phase
docs/api/auth-endpoints.md # Documentation phase
Workflow: Adding Framework Components
When adding agents, skills, commands, or orchestrators:
- Create asset file with proper frontmatter (include parent field)
- Update parent's children array to include new asset
- Run validation:
npx ts-node .claude/scripts/validate-links.ts - Run docs-quality-agent for semantic validation
Critical: Both steps (add parent reference, update children array) are required for bidirectional linking.
Workflow: Updating Existing Documentation
When code changes require doc updates:
- Identify affected docs - Check
@documentationtags in changed code - Update content - Modify docs to reflect changes, update examples
- Update metadata - Increment
updatedandlast_checkeddates - Validate changes - Run
validate-frontmatter.tsandvalidate-links.ts - Update related docs - Check
relatedfield for connected documents
Common mistake: Forgetting to update last_checked even when content hasn't changed.
Workflow: Validating Documentation
Before committing documentation changes:
-
Run validation scripts:
validate-frontmatter.ts- Check metadata compliancevalidate-links.ts- Check bidirectional linksvalidate-tsdoc.ts- Check code documentationcheck-stale-docs.ts- Check for outdated docs
-
Review output - Fix errors (missing fields, broken links)
-
Run docs-quality-agent - Semantic content validation
-
Fix issues iteratively - Infrastructure first, then metadata, then content
-
Re-validate until clean - All scripts pass, agent confirms quality
Workflow: Migrating Legacy Documentation
When adding documentation to brownfield projects:
- Audit existing docs - Identify all
.mdfiles, assess coverage - Add frontmatter - Use
repair-frontmatter.tsfor batch updates - Create README indexes - Add navigation to each directory
- Fill gaps - Generate missing reference documentation
- Establish baseline - Run validation scripts, fix critical issues
- Set up continuous validation - Add to CI/CD, configure hooks
Common Patterns
Two-Layer Pattern (Framework .claude/)
- Asset Documentation - Self-documenting files next to assets
- Index Documentation - README.md files for navigation
Three-Layer Pattern (Project docs/)
- Code Documentation - Inline TSDoc/JSDoc in source files
- Index Documentation - README.md navigation files
- Reference Documentation - Comprehensive guides in
/docs/
Handling Edge Cases
Circular references: Choose one as parent, use related for the other
Multiple parents: Choose primary parent, use related for others
Orphaned docs: Add to parent's children or move to .claude/work/
Cross-directory links: Use related field, not parent-child
Deprecated features: Move to docs/deprecated/, add deprecation notice
Examples
Good: Complete Frontmatter
---
title: Authentication System Guide
created: 2025-12-09
updated: 2025-12-09
last_checked: 2025-12-09
tags: [authentication, security, guide]
parent: ./README.md
related:
- ../api/auth-endpoints.md
- ../../.claude/docs/guides/security.md
---
Bad: Missing Required Fields
---
title: My Doc
# Missing: created, updated, last_checked
# Missing: at least one linking field
---
Good: Bidirectional Linking
# Parent: .claude/agents/README.md
children:
- ./bdd-agent.md
# Child: .claude/agents/bdd-agent.md
parent: .claude/agents/README.md
Bad: Unidirectional Linking
# Parent: .claude/agents/README.md
# (missing children array)
# Child: .claude/agents/bdd-agent.md
parent: .claude/agents/README.md # Parent doesn't list this!
Good: Code Documentation
/**
* Authenticates user with credentials
*
* @documentation /docs/guides/authentication.md
* @requirements /docs/requirements/mini-prd/auth.md
* @adr /docs/architecture/adr/adr-015-auth-strategy.md
*/
export function authenticate(credentials: Credentials): Promise<User>
Bad: Missing @documentation Tag
/**
* Authenticates user with credentials
* (No @documentation tag - how do users learn about this?)
*/
export function authenticate(credentials: Credentials): Promise<User>
Detailed Reference
For complete documentation patterns: Read @.claude/docs/guides/documentation-system.md (REQUIRED reading)
For full specification: See .claude/docs/standards/documentation-standards.md
For validation process: See .claude/skills/af-validate-quality/SKILL.md
For validation scripts: See .claude/scripts/documentation/README.md
For templates: See .claude/templates/ (glossary, mini-PRD, ADR templates)
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?