comment-generator
Generate code comments and docstrings. Use when user asks to "add comments", "document this code", "explain with comments", or "add docstrings".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate code comments and docstrings. Use when user asks to "add comments", "document this code", "explain with comments", or "add docstrings".
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Comprehensive Three.js and React Three Fiber skill for creating 3D scenes, characters, NPCs, procedural generation, animation retargeting, and interactive experiences. Use when user asks to "create Three.js scene", "setup React Three Fiber", "add 3D character", "create NPC AI", "procedural 3D generation", "retarget animation", "setup avatar system", or "create 3D game".
Organizes and sorts import statements in code files. Use when imports are messy or need organization.
Generates comprehensive API documentation including OpenAPI/Swagger specs, endpoint descriptions, request/response examples, and integration guides. Use when documenting APIs.
Creates database migrations with proper schema changes, data migrations, and rollback support for various ORMs (Prisma, TypeORM, Alembic, etc.). Use when managing database schema changes.
Generates Express.js API routes with proper middleware, error handling, validation, and TypeScript support. Use when creating REST APIs or Express endpoints.
Generates FastAPI endpoints with proper Pydantic models, dependency injection, async handlers, and OpenAPI documentation. Use when building Python REST APIs.
| name | comment-generator |
| description | Generate code comments and docstrings. Use when user asks to "add comments", "document this code", "explain with comments", or "add docstrings". |
| allowed-tools | ["Read","Edit"] |
Automatically generates clear, helpful comments for code.
This skill activates when the user wants to add comments to their code:
Determine the programming language from:
JavaScript/TypeScript:
/**
* Calculates the sum of two numbers
* @param {number} a - First number
* @param {number} b - Second number
* @returns {number} The sum
*/
function add(a, b) {
return a + b;
}
Python:
def add(a, b):
"""
Calculates the sum of two numbers.
Args:
a (int): First number
b (int): Second number
Returns:
int: The sum of a and b
"""
return a + b
Java:
/**
* Calculates the sum of two numbers
* @param a First number
* @param b Second number
* @return The sum
*/
public int add(int a, int b) {
return a + b;
}
For functions/methods:
For classes:
For complex logic:
✅ Good comments:
❌ Bad comments:
// Add a and b
function add(a, b) {
return a + b; // Return the sum
}
✅ Better:
/**
* Combines two monetary values, useful for calculating totals
* Handles floating point precision for currency
*/
function add(a, b) {
return Math.round((a + b) * 100) / 100; // Round to 2 decimals
}
Input:
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
Output:
/**
* Calculates the total price of all items in a collection
* @param {Array<{price: number}>} items - Array of items with price property
* @returns {number} Total price of all items
* @example
* const total = calculateTotal([{price: 10}, {price: 20}]); // Returns 30
*/
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
Input:
def process_data(data, filters=None):
if not filters:
filters = []
result = []
for item in data:
valid = True
for f in filters:
if not f(item):
valid = False
break
if valid:
result.append(item)
return result
Output:
def process_data(data, filters=None):
"""
Filters a dataset using multiple filter functions.
Applies each filter function to every item in the dataset.
Only items that pass all filters are included in the result.
Args:
data (list): Collection of items to filter
filters (list of callable, optional): Filter functions that return True/False.
Defaults to empty list (no filtering).
Returns:
list: Filtered dataset containing only items that passed all filters
Example:
>>> data = [1, 2, 3, 4, 5]
>>> is_even = lambda x: x % 2 == 0
>>> is_positive = lambda x: x > 0
>>> process_data(data, [is_even, is_positive])
[2, 4]
"""
if not filters:
filters = []
result = []
for item in data:
valid = True
# Apply each filter - item must pass all filters
for f in filters:
if not f(item):
valid = False
break # Skip remaining filters if one fails
if valid:
result.append(item)
return result
❌ Don't comment obvious code:
// Increment i
i++;
❌ Don't duplicate code in comments:
// Set name to "John"
name = "John";
❌ Don't leave outdated comments:
// TODO: Fix this next week
// (Written 2 years ago)