documentation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocumentation Skill
文档编写Skill
Maintain organized, well-structured project documentation. Prioritizes updating existing docs over creating new ones.
维护条理清晰、结构合理的项目文档。优先更新现有文档,而非创建新文档。
When to Use
适用场景
- Creating or updating any project documentation
- Before creating a new doc file
- When documenting technical decisions, API flows, or architecture
- Writing changelogs, READMEs, or guides
- 创建或更新任何项目文档
- 在创建新文档文件之前
- 记录技术决策、API流程或架构时
- 编写变更日志(changelog)、README或指南文档
Core Principles
核心原则
1. Update First, Create Never (Unless Necessary)
1. 优先更新,非必要不创建
Before creating any new doc:
- Search for existing related documentation
docs/ - Check if content belongs in an existing file
- Only create new files for genuinely distinct topics
Existing docs always beat new docs.
创建任何新文档前:
- 在目录下搜索相关的现有文档
docs/ - 确认内容是否适合添加到现有文件中
- 仅针对完全独立的主题创建新文件
现有文档永远优于新文档。
2. Document Metadata Header
2. 文档元数据头部
Every documentation file MUST include a YAML frontmatter header:
markdown
---
title: [Document Title]
created: YYYY-MM-DD
author: [Name or "AI-assisted"]
last_updated: YYYY-MM-DD
updated_by: [Name or "AI-assisted"]
status: [draft | active | deprecated]
---Rules:
- and
createdare set once, never changedauthor - and
last_updatedchange on every editupdated_by - tracks document lifecycle
status
每个文档文件必须包含YAML前置元数据头部:
markdown
---
title: [Document Title]
created: YYYY-MM-DD
author: [Name or "AI-assisted"]
last_updated: YYYY-MM-DD
updated_by: [Name or "AI-assisted"]
status: [draft | active | deprecated]
---规则:
- 和
created一旦设置,不得修改author - 每次编辑时更新和
last_updatedupdated_by - 用于跟踪文档生命周期
status
3. Minimal Document Count
3. 最小化文档数量
| ✅ Good | ❌ Bad |
|---|---|
| One architecture.md with sections | arch-frontend.md, arch-backend.md, arch-db.md |
| Flowcharts in technical-flows.md | auth-flow.md, api-flow.md, ai-flow.md |
| Single CHANGELOG.md | release-notes-v1.md, release-notes-v2.md |
| ✅ 推荐做法 | ❌ 错误做法 |
|---|---|
| 单个architecture.md包含多个章节 | arch-frontend.md, arch-backend.md, arch-db.md |
| 流程图统一放在technical-flows.md中 | auth-flow.md, api-flow.md, ai-flow.md |
| 单个CHANGELOG.md | release-notes-v1.md, release-notes-v2.md |
4. Standard Doc Structure
4. 标准文档结构
docs/
├── architecture.md # Technical patterns & decisions
├── technical-flows.md # Mermaid diagrams & API flows
├── product-requirements.md # PRD (if applicable)
├── [topic]-guide.md # Only for major topics
└── competitive-analysis-[name].md # Market researchRoot-level docs (not in docs/):
- — Project overview
README.md - — Version history
CHANGELOG.md - — Sprint/backlog
TASKS.md - — Contribution guide (if open source)
CONTRIBUTING.md
docs/
├── architecture.md # 技术模式与决策
├── technical-flows.md # Mermaid图表与API流程
├── product-requirements.md # 产品需求文档(PRD,如有需要)
├── [topic]-guide.md # 仅用于重大主题
└── competitive-analysis-[name].md # 市场调研根目录下的文档(不在docs/内):
- — 项目概述
README.md - — 版本历史
CHANGELOG.md - — 迭代/待办事项
TASKS.md - — 贡献指南(开源项目适用)
CONTRIBUTING.md
Mermaid Diagram Guidelines
Mermaid图表规范
Flowcharts (LR or TD)
流程图(LR或TD方向)
mermaid
flowchart LR
A[User Action] --> B{Decision}
B -->|Yes| C[Result A]
B -->|No| D[Result B]mermaid
flowchart LR
A[User Action] --> B{Decision}
B -->|Yes| C[Result A]
B -->|No| D[Result B]Sequence Diagrams
时序图
mermaid
sequenceDiagram
participant U as User
participant A as App
participant S as Server
U->>A: Action
A->>S: Request
S-->>A: Response
A-->>U: Updatemermaid
sequenceDiagram
participant U as User
participant A as App
participant S as Server
U->>A: Action
A->>S: Request
S-->>A: Response
A-->>U: UpdateState Diagrams
状态图
mermaid
stateDiagram-v2
[*] --> Idle
Idle --> Loading: fetch
Loading --> Success: data
Loading --> Error: error
Success --> Idle: reset
Error --> Idle: retrymermaid
stateDiagram-v2
[*] --> Idle
Idle --> Loading: fetch
Loading --> Success: data
Loading --> Error: error
Success --> Idle: reset
Error --> Idle: retryBest Practices
最佳实践
- Label everything — Edges and nodes should be self-explanatory
- Left-to-right for flows — Easier to read
- Top-down for hierarchies — Natural reading order
- Group related nodes — Use subgraphs for clarity
- Keep it simple — Max 10-15 nodes per diagram
- 所有元素添加标签 — 连接线和节点应清晰易懂
- 流程图采用从左到右布局 — 更易阅读
- 层级结构采用从上到下布局 — 符合自然阅读顺序
- 相关节点分组 — 使用子图提升清晰度
- 保持简洁 — 每张图最多包含10-15个节点
Updating Documentation Checklist
文档更新检查清单
When updating any doc:
- Update date in header
last_updated - Update in header
updated_by - Remove outdated information (don't just add)
- Verify all links still work
- Check code samples are current
- Confirm mermaid diagrams render correctly
更新任何文档时:
- 更新头部的日期
last_updated - 更新头部的信息
updated_by - 删除过时内容(不要仅添加新内容)
- 验证所有链接是否可用
- 检查代码示例是否为当前版本
- 确认Mermaid图表渲染正常
Document Discovery
文档检索
Before creating a new doc, always run:
bash
undefined创建新文档前,务必执行以下命令:
bash
undefinedList existing docs
列出所有现有文档
ls -la docs/
ls -la docs/
Search for related content
搜索相关内容
grep -ri "search term" docs/
grep -ri "search term" docs/
Find mermaid diagrams
查找Mermaid图表
grep -r "mermaid" docs/
---grep -r "mermaid" docs/
---Templates
模板
New Section in Existing Doc
现有文档新增章节
markdown
---markdown
---[Section Title]
[章节标题]
Added: YYYY-MM-DD
[Content...]
undefinedAdded: YYYY-MM-DD
[Content...]
undefinedNew Document (only when justified)
新文档模板(仅在必要时使用)
markdown
---
title: [Document Title]
created: YYYY-MM-DD
author: [Name or "AI-assisted"]
last_updated: YYYY-MM-DD
updated_by: [Name or "AI-assisted"]
status: draft
---markdown
---
title: [Document Title]
created: YYYY-MM-DD
author: [Name or "AI-assisted"]
last_updated: YYYY-MM-DD
updated_by: [Name or "AI-assisted"]
status: draft
---[Title]
[Title]
[One-line description]
[一句话描述]
Overview
概述
[Content...]
---[Content...]
---Anti-Patterns
反模式示例
| ❌ Don't | ✅ Do Instead |
|---|---|
| Create auth-flow.md | Add Auth section to technical-flows.md |
| Duplicate content across files | Reference other docs with links |
| Leave stale dates | Update metadata on every edit |
| Create docs for every minor feature | Document in code comments |
| Write docs without checking existing | Always search first |
| ❌ 请勿这样做 | ✅ 正确做法 |
|---|---|
| 创建auth-flow.md | 在technical-flows.md中添加认证流程章节 |
| 在多个文件中重复内容 | 通过链接引用其他文档 |
| 保留过期的日期信息 | 每次编辑时更新元数据 |
| 为每个小功能单独创建文档 | 在代码注释中记录 |
| 不检查现有文档就创建新文档 | 先搜索现有文档 |
Changelog Conventions
变更日志规范
Follow Keep a Changelog format:
markdown
undefined遵循Keep a Changelog格式:
markdown
undefined[Unreleased]
[Unreleased]
Added
Added
- New feature description
- 新功能描述
Changed
Changed
- Modified behavior
- 修改的行为
Fixed
Fixed
- Bug fix description
- Bug修复描述
Removed
Removed
- Deprecated feature
- 已弃用的功能
[1.0.0] - YYYY-MM-DD
[1.0.0] - YYYY-MM-DD
Added
Added
- Initial release features
**Categories:** Added, Changed, Deprecated, Removed, Fixed, Security
---- 初始版本功能
**分类:** Added、Changed、Deprecated、Removed、Fixed、Security
---Quick Reference
快速参考
| Item | Value |
|---|---|
| Metadata required | title, created, author, last_updated, updated_by, status |
| Max docs in docs/ | ~5-7 files for typical project |
| Always update | last_updated, updated_by on every edit |
| Mermaid types | flowchart (LR/TD), sequenceDiagram, stateDiagram-v2, erDiagram |
| Status values | draft, active, deprecated |
| 项 | 值 |
|---|---|
| 必填元数据 | title、created、author、last_updated、updated_by、status |
| docs/目录最大文档数 | 典型项目约5-7个文件 |
| 每次编辑必须更新 | last_updated、updated_by |
| Mermaid图表类型 | flowchart(LR/TD)、sequenceDiagram、stateDiagram-v2、erDiagram |
| 状态值 | draft、active、deprecated |
License
许可证
MIT
MIT