codebase-documenter by ailabs-393/ai-labs-claude-skills
npx skills add https://github.com/ailabs-393/ai-labs-claude-skills --skill codebase-documenter此技能用于为代码库创建全面、对初学者友好的文档。它提供了编写 README、架构指南、代码注释和 API 文档的结构化模板和最佳实践,帮助新用户快速理解项目并为其做出贡献。
在为新手编写代码文档时,请遵循以下基本原则:
何时创建: 用于项目根目录、主要功能模块或独立组件。
应遵循的结构:
# 项目名称
## 功能说明
[1-2 句通俗易懂的解释]
## 快速开始
[让用户在 < 5 分钟内运行项目]
## 项目结构
[带解释的可视化文件树]
## 核心概念
[用户需要理解的核心概念]
## 常见任务
[高频操作的逐步指南]
## 故障排除
[常见问题及解决方案]
最佳实践:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
何时创建: 用于具有多个模块、复杂数据流或非显而易见设计决策的项目。
应遵循的结构:
# 架构概述
## 系统设计
[高层级图表及解释]
## 目录结构
[详细分解,说明每个目录的用途]
## 数据流
[数据如何在系统中流动]
## 关键设计决策
[为何做出某些架构选择]
## 模块依赖关系
[不同部分如何交互]
## 扩展点
[在何处以及如何添加新功能]
最佳实践:
何时创建: 用于复杂逻辑、非显而易见的算法或需要上下文的代码。
注释模式:
函数/方法文档:
/**
* 计算部分计费周期的按比例订阅费用。
*
* 存在原因:用户可以在月中订阅,因此我们只需要
* 向他们收取当前计费周期剩余天数的费用。
*
* @param {number} fullPrice - 正常的月度订阅价格
* @param {Date} startDate - 用户订阅开始时间
* @param {Date} periodEnd - 当前计费周期结束时间
* @returns {number} 按比例计算的收费金额
*
* @example
* // 用户在 1 月 15 日订阅,周期于 1 月 31 日结束
* calculateProratedCost(30, new Date('2024-01-15'), new Date('2024-01-31'))
* // 返回:16.13(31 天中的 17 天)
*/
复杂逻辑文档:
# 存在此检查的原因:API 对已删除用户返回 null,
# 但对从未设置姓名的用户返回空字符串。我们需要
# 为审计日志区分这些情况。
if user_name is None:
# 用户已被删除 - 将此记录为安全事件
log_deletion_event(user_id)
elif user_name == "":
# 用户从未完成入职 - 可以安全跳过
continue
最佳实践:
何时创建: 用于任何 HTTP 端点、SDK 方法或公共接口。
应遵循的结构:
## 端点名称
### 功能说明
[端点用途的通俗易懂解释]
### 端点
`POST /api/v1/resource`
### 身份验证
[需要何种身份验证以及如何提供]
### 请求格式
[JSON 模式或示例请求]
### 响应格式
[JSON 模式或示例响应]
### 使用示例
[使用 curl/代码的具体示例]
### 常见错误
[错误代码及其含义]
### 相关端点
[指向相关操作的链接]
最佳实践:
在编写文档之前:
基于用户请求和代码库分析:
使用 assets/templates/ 中的模板作为起点:
assets/templates/README.template.md - 用于项目 READMEassets/templates/ARCHITECTURE.template.md - 用于架构文档assets/templates/API.template.md - 用于 API 文档根据特定代码库定制模板:
在最终确定文档之前:
此技能在 assets/templates/ 中包含多个模板,提供起始结构:
assets/templates/ 阅读适当的模板有关详细的文档最佳实践、风格指南和高级模式,请参考:
references/documentation_guidelines.md - 全面的风格指南和最佳实践references/visual_aids_guide.md - 如何创建有效的图表和文件树在以下情况下加载这些参考:
文件树帮助新用户理解项目组织:
project-root/
├── src/ # 源代码
│ ├── components/ # 可复用的 UI 组件
│ ├── pages/ # 页面级组件(路由)
│ ├── services/ # 业务逻辑和 API 调用
│ ├── utils/ # 辅助函数
│ └── types/ # TypeScript 类型定义
├── public/ # 静态资源(图片、字体)
├── tests/ # 测试文件,镜像 src 结构
└── package.json # 依赖项和脚本
使用带图表的编号步骤:
用户请求流程:
1. 用户提交表单 → 2. 验证 → 3. API 调用 → 4. 数据库 → 5. 响应
[1] components/UserForm.tsx
↓ 验证输入
[2] services/validation.ts
↓ 发送到 API
[3] services/api.ts
↓ 查询数据库
[4] Database (PostgreSQL)
↓ 返回数据
[5] components/UserForm.tsx (更新 UI)
捕捉架构选择背后的“原因”:
## 为何使用 Redux
**决策:** 使用 Redux 进行状态管理而非 Context API
**上下文:** 我们的应用有 50 多个组件需要访问用户
身份验证状态、购物车和 UI 偏好设置。
**推理:**
- 对于这么多组件,Context API 会导致不必要的重新渲染
- Redux DevTools 有助于调试复杂的状态变化
- 团队具备现有的 Redux 专业知识
**权衡:**
- 更多的样板代码
- 新开发人员学习曲线更陡峭
- 值得之处:性能、调试、团队熟悉度
生成文档时:
生成 README 的命令: "为此项目创建一个 README 文件,帮助新开发人员快速上手"
记录架构的命令: "记录此代码库的架构,解释不同模块如何交互"
添加代码注释的命令: "为此文件添加解释性注释,帮助新开发人员理解逻辑"
记录 API 的命令: "为此文件中的所有端点创建 API 文档"
每周安装量
230
代码仓库
GitHub 星标数
322
首次出现
Jan 23, 2026
安全审计
安装于
opencode195
codex188
gemini-cli183
github-copilot173
cursor143
claude-code135
This skill enables creating comprehensive, beginner-friendly documentation for codebases. It provides structured templates and best practices for writing READMEs, architecture guides, code comments, and API documentation that help new users quickly understand and contribute to projects.
When documenting code for new users, follow these fundamental principles:
When to create: For project root directories, major feature modules, or standalone components.
Structure to follow:
# Project Name
## What This Does
[1-2 sentence plain-English explanation]
## Quick Start
[Get users running the project in < 5 minutes]
## Project Structure
[Visual file tree with explanations]
## Key Concepts
[Core concepts users need to understand]
## Common Tasks
[Step-by-step guides for frequent operations]
## Troubleshooting
[Common issues and solutions]
Best practices:
When to create: For projects with multiple modules, complex data flows, or non-obvious design decisions.
Structure to follow:
# Architecture Overview
## System Design
[High-level diagram and explanation]
## Directory Structure
[Detailed breakdown with purpose of each directory]
## Data Flow
[How data moves through the system]
## Key Design Decisions
[Why certain architectural choices were made]
## Module Dependencies
[How different parts interact]
## Extension Points
[Where and how to add new features]
Best practices:
When to create: For complex logic, non-obvious algorithms, or code that requires context.
Annotation patterns:
Function/Method Documentation:
/**
* Calculates the prorated subscription cost for a partial billing period.
*
* Why this exists: Users can subscribe mid-month, so we need to charge
* them only for the days remaining in the current billing cycle.
*
* @param {number} fullPrice - The normal monthly subscription price
* @param {Date} startDate - When the user's subscription begins
* @param {Date} periodEnd - End of the current billing period
* @returns {number} The prorated amount to charge
*
* @example
* // User subscribes on Jan 15, period ends Jan 31
* calculateProratedCost(30, new Date('2024-01-15'), new Date('2024-01-31'))
* // Returns: 16.13 (17 days out of 31 days)
*/
Complex Logic Documentation:
# Why this check exists: The API returns null for deleted users,
# but empty string for users who never set a name. We need to
# distinguish between these cases for the audit log.
if user_name is None:
# User was deleted - log this as a security event
log_deletion_event(user_id)
elif user_name == "":
# User never completed onboarding - safe to skip
continue
Best practices:
When to create: For any HTTP endpoints, SDK methods, or public interfaces.
Structure to follow:
## Endpoint Name
### What It Does
[Plain-English explanation of the endpoint's purpose]
### Endpoint
`POST /api/v1/resource`
### Authentication
[What auth is required and how to provide it]
### Request Format
[JSON schema or example request]
### Response Format
[JSON schema or example response]
### Example Usage
[Concrete example with curl/code]
### Common Errors
[Error codes and what they mean]
### Related Endpoints
[Links to related operations]
Best practices:
Before writing documentation:
Based on user request and codebase analysis:
Use the templates from assets/templates/ as starting points:
assets/templates/README.template.md - For project READMEsassets/templates/ARCHITECTURE.template.md - For architecture docsassets/templates/API.template.md - For API documentationCustomize templates based on the specific codebase:
Before finalizing documentation:
This skill includes several templates in assets/templates/ that provide starting structures:
assets/templates/For detailed documentation best practices, style guidelines, and advanced patterns, refer to:
references/documentation_guidelines.md - Comprehensive style guide and best practicesreferences/visual_aids_guide.md - How to create effective diagrams and file treesLoad these references when:
File trees help new users understand project organization:
project-root/
├── src/ # Source code
│ ├── components/ # Reusable UI components
│ ├── pages/ # Page-level components (routing)
│ ├── services/ # Business logic and API calls
│ ├── utils/ # Helper functions
│ └── types/ # TypeScript type definitions
├── public/ # Static assets (images, fonts)
├── tests/ # Test files mirroring src structure
└── package.json # Dependencies and scripts
Use numbered steps with diagrams:
User Request Flow:
1. User submits form → 2. Validation → 3. API call → 4. Database → 5. Response
[1] components/UserForm.tsx
↓ validates input
[2] services/validation.ts
↓ sends to API
[3] services/api.ts
↓ queries database
[4] Database (PostgreSQL)
↓ returns data
[5] components/UserForm.tsx (updates UI)
Capture the "why" behind architectural choices:
## Why We Use Redux
**Decision:** State management with Redux instead of Context API
**Context:** Our app has 50+ components that need access to user
authentication state, shopping cart, and UI preferences.
**Reasoning:**
- Context API causes unnecessary re-renders with this many components
- Redux DevTools helps debug complex state changes
- Team has existing Redux expertise
**Trade-offs:**
- More boilerplate code
- Steeper learning curve for new developers
- Worth it for: performance, debugging, team familiarity
When generating documentation:
Command to generate README: "Create a README file for this project that helps new developers get started"
Command to document architecture: "Document the architecture of this codebase, explaining how the different modules interact"
Command to add code comments: "Add explanatory comments to this file that help new developers understand the logic"
Command to document API: "Create API documentation for all the endpoints in this file"
Weekly Installs
230
Repository
GitHub Stars
322
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode195
codex188
gemini-cli183
github-copilot173
cursor143
claude-code135
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
mcp2cli:无需代码,将MCP/OpenAPI/GraphQL实时转换为命令行工具
612 周安装
使用 yt-dlp 下载视频和音频 - 支持多分辨率、字幕和元数据提取
262 周安装
Parallel Data Enrichment 数据增强工具:自动化丰富CSV与JSON数据,提升AI分析效率
612 周安装
每日销售简报AI工具 - 自动生成优先级行动计划,整合日历、CRM和邮件数据
649 周安装
FlowStudio MCP 构建部署 Power Automate 云流指南 | 自动化流程开发
686 周安装
cmux-browser 浏览器自动化技能:使用 CLI 命令实现网页操作与测试
678 周安装