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
seedance-prompt-en
Write effective prompts for Jimeng Seedance 2.0 multimodal AI video generation. Use when users want to create video prompts using text, images, videos, and audio inputs with the @ reference system. Covers camera movements, effects replication, video extension, editing, music beat-matching, e-commerce ads, short dramas, and educational content.
onepage-pdf
Convert an HTML page into a single continuous-page PDF (one tall page, no pagination breaks), preserving desktop layout, backgrounds and selectable text. Use when the user asks to turn an HTML file/report/proposal into a "single-page PDF", "long PDF", "不分页 PDF", "单页 PDF", "长图式 PDF", or complains that an HTML-to-PDF export breaks into pages or cuts content. Supports optional string redaction with leak verification.
native-feel-cross-platform-desktop
Use when the user is designing, prototyping, or rewriting a desktop app that must run on multiple OSes (macOS + Windows, optionally Linux) AND feel indistinguishable from a native app to its users — fast launch, native windowing, native input handling, native materials. Trigger words include "cross-platform desktop", "Electron alternative", "Tauri vs native", "WebView wrapper", "near-native performance", "Raycast architecture", "WebKit/WebView2 quirks", "WKWebView", "system tray app", "global hotkey app", "launcher app". Do NOT trigger this skill for pure web apps, pure mobile apps, or for greenfield projects that have no native-feel requirement.
gstack
Router for the gstack skill suite. (gstack)
fireworks-tech-graph
Use when the user wants to create any technical diagram - architecture, data flow, flowchart, sequence, agent/memory, or concept map - and export as SVG+PNG. Trigger on: "画图" "帮我画" "生成图" "做个图" "架构图" "流程图" "可视化一下" "出图" "generate diagram" "draw diagram" "visualize" or any system/flow description the user wants illustrated.
dbs-video-extract
接收抖音、小红书、微信视频号等短视频链接或分享文案,查询作品/账号数据并提取语音文字稿,按作者和标题归档为 Markdown。用户希望完整解析短视频、取得数据或文字稿时使用;运行前检查 TikHub 与轻抖使用凭证,缺少时用新手能理解的方式引导购买和安全配置。