code-documenter
Automatically detect and add comprehensive documentation to code files across multiple languages (Python, JavaScript/TypeScript, C/C++, Dart/Flutter). Generate language-appropriate docstrings, comments, and examples following industry standards. Use when code files lack documentation, after implementing new features, or when requested to document code. Support single files and batch documentation.
- License 许可
- MIT
- 最近更新
- 2026-11-01
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- code-documenter
- description
- Automatically detect and add comprehensive documentation to code files across multiple languages (Python, JavaScript/TypeScript, C/C++, Dart/Flutter). Generate language-appropriate docstrings, comments, and examples following industry standards. Use when code files lack documentation, after implementing new features, or when requested to document code. Support single files and batch documentation.
02 资源文件 4
- 参考文档references/cpp_docs.md7.3 KB
- 参考文档references/dart_flutter_docs.md11.1 KB
- 参考文档references/javascript_typescript_docs.md5.2 KB
- 参考文档references/python_docs.md3.3 KB
03 SKILL.md 正文
Code Documenter
Overview
Add or update professional documentation to code files following language-specific best practices and industry conventions. Reduce cognitive load by providing clear, well-structured documentation that explains "why" rather than just "what."
Related Tools
This skill focuses on code-level documentation (docstrings, inline comments).
For project-level documentation, use:
/doc-generate- Generate API docs, architecture diagrams, README filescode-documentationplugin - Automated project documentation workflows
Decision: Use this skill for code, plugin for projects.
Supported Languages
- Python: PEP 257 docstrings with type hints (Google/NumPy style)
- JavaScript/TypeScript: JSDoc/TSDoc comments with examples
- C/C++: Doxygen-style documentation with memory safety notes
- Dart/Flutter: Triple-slash comments with widget documentation
When to Use This Skill
This skill should be used when:
- Explicit request: User asks to "document this code" or "add documentation"
- Auto-detection scenarios:
- New code has been written without documentation
- Existing code lacks adequate docstrings/comments
- Public APIs are undocumented
- Complex logic needs explanation
- After code changes: When implementing features or fixing bugs
- Before commits: When preparing code for review
Documentation Workflow
Step 1: Identify Files to Document
Determine which files need documentation:
- If user provides file path(s), use those specific files
- If user says "document my changes," check git status for modified files
- If user says "document this," use the file currently in context
- For "document everything," ask user to confirm scope
Step 2: Detect Language and Load Standards
For each file, detect the programming language by extension:
.py→ Python: Readreferences/python_docs.md.js, .ts, .jsx, .tsx→ JavaScript/TypeScript: Readreferences/javascript_typescript_docs.md.cpp, .cc, .h, .hpp, .c→ C/C++: Readreferences/cpp_docs.md.dart→ Dart/Flutter: Readreferences/dart_flutter_docs.md
If language is unsupported, inform user and skip the file.
Load only the relevant reference file into context to avoid token waste. Do not load all language references at once.
Step 3: Analyze Code Structure
Read the target file and identify:
- Top-level documentation: Module/file docstring
- Classes/Interfaces: Class documentation, attributes, purpose
- Functions/Methods: Parameter descriptions, return values, exceptions
- Complex logic: Areas needing inline comments
- Constants/Enums: Purpose and usage documentation
Step 4: Apply Documentation Standards
Following the loaded language standards, add documentation at the standard detail level:
- Document all public APIs (classes, functions, methods)
- Add module/file-level documentation
- Include parameter and return value descriptions
- Add inline comments for non-obvious logic
- Skip private methods unless they're complex
- Include usage examples for complex APIs
Key Principles:
- First line should be a concise one-line summary
- Explain "why" in comments, not "what"
- Use proper formatting for the language (PEP 257, JSDoc, Doxygen, etc.)
- Include type information where applicable
- Add examples for complex usage patterns
- Note side effects, thread safety, memory ownership
Step 5: Preserve Code Logic
CRITICAL: Do not modify the actual code logic, only add documentation.
- Add docstrings/comments without changing functionality
- Preserve existing formatting and style
- Keep all existing code intact
- Only add documentation blocks and inline comments
Step 6: Apply Changes
Use the Edit tool to add documentation:
- For module/file documentation: Add at the very top of the file
- For class documentation: Add immediately before class definition
- For function documentation: Add immediately before function definition
- For inline comments: Add on line above or at end of complex statements
Make multiple small, focused edits rather than one large replacement.
Step 7: Verify and Report
After documenting:
- Confirm all public APIs are documented
- Check that complex logic has explanatory comments
- Verify formatting matches language conventions
- Report summary to user:
- Files documented
- Documentation elements added (modules, classes, functions)
- Any issues or skipped items
Language-Specific Quick Reference
Python
"""Module-level docstring explaining purpose."""
class Example:
"""Class docstring with purpose.
Attributes:
attr_name: Description with type info
"""
def method(self, param: str) -> bool:
"""One-line description.
Args:
param: Parameter description
Returns:
Return value description
Raises:
ExceptionType: When this occurs
"""
JavaScript/TypeScript
/**
* Function description.
*
* @param param - Parameter description
* @returns Return value description
* @throws {ErrorType} When error occurs
*
* @example
* ```typescript
* const result = example('value');
* ```
*/
function example(param: string): boolean {
C/C++
/**
* @file filename.h
* @brief Brief file description
*/
/**
* @brief Function description
*
* @param param Parameter description
* @return Return value description
*
* @warning Important warnings
* @threadsafe Thread safety information
*/
bool example(const std::string& param);
Dart/Flutter
/// Function description.
///
/// Detailed explanation if needed.
///
/// Returns description.
///
/// Throws [ExceptionType] when error occurs.
///
/// Example:
/// ```dart
/// final result = example('value');
/// ```
bool example(String param) {
Examples
Example 1: Document Single Python File
User request: "Document this file"
Process:
- Detect file is Python (.py extension)
- Read
references/python_docs.md - Analyze file structure (modules, classes, functions)
- Add PEP 257 docstrings following Google style
- Add inline comments for complex logic
- Report: "Added module docstring, 3 class docstrings, 12 function docstrings, and 8 inline comments"
Example 2: Document Changed TypeScript Files
User request: "Document my changes"
Process:
- Check git status for modified .ts/.tsx files
- For each file: detect TypeScript
- Read
references/javascript_typescript_docs.md - Add JSDoc comments to new/modified functions
- Update existing docstrings if signatures changed
- Report: "Documented 5 TypeScript files with 23 functions"
Example 3: Document C++ Header
User request: "Add documentation to timer.h"
Process:
- Detect C++ from .h extension
- Read
references/cpp_docs.md - Add file-level @file and @brief
- Document all public classes and methods
- Add @note for thread safety, memory ownership
- Report: "Added file header, 2 class docs, 15 method docs with threading notes"
Advanced Features
Batch Documentation
When documenting multiple files:
- Group files by language to minimize reference file loading
- Process all Python files, then JavaScript, then C++, etc.
- Load each language reference only once
- Report progress: "Documenting file 3 of 8..."
- Provide summary at end with breakdown by language
Smart Detection of Documentation Needs
Automatically identify what needs documentation:
- Missing module docstrings: Top of file has no documentation
- Undocumented public APIs: Classes/functions lack docstrings
- Complex logic: Code blocks with high cyclomatic complexity
- Recent changes: Functions modified in recent commits
- TODO/FIXME comments: Areas marked for attention
Handling Edge Cases
Mixed languages in project: Document each file in its native style
Partially documented code: Fill in gaps without duplicating existing docs
Generated code: Skip auto-generated files (ask user if uncertain)
Test files: Use simpler documentation (purpose and what is tested)
Legacy code: Add minimal documentation first, suggest comprehensive pass
Best Practices
- Read the file first: Always read the target file before documenting
- Load references as needed: Don't load all language references at once
- Multiple small edits: Make focused edits rather than large replacements
- Preserve formatting: Match existing code style and indentation
- Explain "why" not "what": Focus comments on reasoning, not mechanics
- Include examples: Add usage examples for complex APIs
- Note constraints: Document preconditions, thread safety, ownership
- Update existing docs: If code changed, update related documentation
Resources
references/
Language-specific documentation standards:
python_docs.md- PEP 257 conventions, type hints, Google/NumPy stylejavascript_typescript_docs.md- JSDoc/TSDoc standards with examplescpp_docs.md- Doxygen conventions, thread safety, memory managementdart_flutter_docs.md- Dart doc comments, Flutter widget documentation
Load only the relevant reference when documenting files in that language.
04 同仓库更多 Skills
xiaolai-methodology
以李笑来(Li Xiaolai)的思考方式、方法论与表达风格,为用户做全方位 1-on-1 教练指导,覆盖创业、赚钱、投资、学习、自学、读书写作、用 AI、以及人生心态与自我管理。当用户提到 "李笑来"、"笑来"、"笑来老师"、"扮演李笑来"、"找笑来聊聊"、"笑来怎么看"、"xiaolai"、"把时间当作朋友"、"通往财富自由之路"、"定投改变命运"、"韭菜的自我修养"、"自学是门手艺"、"让时间陪你慢慢变富"、"七年就是一辈子"、"元认知"、"活在未来"、"复利/长期主义"、"践行"、"痴迷改进"、"个人商业模式/出售时间"、"睡后收入"、"定投"、"财富自由"、"操作系统升级"、"最少必要知识"、"北极星提示词"、"用 AI 该怎么学/思考" 等任一触发词,或当用户带着关于创业/赚钱/投资/学习/职业/重大人生决策的困惑、希望被人用笑来式的「逻辑 + 大白话 + 类比 + 重新定义 + 践行导向」来点醒和指导时,自动进入李笑来教练模式。
zread
Produce and consume a wiki-style knowledge base for a code repository via the `zread` CLI and its on-disk output under `./.zread/wiki/`. Use this skill whenever the user wants to understand, onboard onto, explore, summarize, map, or get an overview of an unfamiliar codebase; asks for architecture docs, a project wiki, a repo walkthrough, module/package explanations, or "what does this repo do"; wants to generate, regenerate, resume, browse, or serve code documentation locally; or mentions zread / zread.ai directly. Also use it proactively before diving into a large unknown repo — if `./.zread/wiki/current` exists, read the generated pages instead of crawling source file-by-file; if it doesn't, consider offering to run `zread generate`. The trigger is the intent (understand a codebase through generated docs), not the literal word "zread".
youtube
Launch the YouTube Creator Agent to auto-generate videos. Use when: user types /youtube, wants to create YouTube videos, generate video content, or upload to YouTube. Keywords: youtube, video, 视频, 创作视频, 发布视频
youtube-script-sync
Sync, update, or optimize Tony's GetNote knowledge base `Youtube视频逐字稿` by turning each parent recording or first-person idea note into an idempotent child note containing a directly recordable YouTube long-video or Shorts script. Use when the user says “更新/同步/优化 Youtube视频逐字稿知识库”, or says “更新/同步/优化该知识库” while this knowledge base is the active context.
writing-skills
How to write SKILL.md files that trigger reliably and teach effectively. Use when creating, improving, or reviewing Claude Code skills.
writing-rules
How to write .claude/rules/ files that Claude actually follows. Use when creating, improving, or reviewing project rules.