一键导入
doc-inline-code
Inline code documentation skill. Adds and updates docstrings, comments, and type annotations in implementation source files without modifying logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Inline code documentation skill. Adds and updates docstrings, comments, and type annotations in implementation source files without modifying logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
基于 SOC 职业分类
| name | doc-inline-code |
| description | Inline code documentation skill. Adds and updates docstrings, comments, and type annotations in implementation source files without modifying logic. |
| argument-hint | Invoked by Docs Agent Coordinator - do not call directly |
This skill is invoked by the Docs Agent Coordinator as a subagent. It adds and updates docstrings, comments, and type annotations in implementation source files modified by the approved work package. Unlike other doc skills that write to .sdd/docs/, this skill modifies source files directly. It SHALL NOT modify implementation logic -- only documentary content (docstrings, comments, type annotations) may be added or updated.
This skill receives the following 7 inputs via the coordinator's subagent prompt, as defined in DOC-SKILL-CONTRACT.md:
| # | Input | Type | Description |
|---|---|---|---|
| 1 | skill_path | Path | Path to this SKILL.md file |
| 2 | wp_path | Path | Path to the approved WP file and its task list |
| 3 | spec_path | Path | Path to the spec file; includes contract files directory (.sdd/plans/contracts/<WP-slug>/) |
| 4 | source_files | List(Path) | Implementation source files modified by the WP |
| 5 | docs_dir | Path | Path to existing documentation directory (.sdd/docs/) for incremental updates |
| 6 | patterns | Text | Active doc-domain patterns to avoid (from .sdd/reviews/doc-patterns.md) |
| 7 | contracts_dir | Path | Path to contract files for this WP (.sdd/plans/contracts/<WP-slug>/) |
| Field | Value |
|---|---|
| Target files | Implementation source files (*.ts, *.py, *.go, *.rs, *.js, *.jsx, *.tsx) |
| Action | Update source files in-place; add missing docstrings, comments, and type annotations |
| Content | Module-level docstrings, function/method docstrings, complex logic comments, type annotations |
source_files to understand current documentation state#tool:search/usages to find symbol definitions and call sites for accurate docstrings.#tool:edit/editFiles with multi-replace mode for batch docstring additions. Call #tool:read/problems after edits to verify no syntax errors were introduced.This section is critical. Read it before making any changes to source files.
The skill SHALL NOT modify implementation logic. Only documentary content may be added or updated. This is the only doc skill that modifies source files, and it must do so with extreme care.
If you discover a bug, a code smell, or an improvement opportunity, include it in your report to the coordinator but do NOT make the change.
When a WP modifies existing source files that already have documentation:
The goal is surgical documentation updates, not wholesale rewrites.
Read the source_files list provided by the coordinator and determine which files need documentation updates.
source_files:
a. Read the file contents in full using read_file
b. Determine the file's programming language from its extension
c. Note which functions, methods, and classes exist
d. Note which already have docstrings and which are missing them
e. Note which have type annotations and which are missing them.md, .json, .yaml, .toml, .lock, .env)Before writing any docstrings, detect the project's existing docstring convention.
Read a sample of existing source files in the project (not just the WP's files) to detect the docstring style in use:
file_search or grep_search to find files with existing docstringsCheck for consistent patterns:
| Language | Convention indicators |
|---|---|
| Python | """ triple-quote style; look for :param, Args:, :returns:, Returns: to distinguish Google vs NumPy vs Sphinx style |
| TypeScript/JavaScript | /** ... */ JSDoc style; look for @param, @returns, @throws |
| Go | // FunctionName ... comment directly above function (godoc convention) |
| Rust | /// ... doc comments with markdown formatting (rustdoc convention) |
If a consistent convention is detected, use it for all new docstrings
If no existing docstrings are found (greenfield code), use the language default:
| Language | Default convention |
|---|---|
| Python | Google style (Args:, Returns:, Raises:) |
| TypeScript | JSDoc (@param, @returns, @throws) |
| JavaScript | JSDoc (@param, @returns, @throws) |
| Go | godoc (comment starts with function name) |
| Rust | rustdoc (/// with markdown) |
Record the detected convention so all docstrings in this run are consistent
Add or update module-level docstrings that describe the purpose of each file.
Python:
"""User authentication module.
Provides JWT token generation, validation, and refresh functionality
for the authentication API. Used by the auth router and middleware.
"""
TypeScript:
/**
* User authentication module.
*
* Provides JWT token generation, validation, and refresh functionality
* for the authentication API. Used by the auth router and middleware.
*/
Go:
// Package auth provides JWT token generation, validation, and refresh
// functionality for the authentication API.
package auth
Rust:
//! User authentication module.
//!
//! Provides JWT token generation, validation, and refresh functionality
//! for the authentication API. Used by the auth router and middleware.
Add or update docstrings for functions, methods, and classes that lack them.
_ in Python, not exported in TS/JS) should get docstrings if they contain complex logic; simple helpers may be skippedPython (Google style):
def refresh_token(token: str, secret: str) -> str:
"""Generate a new JWT token from an existing valid token.
Args:
token: The current JWT token to refresh.
secret: The secret key used for signing the new token.
Returns:
A new JWT token string with an extended expiration.
Raises:
TokenExpiredError: If the input token has already expired.
InvalidTokenError: If the input token is malformed.
"""
TypeScript (JSDoc):
/**
* Generate a new JWT token from an existing valid token.
*
* @param token - The current JWT token to refresh.
* @param secret - The secret key used for signing the new token.
* @returns A new JWT token string with an extended expiration.
* @throws {TokenExpiredError} If the input token has already expired.
* @throws {InvalidTokenError} If the input token is malformed.
*/
function refreshToken(token: string, secret: string): string {
Go (godoc):
// RefreshToken generates a new JWT token from an existing valid token.
// It returns a new token string with an extended expiration.
// Returns TokenExpiredError if the input token has already expired.
// Returns InvalidTokenError if the input token is malformed.
func RefreshToken(token, secret string) (string, error) {
Rust (rustdoc):
/// Generate a new JWT token from an existing valid token.
///
/// # Arguments
///
/// * `token` - The current JWT token to refresh.
/// * `secret` - The secret key used for signing the new token.
///
/// # Returns
///
/// A new JWT token string with an extended expiration.
///
/// # Errors
///
/// Returns `TokenExpiredError` if the input token has already expired.
/// Returns `InvalidTokenError` if the input token is malformed.
pub fn refresh_token(token: &str, secret: &str) -> Result<String, AuthError> {
Add comments explaining "why" for complex logic sections.
# Retry with exponential backoff because the upstream API rate-limits at 100 req/min# Retry the request (restates the code)# Use a set instead of list for O(1) lookup during deduplication# Create a set (restates the code)Add type annotations where missing and the language supports them.
Check if the language supports type annotations:
| Language | Type annotation support |
|---|---|
| Python | Yes (PEP 484 type hints: def foo(x: int) -> str:) |
| TypeScript | Yes (native: function foo(x: number): string) |
| JavaScript | No native support; use JSDoc @param {type} and @returns {type} instead |
| Go | Yes (native: func foo(x int) string) -- types are required by the compiler, so this step is usually a no-op |
| Rust | Yes (native: fn foo(x: i32) -> String) -- types are required by the compiler, so this step is usually a no-op |
For Python and TypeScript, add type annotations to:
items = [] -> items: list[Item] = [])For JavaScript, add JSDoc type annotations where missing
For Go and Rust, type annotations are mandatory and likely already present -- skip this step unless the code somehow has missing types
Infer types from:
If the type cannot be confidently determined, use the broader type (e.g., Any in Python, unknown in TypeScript) and add a # DOCFIX: narrow type comment
Before completing, verify that no implementation logic was modified.
Before completing, verify:
# DOCFIX: narrow type markers used for uncertain types (not # TODO)