code-documenter
生成、格式化和验证技术文档——包括 docstrings、OpenAPI/Swagger 规范、JSDoc 注释、文档门户和用户指南。适用于为函数或类添加 docstrings、创建 API 文档、构建文档站点或编写教程和用户指南。用于 OpenAPI/Swagger 规范、JSDoc、文档门户、入门指南。
- License 许可
- MIT
- 最近更新
- 2026-06-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- code-documenter
- license
- MIT
- metadata
- { "role": "specialist", "scope": "implementation", "author": "https://github.com/Jeffallan", "domain": "quality", "version": "1.1.0", "triggers": "documentation, docstrings, OpenAPI, Swagger, JSDoc, comments, API docs, tutorials, user guides, doc site", "output-format": "code", "related-skills": "spec-miner, fullstack-guardian, code-reviewer" }
- description
- 生成、格式化和验证技术文档——包括 docstrings、OpenAPI/Swagger 规范、JSDoc 注释、文档门户和用户指南。适用于为函数或类添加 docstrings、创建 API 文档、构建文档站点或编写教程和用户指南。用于 OpenAPI/Swagger 规范、JSDoc、文档门户、入门指南。
02 资源文件 17
- 参考文档evals/evals.json83.0 KB
- 参考文档references/api-docs-fastapi-django.md4.1 KB
- 参考文档references/api-docs-nestjs-express.md4.8 KB
- 参考文档references/benchstat.md14.2 KB
- 参考文档references/ci-regression.md10.4 KB
- 参考文档references/compiler-analysis.md10.7 KB
- 参考文档references/coverage-reports.md3.0 KB
- 参考文档references/documentation-systems.md5.9 KB
- 参考文档references/interactive-api-docs.md10.0 KB
- 参考文档references/investigation-session.md7.1 KB
- 参考文档references/pprof.md33.2 KB
- 参考文档references/prometheus-go-metrics.md11.4 KB
- 参考文档references/python-docstrings.md2.9 KB
- 参考文档references/tools.md3.9 KB
- 参考文档references/trace.md18.0 KB
- 参考文档references/typescript-jsdoc.md3.0 KB
- 参考文档references/user-guides-tutorials.md10.7 KB
03 SKILL.md 正文
Code Documenter(代码文档专家)
用于内联文档、API 规范、文档站点和开发者指南的文档专家。
何时使用此技能
适用于任何涉及代码文档、API 规范或面向开发者的指南的任务。请参阅下方参考表格了解具体的子主题。
核心工作流程
- Discover(发现) - 询问格式偏好和排除项
- Detect(检测) - 识别语言和框架
- Analyze(分析) - 查找未文档化的代码
- Document(文档化) - 应用一致的格式
- Validate(验证) - 测试所有代码示例能否编译/运行:
- Python:
python -m doctest file.py用于 doctest 块;pytest --doctest-modules用于模块级检查 - TypeScript/JavaScript:
tsc --noEmit确认类型化示例能编译 - OpenAPI:使用
npx @redocly/cli lint openapi.yaml验证规范 - 如果验证失败:修复示例并重新验证,然后再进入报告步骤
- Python:
- Report(报告) - 生成覆盖率摘要
Quick-Reference Examples(快速参考示例)
Google-style Docstring (Google 风格文档字符串,Python)
def fetch_user(user_id: int, active_only: bool = True) -> dict:
"""Fetch a single user record by ID.
Args:
user_id: Unique identifier for the user.
active_only: When True, raise an error for inactive users.
Returns:
A dict containing user fields (id, name, email, created_at).
Raises:
ValueError: If user_id is not a positive integer.
UserNotFoundError: If no matching user exists.
"""
NumPy-style Docstring (NumPy 风格文档字符串,Python)
def compute_similarity(vec_a: np.ndarray, vec_b: np.ndarray) -> float:
"""Compute cosine similarity between two vectors.
Parameters
----------
vec_a : np.ndarray
First input vector, shape (n,).
vec_b : np.ndarray
Second input vector, shape (n,).
Returns
-------
float
Cosine similarity in the range [-1, 1].
Raises
------
ValueError
If vectors have different lengths.
"""
JSDoc (TypeScript)
/**
* Fetches a paginated list of products from the catalog.
*
* @param {string} categoryId - The category to filter by.
* @param {number} [page=1] - Page number (1-indexed).
* @param {number} [limit=20] - Maximum items per page.
* @returns {Promise<ProductPage>} Resolves to a page of product records.
* @throws {NotFoundError} If the category does not exist.
*
* @example
* const page = await fetchProducts('electronics', 2, 10);
* console.log(page.items);
*/
async function fetchProducts(
categoryId: string,
page = 1,
limit = 20
): Promise<ProductPage> { ... }
Reference Guide(参考指南)
根据上下文加载详细指导:
| 主题 | 参考文件 | 加载时机 |
|---|---|---|
| Python 文档字符串 | references/python-docstrings.md |
Google、NumPy、Sphinx 风格 |
| TypeScript JSDoc | references/typescript-jsdoc.md |
JSDoc 模式、TypeScript |
| FastAPI/Django API | references/api-docs-fastapi-django.md |
Python API 文档 |
| NestJS/Express API | references/api-docs-nestjs-express.md |
Node.js API 文档 |
| 覆盖率报告 | references/coverage-reports.md |
生成文档报告 |
| 文档系统 | references/documentation-systems.md |
文档站点、静态生成器、搜索、测试 |
| 交互式 API 文档 | references/interactive-api-docs.md |
OpenAPI 3.1、门户、GraphQL、WebSocket、gRPC、SDK |
| 用户指南与教程 | references/user-guides-tutorials.md |
入门指南、教程、故障排除、常见问题 |
Constraints(约束条件)
MUST DO(必须做)
- 开始前询问格式偏好
- 检测框架以选择正确的 API 文档策略
- 记录所有公开函数/类
- 包含参数类型和描述
- 记录异常/错误
- 测试文档中的代码示例
- 生成覆盖率报告
MUST NOT DO(禁止做)
- 未经询问就假设文档字符串格式
- 为框架应用错误的 API 文档策略
- 编写不准确或未经测试的文档
- 跳过错误文档
- 冗长地记录显而易见的 getter/setter
- 创建难以维护的文档
Output Formats(输出格式)
根据任务的不同,提供以下内容:
- Code Documentation(代码文档): 文档化文件 + 覆盖率报告
- API Docs(API 文档): OpenAPI 规范 + 门户配置
- Doc Sites(文档站点): 站点配置 + 内容结构 + 构建说明
- Guides/Tutorials(指南/教程): 带有示例和图表的结构化 Markdown
Knowledge Reference(知识参考)
Google/NumPy/Sphinx 文档字符串、JSDoc、OpenAPI 3.0/3.1、AsyncAPI、gRPC/protobuf、FastAPI、Django、NestJS、Express、GraphQL、Docusaurus、MkDocs、VitePress、Swagger UI、Redoc、Stoplight
04 同仓库更多 Skills
websocket-engineer
当使用 WebSocket 或 Socket.IO 构建实时通信系统时使用。适用于双向消息通信、Redis 水平扩展、在线状态追踪、房间管理。
security-reviewer
识别安全漏洞,生成带有严重性评级的结构化审计报告,并提供可操作的安全修复建议。在开展安全审计、审查代码漏洞或分析基础设施安全时使用。适用于 SAST 扫描、渗透测试、DevSecOps 实践、云安全审查、依赖审计、密钥扫描或合规检查。生成漏洞报告、优先级建议和合规清单。
secure-code-guardian
用于实现认证/授权、保护用户输入或防御 OWASP Top 10 漏洞 —— 包括自定义安全实现,例如使用 bcrypt/argon2 哈希密码、使用参数化语句清理 SQL 查询、配置 CORS/CSP 头部、使用 Zod 验证输入以及设置 JWT token。适用于认证、授权、输入验证、加密、OWASP Top 10 防护、安全会话管理和安全加固。对于预构建的 OAuth/SSO 集成或独立的安全审计,请考虑使用更专业的 skill。
rust-engineer
编写、审查和调试符合 Rust 风格的代码,确保内存安全和零成本抽象。实现所有权模式、管理生命周期、设计 trait 层级、使用 tokio 构建异步应用程序,以及使用 Result/Option 结构化错误处理。适用于构建 Rust 应用程序、解决所有权或借用问题、设计基于 trait 的 API、实现 async/await 并发、创建 FFI 绑定,或优化性能和内存安全。触发词:Rust, Cargo, ownership, borrowing, lifetimes, async Rust, tokio, zero-cost abstractions, memory safety, systems programming。
react-native-expert
使用 React Native 和 Expo 构建、优化和调试跨平台移动应用。实现导航层级结构(标签页、堆栈、抽屉),配置原生模块,使用 memo 和 useCallback 优化 FlatList 渲染,处理 iOS 和 Android 的平台特定代码。在构建 React Native 或 Expo 移动应用、设置导航、集成原生模块、改善滚动性能、处理 SafeArea 或键盘输入、配置 Expo SDK 项目时使用。
react-expert
当你使用 .jsx 或 .tsx 文件构建 React 18+ 应用、Next.js App Router 项目或 create-react-app 时使用。创建组件、实现自定义 hooks、调试渲染问题、将类组件迁移为函数组件、以及实现状态管理。适用于 Server Components、Suspense 边界、useActionState 表单、性能优化或 React 19 特性。