code-commenting
Comprehensive code commenting methodology for Python projects. Use when user asks to add comments, annotations, or documentation to Python code files. Provides structured approach with module docstrings, class/function documentation, section separators, and inline comments.
Best use case
code-commenting is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Comprehensive code commenting methodology for Python projects. Use when user asks to add comments, annotations, or documentation to Python code files. Provides structured approach with module docstrings, class/function documentation, section separators, and inline comments.
Teams using code-commenting should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/code-commenting/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How code-commenting Compares
| Feature / Agent | code-commenting | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Comprehensive code commenting methodology for Python projects. Use when user asks to add comments, annotations, or documentation to Python code files. Provides structured approach with module docstrings, class/function documentation, section separators, and inline comments.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Code Commenting Skill
Add structured, professional comments to Python code files.
## Commenting Hierarchy
Add comments in the following hierarchical structure:
### 1. Module-Level Docstring
Place at the top of the file using triple quotes with separator lines:
```python
"""
============================================================================
Module Name - Brief Description
============================================================================
Detailed description of the module.
This module provides:
- Feature 1
- Feature 2
- Feature 3
Note:
Any important notes for users.
"""
```
### 2. Import Section Comments
Group imports by category using separator lines:
```python
# =============================================================================
# Standard Library Imports
# =============================================================================
import os
import random
# =============================================================================
# Third-Party Library Imports
# =============================================================================
from tqdm import tqdm
# =============================================================================
# Project Internal Imports
# =============================================================================
from myproject.core import Module
```
### 3. Section Separators
Use fixed-length separator lines to divide code blocks:
```python
# =============================================================================
# Type Aliases
# =============================================================================
ParamKey = Tuple[int, int] # (num_ue, b) - parameter combination key
# =============================================================================
# Main Functions
# =============================================================================
def main():
pass
```
### 4. Class Documentation
```python
class Metrics:
"""
Statistics Collector - Collect metrics during simulation.
Uses Welford's online algorithm for delay statistics.
Attributes:
total_requests: Total number of requests.
collision_failures: Number of collision failures.
Note:
Only data within the statistics window is recorded.
"""
def __init__(self) -> None:
"""Initialize all statistics counters."""
# Counters
self.total_requests: int = 0
```
### 5. Function Documentation
Use detailed docstrings with workflow, parameters, returns, and examples:
```python
def run_simulation(
num_ue: int,
frame: Frame,
) -> Dict:
"""
Run simulation - Brief description.
Detailed explanation of the function's purpose and behavior.
Workflow:
1. Step one
2. Step two
3. Step three
Args:
num_ue: Number of UEs.
Detailed explanation of the parameter.
frame: Frame structure configuration.
- Sub-attribute 1
- Sub-attribute 2
Returns:
Dict: Result dictionary.
- key1: Description
- key2: Description
Example:
>>> result = run_simulation(num_ue=100, frame=Frame())
>>> print(result['success_rate'])
Note:
Any important notes.
"""
```
### 6. Step-by-Step Inline Comments
For complex functions, use step-by-step structure:
```python
def complex_function():
# =========================================================================
# Stage 1: Initialization
# =========================================================================
# -------------------------------------------------------------------------
# Step 1.1: Calculate Parameters
# -------------------------------------------------------------------------
# Explain why we calculate this way
total = calculate_total()
# -------------------------------------------------------------------------
# Step 1.2: Create Instances
# -------------------------------------------------------------------------
instance = create_instance()
# =========================================================================
# Stage 2: Main Loop
# =========================================================================
for i in range(total):
# ---------------------------------------------------------------------
# Phase 1: Request Phase
# ---------------------------------------------------------------------
# Detailed explanation of what this phase does
process_request()
```
### 7. Inline Comments
```python
# Variable explanation
num_slots = 10 # m: number of request slots (paper notation)
# Condition explanation
if frame_idx < warmup_frames:
continue # Skip statistics during warmup period
# Algorithm step
delta = value - mean # Welford Step 1: Calculate delta
```
## Formatting Guidelines
### Separator Lengths
- **Major sections** (=): 77 characters total
```
# =============================================================================
```
- **Minor subsections** (-): 77 characters total
```
# -------------------------------------------------------------------------
```
### Best Practices
1. **Don't repeat the code** - Comments should explain "why", not "what"
2. **Be consistent** - Use the same commenting style throughout the project
3. **Hierarchical structure** - Use `=` for major blocks, `-` for sub-blocks
4. **Step numbering** - Use Step X.Y numbering for complex workflows
5. **Type annotations** - Add type explanations for important variables
6. **Paper references** - Note formula numbers when code implements paper equations
## Workflow
1. **Read the file** - First read the entire file to understand its structure
2. **Add module docstring** - Add module-level documentation
3. **Organize imports** - Group imports with separator lines
4. **Document classes** - Add docstrings to each class
5. **Document functions** - Add detailed docstrings to each function
6. **Add section separators** - Divide code blocks with separator lines
7. **Add inline comments** - Add inline comments for complex logic
8. **Review** - Ensure comments are complete and consistent
## Template Reference
For quick-reference templates, see [references/templates.md](references/templates.md).
## Example: Complete File Structure
```python
"""
============================================================================
Module Name - Brief Description
============================================================================
Module description.
"""
# =============================================================================
# Standard Library Imports
# =============================================================================
import os
# =============================================================================
# Project Imports
# =============================================================================
from project import Module
# =============================================================================
# Constants
# =============================================================================
MAX_VALUE = 100 # Maximum value limit
# =============================================================================
# Class Definitions
# =============================================================================
class MyClass:
"""Class description."""
pass
# =============================================================================
# Main Functions
# =============================================================================
def main():
"""Main function."""
# -------------------------------------------------------------------------
# Step 1: Initialization
# -------------------------------------------------------------------------
pass
# =============================================================================
# Module Exports
# =============================================================================
__all__ = ["MyClass", "main"]
```Related Skills
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
code-cleaner
Refactor code to remove technical debt, eliminate dead code, and enforce SOLID principles without altering runtime behavior.
code-audit
Perform a human-assisted code audit. Use when asked to audit, review architecture, document a codebase, or create technical documentation with diagrams.
code-assistant
Expert coding assistant for writing, reviewing, and debugging code across multiple languages
code-architecture-analyzer
智能代码架构解读和分析工具。当用户请求分析项目架构、生成架构文档、识别设计模式、分析依赖关系、评估代码质量、或理解复杂项目结构时使用此skill。适用于接手新项目、代码审查、重构规划、技术选型评估等场景。
code-analysis
Analyze code quality, detect code smells, identify bugs, and provide improvement recommendations. Use when reviewing code, checking quality, analyzing complexity, or when user mentions code review, refactoring suggestions, or quality assessment.
cloudrun-development
CloudBase Run backend development rules (Function mode/Container mode). Use this skill when deploying backend services that require long connections, multi-language support, custom environments, or AI agent development.
cloudflare-workers-expert
Expert in Cloudflare Workers and the Edge Computing ecosystem. Covers Wrangler, KV, D1, Durable Objects, and R2 storage.
cloudflare-api-key-automation
Automate Cloudflare API tasks via Rube MCP (Composio). Always search tools first for current schemas.
cloudbase-platform
CloudBase platform knowledge and best practices. Use this skill for general CloudBase platform understanding, including storage, hosting, authentication, cloud functions, database permissions, and data models.
cloudbase-guidelines
Essential CloudBase (TCB, Tencent CloudBase, 云开发, 微信云开发) development guidelines. MUST read when working with CloudBase projects, developing web apps, mini programs, or backend services using CloudBase platform.
cloud-storage-web
Complete guide for CloudBase cloud storage using Web SDK (@cloudbase/js-sdk) - upload, download, temporary URLs, file management, and best practices.