Documentation
Purpose: Write clear, maintainable documentation for code and APIs.
Goal: Self-documenting code, useful comments, comprehensive READMEs.
Note: For implementation, see C# Development or Python Development.
When to Use This Skill
- Writing or updating README files
- Documenting APIs with OpenAPI/Swagger
- Creating architecture decision records (ADRs)
- Adding inline code documentation
- Setting up documentation tooling
Prerequisites
- Markdown formatting knowledge
Decision Tree
Documenting something?
+- New project/repo? -> README.md (setup, usage, contributing)
+- Public API?
| +- REST API -> OpenAPI/Swagger spec
| - Library -> XML docs / docstrings on all public members
+- Architecture decision? -> ADR (docs/artifacts/adr/ADR-NNN.md)
+- Complex logic?
| +- WHY it works this way -> Code comment
| - HOW to use it -> Doc comment / docstring
+- Code self-explanatory?
| - Yes -> No comment needed (good naming > comments)
- Inline comment?
+- Explains WHY (business rule, workaround) -> Keep it
- Explains WHAT (obvious from code) -> Remove it
Documentation Hierarchy
Documentation Pyramid:
/\
/API\ External API docs (OpenAPI/Swagger)
/------\
/ README \ Project documentation
/----------\
/ Inline Docs\ Function/class documentation
/--------------\
/ Code Quality \ Self-documenting code (naming, structure)
/------------------\
Best Code = Minimal comments needed
Self-Documenting Code
Code Should Explain WHAT
[FAIL] Bad: Needs comment to understand
# Check if user can access
if u.r == 1 or u.r == 2:
return True
[PASS] Good: Self-explanatory
if user.role == Role.ADMIN or user.role == Role.MODERATOR:
return True
[PASS] Better: Extract to function
if user.hasModeratorPermissions():
return True
Names Should Be Descriptive
Variables:
[FAIL] d, tmp, data, x
[PASS] daysSinceLastLogin, userCount, orderTotal
Functions:
[FAIL] process(), handle(), do()
[PASS] calculateShippingCost(), validateEmailFormat(), sendWelcomeEmail()
Classes:
[FAIL] Manager, Handler, Processor, Helper
[PASS] OrderRepository, EmailValidator, PaymentGateway
Core Rules
| Practice |
Description |
| Code first |
Write self-documenting code before adding comments |
| Document why |
Explain intent, not mechanics |
| Keep updated |
Wrong docs are worse than no docs |
| Examples |
Show, don't just tell |
| Audience |
Write for the reader, not yourself |
| Minimal |
Document what's needed, no more |
| Accessible |
Store docs near the code |
| Versioned |
Docs in repo, not external wikis |
Anti-Patterns
- Stale Docs: Documentation that contradicts current code behavior -> Tie doc updates to code changes in the same PR; add doc review to checklist
- Comment Parrot: Comments that restate the code (
i += 1 // increment i) -> Only comment WHY, never WHAT; delete comments that repeat the code
- README Novel: Putting all documentation in a single massive README -> Split into focused docs/ files (CONTRIBUTING.md, ARCHITECTURE.md) and link from README
- Tribal Knowledge: Critical setup or deployment steps live only in someone's head -> Write runbooks and onboarding guides; if you explained it twice, document it
- API Doc Drift: Hand-written API docs that diverge from actual endpoints -> Generate API docs from code annotations (OpenAPI/Swagger) and validate in CI
- TODO Graveyard: Scattering TODO comments that never get addressed -> Create issues for TODOs with deadlines; remove or resolve stale TODOs regularly
- Screenshot Docs: Using images where text would be searchable and maintainable -> Use code blocks, ASCII diagrams, or Mermaid for diagrams; reserve images for UX mockups
See Also: API Design - C# Development - Python Development
Scripts
| Script |
Purpose |
Usage |
generate-readme.py |
Auto-generate README.md from project metadata |
python scripts/generate-readme.py [--output README.md] |
Troubleshooting
| Issue |
Solution |
| Documentation out of sync with code |
Generate API docs from code annotations, add doc validation to CI |
| README too long |
Split into separate docs/ files, link from README |
| Missing API documentation |
Add doc comments to all public APIs, generate with Swagger/Redoc |
References
- Inline Docs Comments
- Readme Templates
- Api Architecture Docs
Source: jnPiyush/AgentX — distributed by TomeVault.
1---2name: documentation-183description: Write effective documentation including inline docs, README structure, API documentation, and code comments. Use when writing README files, documenting APIs, creating architecture decision records, adding inline code documentation, or setting up documentation tooling. Use when this capability is needed.4---56# Documentation78> **Purpose**: Write clear, maintainable documentation for code and APIs. 9> **Goal**: Self-documenting code, useful comments, comprehensive READMEs. 10> **Note**: For implementation, see [C# Development](../../languages/csharp/SKILL.md) or [Python Development](../../languages/python/SKILL.md).1112---1314## When to Use This Skill1516- Writing or updating README files17- Documenting APIs with OpenAPI/Swagger18- Creating architecture decision records (ADRs)19- Adding inline code documentation20- Setting up documentation tooling2122## Prerequisites2324- Markdown formatting knowledge2526## Decision Tree2728```29Documenting something?30+- New project/repo? -> README.md (setup, usage, contributing)31+- Public API?32| +- REST API -> OpenAPI/Swagger spec33| - Library -> XML docs / docstrings on all public members34+- Architecture decision? -> ADR (docs/artifacts/adr/ADR-NNN.md)35+- Complex logic?36| +- WHY it works this way -> Code comment37| - HOW to use it -> Doc comment / docstring38+- Code self-explanatory?39| - Yes -> No comment needed (good naming > comments)40- Inline comment?41 +- Explains WHY (business rule, workaround) -> Keep it42 - Explains WHAT (obvious from code) -> Remove it43```4445## Documentation Hierarchy4647```48Documentation Pyramid:4950 /\51 /API\ External API docs (OpenAPI/Swagger)52 /------\53 / README \ Project documentation54 /----------\55 / Inline Docs\ Function/class documentation56 /--------------\57 / Code Quality \ Self-documenting code (naming, structure)58/------------------\5960Best Code = Minimal comments needed61```6263---6465## Self-Documenting Code6667### Code Should Explain WHAT6869```70[FAIL] Bad: Needs comment to understand71 # Check if user can access72 if u.r == 1 or u.r == 2:73 return True7475[PASS] Good: Self-explanatory76 if user.role == Role.ADMIN or user.role == Role.MODERATOR:77 return True7879[PASS] Better: Extract to function80 if user.hasModeratorPermissions():81 return True82```8384### Names Should Be Descriptive8586```87Variables:88 [FAIL] d, tmp, data, x89 [PASS] daysSinceLastLogin, userCount, orderTotal9091Functions:92 [FAIL] process(), handle(), do()93 [PASS] calculateShippingCost(), validateEmailFormat(), sendWelcomeEmail()9495Classes:96 [FAIL] Manager, Handler, Processor, Helper97 [PASS] OrderRepository, EmailValidator, PaymentGateway98```99100---101102## Core Rules103104| Practice | Description |105|----------|-------------|106| **Code first** | Write self-documenting code before adding comments |107| **Document why** | Explain intent, not mechanics |108| **Keep updated** | Wrong docs are worse than no docs |109| **Examples** | Show, don't just tell |110| **Audience** | Write for the reader, not yourself |111| **Minimal** | Document what's needed, no more |112| **Accessible** | Store docs near the code |113| **Versioned** | Docs in repo, not external wikis |114115---116117## Anti-Patterns118119- **Stale Docs**: Documentation that contradicts current code behavior -> Tie doc updates to code changes in the same PR; add doc review to checklist120- **Comment Parrot**: Comments that restate the code (`i += 1 // increment i`) -> Only comment WHY, never WHAT; delete comments that repeat the code121- **README Novel**: Putting all documentation in a single massive README -> Split into focused docs/ files (CONTRIBUTING.md, ARCHITECTURE.md) and link from README122- **Tribal Knowledge**: Critical setup or deployment steps live only in someone's head -> Write runbooks and onboarding guides; if you explained it twice, document it123- **API Doc Drift**: Hand-written API docs that diverge from actual endpoints -> Generate API docs from code annotations (OpenAPI/Swagger) and validate in CI124- **TODO Graveyard**: Scattering TODO comments that never get addressed -> Create issues for TODOs with deadlines; remove or resolve stale TODOs regularly125- **Screenshot Docs**: Using images where text would be searchable and maintainable -> Use code blocks, ASCII diagrams, or Mermaid for diagrams; reserve images for UX mockups126127---128129**See Also**: [API Design](../../architecture/api-design/SKILL.md) - [C# Development](../../languages/csharp/SKILL.md) - [Python Development](../../languages/python/SKILL.md)130131## Scripts132133| Script | Purpose | Usage |134|--------|---------|-------|135| [`generate-readme.py`](scripts/generate-readme.py) | Auto-generate README.md from project metadata | `python scripts/generate-readme.py [--output README.md]` |136137## Troubleshooting138139| Issue | Solution |140|-------|----------|141| Documentation out of sync with code | Generate API docs from code annotations, add doc validation to CI |142| README too long | Split into separate docs/ files, link from README |143| Missing API documentation | Add doc comments to all public APIs, generate with Swagger/Redoc |144145## References146147- [Inline Docs Comments](references/inline-docs-comments.md)148- [Readme Templates](references/readme-templates.md)149- [Api Architecture Docs](references/api-architecture-docs.md)150151---152> Source: [jnPiyush/AgentX](https://github.com/jnPiyush/AgentX) — distributed by [TomeVault](https://tomevault.io).153<!-- tomevault:4.0:skill_md:2026-06-16 -->