High-Precision Documentation Protocol
A protocol for generating in-code comments and system documentation. Uses the Diátaxis framework for external docs and enforces "explain why, not what" for inline comments.
When to Activate
- Writing or updating in-code documentation (TSDoc, PHPDoc)
- Creating system documentation in a
/docs/ folder
- Generating READMEs, tutorials, or how-to guides
- Documenting APIs, schemas, or architectural decisions
Core Concepts
- Why, not what — documentation explains reasoning, not mechanics
- Diátaxis framework — four types of docs, each with a clear purpose
- Synchronized updates — docs update in the same step as the code change
- Source-verified — read the implementation before writing about it
Detailed Guidance
In-Code Documentation (The "Reference" Layer)
Follow the recursive principle: documentation must explain why, not what.
- TypeScript: Use TSDoc. Explicitly document generics, complex union types, and interface contracts found in the project.
- PHP: Use PHPDoc. Mandatory
@throws for all identified exceptions in the call chain.
- Synchronization: Documentation must be updated in the same "Baby Step" as the code change.
System Documentation (The /docs/ Folder)
When generating files for the project's /docs/ directory, strictly apply the Diátaxis Framework:
A. Tutorials (Learning-oriented)
- Focus: "Learning by doing". Abstract complexity to guarantee a successful first run.
B. How-To Guides (Problem-oriented)
- Focus: "Solving a specific task". Steps for real-world goals (e.g., "Adding a new Payment Gateway").
C. Explanations (Understanding-oriented)
- Focus: "Concepts and Architecture". Discuss recursive dependencies, design patterns, and system constraints.
D. Reference (Information-oriented)
- Focus: "Technical facts". Exhaustive descriptions of APIs, schemas, and classes.
Recursive Context Check
Before writing any documentation:
- Source Trace: Read the actual implementation to ensure the documentation is technically accurate.
- Global Context: Search the
./docs/ folder for existing guides to avoid duplication and maintain a consistent voice.
- Link Verification: Ensure all file paths and cross-references between
./docs/ and source code are valid.
Tone & Style
- The Invisible Author: Objective, clear, and concise. No fluff.
- Visuals: Use Mermaid.js for architecture diagrams if the recursive logic spans more than 3 calls.
Examples
Good inline comment (why):
// Retry up to 3 times because the payment gateway occasionally returns
// transient 503 errors during high-traffic windows.
const result = await retry(3, () => gateway.charge(amount));
Bad inline comment (what):
// Charge the amount using the gateway
const result = await gateway.charge(amount);
Guidelines
- Explain why, never what — the code already shows what
- TSDoc for TypeScript, PHPDoc for PHP — no exceptions
- Document
@throws for all exceptions in the call chain (PHP)
- Update docs in the same step as the code change
- Apply Diátaxis: tutorials, how-to guides, explanations, reference
- Read the implementation before writing about it
- Check for existing docs before creating new ones
Integration
- Related:
typescript-standard (TSDoc conventions), php-standard (PHPDoc conventions), recursive-exploration (source tracing)
Skill Metadata
- Created: 2025-06-01
- Last Updated: 2025-07-01
- Author: didacrios
- Version: 1.0.0
1---2name: documentation3description: Activate when generating in-code comments or system documentation using the Diátaxis framework.4---56# High-Precision Documentation Protocol78A protocol for generating in-code comments and system documentation. Uses the Diátaxis framework for external docs and enforces "explain why, not what" for inline comments.910## When to Activate11- Writing or updating in-code documentation (TSDoc, PHPDoc)12- Creating system documentation in a `/docs/` folder13- Generating READMEs, tutorials, or how-to guides14- Documenting APIs, schemas, or architectural decisions1516## Core Concepts17- **Why, not what** — documentation explains reasoning, not mechanics18- **Diátaxis framework** — four types of docs, each with a clear purpose19- **Synchronized updates** — docs update in the same step as the code change20- **Source-verified** — read the implementation before writing about it2122## Detailed Guidance2324### In-Code Documentation (The "Reference" Layer)25Follow the recursive principle: documentation must explain **why**, not **what**.26- **TypeScript:** Use TSDoc. Explicitly document generics, complex union types, and interface contracts found in the project.27- **PHP:** Use PHPDoc. Mandatory `@throws` for all identified exceptions in the call chain.28- **Synchronization:** Documentation must be updated in the same "Baby Step" as the code change.2930### System Documentation (The `/docs/` Folder)31When generating files for the project's `/docs/` directory, strictly apply the **Diátaxis Framework**:3233#### A. Tutorials (Learning-oriented)34- Focus: "Learning by doing". Abstract complexity to guarantee a successful first run.3536#### B. How-To Guides (Problem-oriented)37- Focus: "Solving a specific task". Steps for real-world goals (e.g., "Adding a new Payment Gateway").3839#### C. Explanations (Understanding-oriented)40- Focus: "Concepts and Architecture". Discuss recursive dependencies, design patterns, and system constraints.4142#### D. Reference (Information-oriented)43- Focus: "Technical facts". Exhaustive descriptions of APIs, schemas, and classes.4445### Recursive Context Check46Before writing any documentation:471. **Source Trace:** Read the actual implementation to ensure the documentation is technically accurate.482. **Global Context:** Search the `./docs/` folder for existing guides to avoid duplication and maintain a consistent voice.493. **Link Verification:** Ensure all file paths and cross-references between `./docs/` and source code are valid.5051### Tone & Style52- **The Invisible Author:** Objective, clear, and concise. No fluff.53- **Visuals:** Use Mermaid.js for architecture diagrams if the recursive logic spans more than 3 calls.5455## Examples5657**Good inline comment (why):**58```typescript59// Retry up to 3 times because the payment gateway occasionally returns60// transient 503 errors during high-traffic windows.61const result = await retry(3, () => gateway.charge(amount));62```6364**Bad inline comment (what):**65```typescript66// Charge the amount using the gateway67const result = await gateway.charge(amount);68```6970## Guidelines711. Explain **why**, never **what** — the code already shows what722. TSDoc for TypeScript, PHPDoc for PHP — no exceptions733. Document `@throws` for all exceptions in the call chain (PHP)744. Update docs in the same step as the code change755. Apply Diátaxis: tutorials, how-to guides, explanations, reference766. Read the implementation before writing about it777. Check for existing docs before creating new ones7879## Integration80- Related: `typescript-standard` (TSDoc conventions), `php-standard` (PHPDoc conventions), `recursive-exploration` (source tracing)8182## Skill Metadata83- Created: 2025-06-0184- Last Updated: 2025-07-0185- Author: didacrios86- Version: 1.0.0