documentation-writing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocumentation Writing Skill
文档编写Skill
Purpose
用途
Creates high-quality, discoverable documentation following the Eight Rules and Diataxis framework. Ensures all docs are properly located, linked, and contain real runnable examples.
遵循八项规则与Diataxis框架,创建高质量、易于查找的文档。确保所有文档存放位置正确、链接得当,并包含真实可运行的示例。
When I Activate
触发条件
I load automatically when you mention:
- "write documentation" or "create docs"
- "document this feature/module/API"
- "create a README" or "write a tutorial"
- "explain how this works"
- Any request to create markdown documentation
当你提及以下内容时,我会自动加载:
- "编写文档"或"创建文档"
- "为该功能/模块/API编写文档"
- "创建README"或"编写教程"
- "解释其工作原理"
- 任何创建Markdown文档的请求
Core Rules (MANDATORY)
核心规则(强制性)
The Eight Rules
八项规则
- Location: All docs in directory
docs/ - Linking: Every doc linked from at least one other doc
- Simplicity: Plain language, remove unnecessary words
- Real Examples: Runnable code, not "foo/bar" placeholders
- Diataxis: One doc type per file (tutorial/howto/reference/explanation)
- Scanability: Descriptive headings, table of contents for long docs
- Local Links: Relative paths, context with links
- Currency: Delete outdated docs, include update metadata
- 位置:所有文档存放于目录
docs/ - 链接:每个文档至少与其他一个文档建立链接
- 简洁:使用平实语言,删除冗余词汇
- 真实示例:使用可运行代码,而非"foo/bar"占位符
- Diataxis规范:每个文件对应一种文档类型(教程/操作指南/参考文档/说明文档)
- 易读性:使用描述性标题,长文档添加目录
- 本地链接:使用相对路径,通过链接提供上下文
- 时效性:删除过时文档,包含更新元数据
What Stays OUT of Docs
文档中禁止包含的内容
Never put in :
docs/- Status reports or progress updates
- Test results or benchmarks
- Meeting notes or decisions
- Plans with dates
- Point-in-time snapshots
Where temporal info belongs:
- Test results → CI logs, GitHub Actions
- Status updates → GitHub Issues
- Progress → Pull Request descriptions
- Decisions → Commit messages
切勿放入目录的内容:
docs/- 状态报告或进度更新
- 测试结果或基准数据
- 会议记录或决策内容
- 带日期的计划
- 特定时间点的快照
时效性信息的正确存放位置:
- 测试结果 → CI日志、GitHub Actions
- 状态更新 → GitHub Issues
- 进度情况 → Pull Request描述
- 决策内容 → 提交信息
Quick Start
快速入门
Creating a New Document
创建新文档
markdown
undefinedmarkdown
undefined[Feature Name]
[功能名称]
Brief one-sentence description of what this is.
简要的一句话描述该功能是什么。
Quick Start
快速入门
Minimal steps to get started (3-5 steps max).
入门的最少步骤(最多3-5步)。
Contents
目录
Configuration
配置
Step-by-step setup with real examples.
带真实示例的分步设置说明。
Usage
使用方法
Common use cases with runnable code.
带可运行代码的常见使用场景。
Troubleshooting
故障排除
Common problems and solutions.
undefined常见问题及解决方案。
undefinedDocument Types (Diataxis)
文档类型(Diataxis规范)
| Type | Purpose | Location | User Question |
|---|---|---|---|
| Tutorial | Learning | | "Teach me how" |
| How-To | Doing | | "Help me do X" |
| Reference | Information | | "What are the options?" |
| Explanation | Understanding | | "Why is it this way?" |
| 类型 | 用途 | 存放位置 | 用户问题 |
|---|---|---|---|
| Tutorial | 学习指导 | | "教我如何操作" |
| How-To | 操作指南 | | "帮我完成X操作" |
| Reference | 信息查询 | | "有哪些选项?" |
| Explanation | 概念说明 | | "为什么要这样设计?" |
Workflow
工作流程
Step 1: Determine Document Type
步骤1:确定文档类型
Ask: What is the reader trying to accomplish?
- Learning something new → Tutorial
- Solving a specific problem → How-To
- Looking up details → Reference
- Understanding concepts → Explanation
思考:读者想要达成什么目标?
- 学习新知识 → 教程
- 解决特定问题 → 操作指南
- 查阅详细信息 → 参考文档
- 理解概念 → 概念说明
Step 2: Choose Location
步骤2:选择存放位置
docs/
├── tutorials/ # Learning-oriented
├── howto/ # Task-oriented
├── reference/ # Information-oriented
├── concepts/ # Understanding-oriented
└── index.md # Links to all docsdocs/
├── tutorials/ # 学习导向
├── howto/ # 任务导向
├── reference/ # 信息导向
├── concepts/ # 理解导向
└── index.md # 所有文档的链接入口Step 3: Write with Examples
步骤3:编写并添加示例
Every concept needs a runnable example:
python
undefined每个概念都需要可运行的示例:
python
undefinedExample: Analyze file complexity
示例:分析文件复杂度
from amplihack import analyze
result = analyze("src/main.py")
print(f"Complexity: {result.score}")
from amplihack import analyze
result = analyze("src/main.py")
print(f"复杂度: {result.score}")
Output: Complexity: 12.5
输出: 复杂度: 12.5
undefinedundefinedStep 4: Link from Index
步骤4:从索引页添加链接
Add entry to :
docs/index.mdmarkdown
- [New Feature Guide](./howto/new-feature.md) - How to configure X在中添加条目:
docs/index.mdmarkdown
- [新功能指南](./howto/new-feature.md) - 如何配置XStep 5: Validate
步骤5:验证
Checklist before completion:
- File in directory
docs/ - Linked from index or parent doc
- No temporal information
- All examples tested
- Follows one Diataxis type
完成前的检查清单:
- 文件存放于目录
docs/ - 已从索引页或父文档添加链接
- 无时效性信息
- 所有示例均已测试
- 符合Diataxis的单一文档类型规范
Navigation Guide
导航指南
When to Read Supporting Files
何时阅读支持文件
reference.md - Read when you need:
- Complete frontmatter specification
- Detailed Diataxis type definitions
- Markdown style conventions
- Documentation review checklist
examples.md - Read when you need:
- Full document templates for each type
- Real-world documentation examples
- Before/after improvement examples
- Complex documentation patterns
reference.md - 当你需要以下信息时阅读:
- 完整的前置规范
- 详细的Diataxis类型定义
- Markdown风格约定
- 文档审核检查清单
examples.md - 当你需要以下信息时阅读:
- 每种文档类型的完整模板
- 真实场景的文档示例
- 改进前后的示例对比
- 复杂文档的编写模式
Anti-Patterns to Avoid
需避免的反模式
| Anti-Pattern | Why It's Bad | Better Approach |
|---|---|---|
| "Click here" links | No context | "See auth config" |
| foo/bar examples | Not realistic | Use real project code |
| Wall of text | Hard to scan | Use headings and bullets |
| Orphan docs | Never found | Link from index |
| Status in docs | Gets stale | Use Issues/PRs |
| 反模式 | 问题所在 | 更好的做法 |
|---|---|---|
| "点击这里"链接 | 无上下文信息 | "查看认证配置" |
| foo/bar占位示例 | 不贴合实际 | 使用真实项目代码 |
| 大段无格式文本 | 难以快速浏览 | 使用标题和列表 |
| 孤立文档 | 永远无法被找到 | 从索引页添加链接 |
| 文档中包含状态信息 | 容易过时 | 使用Issues/PRs |
Retcon Documentation Exception
回溯文档例外情况
When writing documentation BEFORE implementation (document-driven development):
markdown
undefined当在实现前编写文档时(文档驱动开发):
markdown
undefined[PLANNED - Implementation Pending]
[计划中 - 待实现]
This document describes the intended behavior of Feature X.
本文档描述了功能X的预期行为。
Planned Interface
计划中的接口
python
undefinedpython
undefined[PLANNED] - This API will be implemented
[计划中] - 该API将被实现
def future_function(input: str) -> Result:
"""Process input and return result."""
pass
undefinedOnce implemented, remove the markers and update with real examples.
[PLANNED]
---
**Full reference**: See [reference.md](./reference.md) for complete specification.
**Templates**: See [examples.md](./examples.md) for copy-paste templates.def future_function(input: str) -> Result:
"""处理输入并返回结果。"""
pass
undefined实现完成后,移除标记并更新为真实示例。
[计划中]完整参考:请查看reference.md获取完整规范。
模板:请查看examples.md获取可直接复制使用的模板。