Doc Forge — Intelligent Documentation Generator
Version: 1.1.0 | Author: Shadows Company | License: MIT
WHEN TO TRIGGER
- - Project has no README or outdated documentation
- User says "document this", "generate docs", "write README"
- New module/feature needs documentation
- API endpoints need documented
- Onboarding documentation needed
WHEN NOT TO TRIGGER
- - Code is self-explanatory and well-named
- User explicitly says "no docs needed"
- Adding trivial comments to obvious code
PREREQUISITES
No binaries required. This skill reads source files and generates documentation in markdown format. No external tools needed.
DOCUMENTATION TYPES
Type 1 — README.md
Structure:
CODEBLOCK0
Type 2 — API Documentation
For each endpoint/function:
### `METHOD /path/to/endpoint`
**Description**: What it does.
**Auth**: Required/Optional/None
**Parameters**:
| Name | Type | Required | Description |
|------|------|----------|-------------|
| id | string | Yes | Resource ID |
**Request Body**:
json
{ "key": "value" }
**Response** (200):
json
{ "ok": true, "data": {} }
CODEBLOCK3
Type 3 — Architecture Document
CODEBLOCK4
Type 4 — Inline Code Documentation
Rules for adding code comments:
- 1. Only document WHY, never WHAT — the code shows WHAT
- Document edge cases — explain non-obvious behavior
- Document contracts — inputs, outputs, side effects
- No obvious comments —
// increment counter on counter++ is noise
Good:
CODEBLOCK5
Bad:
# Set batch size to 80
batch_size = 80
PROCESS
- 1. Scan the project structure — list all directories and key files (entry points, configs, tests)
- Read entry points first (main.py, index.ts, server.py), then configs, then supporting modules
- Analyze frameworks used, architecture patterns, data flow, public interfaces
- Generate the appropriate documentation type based on what the project needs most
- Verify every code example and function signature against the actual source before finalizing
SECURITY CONSIDERATIONS
This skill reads source code files to generate documentation. It does not execute code, make network calls, or modify existing source files. Generated documentation is written as new files only. No credentials required, no persistence, no network access. Safe for all repositories.
OUTPUT FORMAT
Generated documentation follows the templates defined in DOCUMENTATION TYPES above. Each output file is a standalone markdown document placed alongside the source it documents (or at the project root for README.md).
RULES
- 1. Read before documenting — never document code you haven't read
- Accuracy over completeness — better to document less correctly than more incorrectly
- Living docs — documentation must match current code state
- Examples are mandatory — every API endpoint needs a usage example
- No fictional features — only document what actually exists in the codebase
- Match project language — if project docs are in French, write in French
Published by Shadows Company — "We work in the shadows to serve the Light."
Doc Forge — 智能文档生成器
版本: 1.1.0 | 作者: Shadows Company | 许可证: MIT
触发条件
- - 项目缺少README或文档已过时
- 用户说记录此项目、生成文档、编写README
- 新模块/功能需要文档
- API端点需要文档化
- 需要入门文档
不触发条件
- - 代码自解释且命名良好
- 用户明确表示无需文档
- 为显而易见的代码添加琐碎注释
前置条件
无需二进制文件。此技能读取源文件并以markdown格式生成文档。无需外部工具。
文档类型
类型1 — README.md
结构:
markdown
项目名称
[一行描述]
快速开始
[3-5个运行步骤]
功能特性
[关键能力的项目符号列表]
安装
[逐步安装说明]
使用方法
[常见用例的代码示例]
配置
[环境变量、配置文件]
API参考
[如适用 — 端点或函数签名]
架构
[高层级图表或描述]
贡献指南
[如何贡献]
许可证
[许可证类型]
类型2 — API文档
针对每个端点/函数:
markdown
METHOD /路径/到/端点
描述:功能说明。
认证:必需/可选/无需
参数:
请求体:
json
{ key: value }
响应 (200):
json
{ ok: true, data: {} }
错误:
未授权 |
| 404 | 未找到 |
类型3 — 架构文档
markdown
架构概述
系统图
[使用ASCII或Mermaid的文本图表]
组件
[每个主要组件的描述]
数据流
[数据在系统中的流动方式]
关键决策
[为何做出某些架构选择]
依赖项
[外部服务及其用途]
类型4 — 内联代码文档
添加代码注释的规则:
- 1. 只记录原因,不记录内容 — 代码已展示内容
- 记录边界情况 — 解释非显而易见的行为
- 记录契约 — 输入、输出、副作用
- 无显而易见的注释 — 在counter++上写// 递增计数器是噪音
好的示例:
python
速率限制:Stripe API允许最多100次请求/秒。
我们批量处理以保持在80以下,为重试留出空间。
batch_size = 80
差的示例:
python
将批量大小设为80
batch_size = 80
处理流程
- 1. 扫描项目结构 — 列出所有目录和关键文件(入口点、配置、测试)
- 读取入口点(main.py、index.ts、server.py),然后是配置,最后是支持模块
- 分析使用的框架、架构模式、数据流、公共接口
- 生成基于项目最需要的文档类型
- 验证每个代码示例和函数签名是否与实际源代码一致,然后定稿
安全考虑
此技能读取源代码文件以生成文档。它不执行代码、不发起网络调用、不修改现有源文件。生成的文档仅作为新文件写入。无需凭据、无持久化、无网络访问。适用于所有仓库。
输出格式
生成的文档遵循上述文档类型中定义的模板。每个输出文件是一个独立的markdown文档,放置在其所文档化的源代码旁边(对于README.md则放在项目根目录)。
规则
- 1. 先阅读再记录 — 绝不记录未阅读的代码
- 准确性优于完整性 — 正确记录少量内容优于错误记录大量内容
- 活文档 — 文档必须与当前代码状态一致
- 示例是必须的 — 每个API端点都需要使用示例
- 无虚构功能 — 只记录代码库中实际存在的内容
- 匹配项目语言 — 如果项目文档是法语,则用法语编写
由Shadows Company发布 — 我们在暗处工作,以服务于光明。