Documentation Style Guide
Apply these principles when writing or reviewing documentation to ensure clarity, consistency, and accessibility for both human readers and LLMs.
Voice and Tone
Use Second Person
Address the reader directly as "you" rather than "the user" or "developers."
CODEBLOCK0
Prefer Active Voice
Write sentences where the subject performs the action. Active voice is clearer and more direct.
CODEBLOCK1
Be Concise
Cut unnecessary words. Every word should earn its place.
CODEBLOCK2
CODEBLOCK3
Common phrases to simplify:
| Instead of | Use |
|---|
| in order to | to |
| for the purpose of |
to, for |
| in the event that | if |
| at this point in time | now |
| due to the fact that | because |
| it is necessary to | you must |
| is able to | can |
| make use of | use |
Document Structure
Write Clear, Descriptive Headings
Headings should tell readers exactly what the section contains. Avoid clever or vague titles.
CODEBLOCK4
Create Self-Contained Pages
Assume readers may land on any page directly from search. Each page should:
- - Explain what the feature/concept is
- State prerequisites clearly
- Provide complete context for the topic
CODEBLOCK5
Use Semantic Markup
Choose the right format for the content type:
- - Headings: Follow proper hierarchy (h1 > h2 > h3, never skip levels)
- Lists: Use for multiple related items
- Tables: Use for structured data with consistent attributes
- Code blocks: Use for any code, commands, or file paths
CODEBLOCK6
Make Content Skimmable
Break dense paragraphs into digestible chunks:
- - Keep paragraphs to 3-4 sentences maximum
- Use bullet points for lists of items
- Add subheadings to long sections
- Put key information first (inverted pyramid)
CODEBLOCK7
Consistency
Use One Term Per Concept
Pick a term and use it consistently. Switching terms confuses readers.
CODEBLOCK8
Document your terminology choices:
| Concept | Use | Don't use |
|---|
| Authentication credential | API key | API token, secret key, access key |
| Configuration file |
config file | settings file, preferences file |
| Command line | CLI | terminal, command prompt, shell |
Apply Consistent Formatting
Use the same formatting for similar content types:
- - UI elements: Bold (Click Save)
- Code/commands: Backticks (
npm install) - File paths: Backticks (
/etc/config.yaml) - Key terms on first use: Bold or italics
- Placeholders: SCREAMING_CASE or angle brackets (
YOUR_API_KEY or <api-key>)
LLM-Friendly Patterns
State Prerequisites Explicitly
List what users need before starting. This helps both humans and LLMs understand context.
CODEBLOCK9
Define Acronyms on First Use
Spell out acronyms the first time they appear on a page.
CODEBLOCK10
Provide Complete, Runnable Code Examples
Code examples should work when copied. Include:
- - All necessary imports
- Realistic placeholder values
- Expected output (when helpful)
CODEBLOCK11 python
import requests
API_KEY = "your-api-key"
BASE_URL = "https://api.example.com/v1"
response = requests.get(
f"{BASE_URL}/users",
headers={"Authorization": f"Bearer {API_KEY}"}
)
print(response.json())
Output: {"users": [{"id": 1, "name": "Alice"}, ...]}
<!-- Avoid: Incomplete snippet -->
python
response = requests.get(url, headers=headers)
CODEBLOCK13
Write Descriptive Titles and Meta Descriptions
Page titles and descriptions help with search and LLM understanding.
CODEBLOCK14
Pitfalls to Avoid
Don't Use Product-Centric Language
Orient documentation around user goals, not product features.
CODEBLOCK15
Skip Obvious Instructions
Don't document self-explanatory UI actions.
CODEBLOCK16
Avoid Colloquialisms
Colloquialisms hurt clarity and localization.
CODEBLOCK17
Quick Reference Checklist
When writing documentation, verify:
- - [ ] Using "you" instead of "the user"
- [ ] Active voice throughout
- [ ] No unnecessary words
- [ ] Headings are descriptive
- [ ] Page is self-contained
- [ ] Proper heading hierarchy
- [ ] One term per concept
- [ ] Prerequisites listed
- [ ] Acronyms defined
- [ ] Code examples are complete
- [ ] No product-centric language
- [ ] No colloquialisms
Applying This Skill
Use these principles when:
- 1. Writing new documentation: Apply all principles from the start
- Reviewing documentation: Check against the quick reference checklist
- Editing existing docs: Prioritize voice/tone, then structure, then consistency
- Creating code examples: Ensure they are complete and runnable
文档风格指南
在编写或审阅文档时应用以下原则,以确保对人类读者和LLM的清晰性、一致性和可访问性。
语气与风格
使用第二人称
直接以你称呼读者,而不是用户或开发者。
markdown
你可以通过设置环境变量来配置API。
用户可以通过设置环境变量来配置API。
开发者应该通过设置环境变量来配置API。
优先使用主动语态
编写主语执行动作的句子。主动语态更清晰、更直接。
markdown
在根目录中创建配置文件。
该函数返回用户对象数组。
配置文件应该在根目录中被创建。
用户对象数组由该函数返回。
保持简洁
删减不必要的词语。每个词都应该有其存在的价值。
markdown
运行安装命令。
为了继续操作,你将需要运行安装命令。
markdown
此端点返回用户数据。
此端点用于返回用户数据的目的。
常见简化短语:
以,用于 |
| 在...情况下 | 如果 |
| 在此时 | 现在 |
| 由于...的事实 | 因为 |
| 有必要 | 你必须 |
| 能够 | 可以 |
| 利用 | 使用 |
文档结构
编写清晰、描述性的标题
标题应准确告知读者该部分内容。避免使用巧妙或模糊的标题。
markdown
安装CLI
配置身份验证
处理速率限制
入门(模糊)
有趣的部分(巧妙)
杂项(无信息量)
创建自包含页面
假设读者可能通过搜索直接访问任何页面。每个页面应:
- - 解释该功能/概念是什么
- 明确说明先决条件
- 提供该主题的完整上下文
markdown
Webhooks
Webhooks让你在账户中发生事件时接收实时通知。
先决条件
- - 具有webhook权限的有效API密钥
- 可公开访问的HTTPS端点
创建Webhook
...
使用语义化标记
为内容类型选择正确的格式:
- - 标题:遵循正确的层级(h1 > h2 > h3,切勿跳级)
- 列表:用于多个相关项目
- 表格:用于具有一致属性的结构化数据
- 代码块:用于任何代码、命令或文件路径
markdown
| 参数 | 类型 | 必填 | 描述 |
|---|
| api_key | 字符串 | 是 | 你的API密钥 |
| timeout |
整数 | 否 | 请求超时时间(秒) |
要进行身份验证,你可以:
- - 在请求头中使用API密钥
- 使用OAuth 2.0
- 使用服务账户
使内容易于浏览
将密集的段落分解为易于消化的块:
- - 每段最多3-4句话
- 项目列表使用项目符号
- 长章节添加子标题
- 关键信息放在前面(倒金字塔结构)
markdown
错误处理
API返回标准HTTP状态码。
常见错误
- - 400 错误请求:参数无效。检查请求体。
- 401 未授权:API密钥无效或缺失。
- 429 请求过多:超出速率限制。等待后重试。
重试策略
对于429错误,从1秒开始使用指数退避。
一致性
每个概念使用一个术语
选择一个术语并一致使用。切换术语会混淆读者。
markdown
在控制面板中生成API密钥。在Authorization请求头中使用你的API密钥。
在控制面板中生成API密钥。在Authorization请求头中使用你的API令牌。
记录你的术语选择:
| 概念 | 使用 | 不使用 |
|---|
| 身份验证凭证 | API密钥 | API令牌、密钥、访问密钥 |
| 配置文件 |
配置文件 | 设置文件、偏好文件 |
| 命令行 | CLI | 终端、命令提示符、shell |
应用一致的格式
对类似内容类型使用相同格式:
- - UI元素:加粗(点击保存)
- 代码/命令:反引号(npm install)
- 文件路径:反引号(/etc/config.yaml)
- 首次使用的关键术语:加粗或斜体
- 占位符:大写字母或尖括号(YOURAPIKEY或)
LLM友好模式
明确说明先决条件
列出用户开始前需要的内容。这有助于人类和LLM理解上下文。
markdown
先决条件
开始之前,请确保你已:
- - 安装Node.js 18或更高版本
- 拥有具有管理员权限的有效账户
- 准备好你的API密钥(在设置 > API中找到)
首次使用时定义缩写
在页面上首次出现时拼写缩写。
markdown
CLI(命令行界面)提供了管理资源的工具。
后续使用可以直接说CLI。
CLI提供了管理资源的工具。
提供完整、可运行的代码示例
代码示例在复制后应能正常工作。包括:
- - 所有必要的导入
- 真实的占位符值
- 预期输出(如有帮助)
markdown
python
import requests
API_KEY = your-api-key
BASE_URL = https://api.example.com/v1
response = requests.get(
f{BASE_URL}/users,
headers={Authorization: fBearer {API_KEY}}
)
print(response.json())
输出:{users: [{id: 1, name: Alice}, ...]}
python
response = requests.get(url, headers=headers)
编写描述性标题和元描述
页面标题和描述有助于搜索和LLM理解。
markdown
title: 身份验证 - API参考
description: 了解如何使用API密钥、OAuth 2.0或服务账户对API请求进行身份验证。
需要避免的陷阱
不要使用以产品为中心的语言
文档应围绕用户目标而非产品功能来组织。
markdown
发送邮件
向你的用户发送带有投递追踪的事务性邮件。
邮件服务
我们强大的邮件服务提供企业级投递能力。
跳过显而易见的说明
不要记录不言自明的UI操作。
markdown
输入你的webhook URL。URL必须使用HTTPS并且可公开访问。
点击文本字段。输入你的webhook URL。点击保存按钮。
避免口语化表达
口语化表达会损害清晰度和本地化。
markdown
这种方法显著提升了性能。
这种方法对性能来说是颠覆性的。
这会让你的大脑爆炸。
让我们深入探讨吧!
快速参考清单
编写文档时,请验证:
- - [ ] 使用你而不是用户
- [ ] 全文使用主动语态
- [ ] 没有不必要的词语
- [ ] 标题具有描述性
- [ ] 页面是自包含的
- [ ] 标题层级正确
- [ ] 每个概念使用一个术语
- [ ] 列出了先决条件
- [ ] 定义了缩写
- [ ] 代码示例完整
- [ ] 没有以产品为中心的语言
- [ ] 没有口语化表达
应用此技能
在以下情况下使用这些原则:
- 1. 编写新文档:从一开始就应用所有原则
- 审阅文档:对照快速参考清单进行检查
- 编辑现有文档:优先处理语气/风格,然后是结构,最后是一致性
- 创建代码示例:确保它们完整且可运行