// 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.
| 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. |
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."
This skill should be used when:
Determine which files need documentation:
For each file, detect the programming language by extension:
.py โ Python: Read references/python_docs.md.js, .ts, .jsx, .tsx โ JavaScript/TypeScript: Read references/javascript_typescript_docs.md.cpp, .cc, .h, .hpp, .c โ C/C++: Read references/cpp_docs.md.dart โ Dart/Flutter: Read references/dart_flutter_docs.mdIf 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.
Read the target file and identify:
Following the loaded language standards, add documentation at the standard detail level:
Key Principles:
CRITICAL: Do not modify the actual code logic, only add documentation.
Use the Edit tool to add documentation:
Make multiple small, focused edits rather than one large replacement.
After documenting:
"""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
"""
/**
* 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 {
/**
* @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);
/// Function description.
///
/// Detailed explanation if needed.
///
/// Returns description.
///
/// Throws [ExceptionType] when error occurs.
///
/// Example:
/// ```dart
/// final result = example('value');
/// ```
bool example(String param) {
User request: "Document this file"
Process:
references/python_docs.mdUser request: "Document my changes"
Process:
references/javascript_typescript_docs.mdUser request: "Add documentation to timer.h"
Process:
references/cpp_docs.mdWhen documenting multiple files:
Automatically identify what needs documentation:
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
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 documentationLoad only the relevant reference when documenting files in that language.