为 Claude How To 贡献内容时遵循的约定和格式规则。请按照这份指南保持内容一致、专业且易于维护。


目录


文件与文件夹命名

课程文件夹

课程文件夹使用一个 两位数字前缀,后接一个 kebab-case 描述符:

01-slash-commands/
02-memory/
03-skills/
04-subagents/
05-mcp/

这个数字反映了学习路径的顺序,从初学者到高级。

文件名

类型 约定 示例
课程 README README.md 01-slash-commands/README.md
功能文件 kebab-case .md code-reviewer.md, generate-api-docs.md
Shell 脚本 kebab-case .sh format-code.sh, validate-input.sh
配置文件 标准名称 .mcp.json, settings.json
记忆文件 带作用域前缀 project-CLAUDE.md, personal-CLAUDE.md
顶层文档 UPPER_CASE .md CATALOG.md, QUICK_REFERENCE.md, CONTRIBUTING.md
图片资源 kebab-case pr-slash-command.png, claude-howto-logo.svg

规则


文档结构

根 README

根目录 README.md 的顺序如下:

  1. Logo(使用带深色/浅色变体的 <picture> 元素)
  2. H1 标题
  3. 引导性引用块(一句话价值主张)
  4. “为什么需要这份指南?”部分,以及对比表
  5. 分隔线(---
  6. 目录
  7. 功能目录
  8. 快速导航
  9. 学习路径
  10. 功能章节
  11. 快速上手
  12. 最佳实践 / 故障排查
  13. 参与贡献 / 许可证

课程 README

每个课程 README.md 的顺序如下:

  1. H1 标题,例如 # Slash Commands
  2. 简短概述段落
  3. 快速参考表格(可选)
  4. 架构图(Mermaid)
  5. 详细章节(H2)
  6. 实用示例(编号列表,4-6 个示例)
  7. 最佳实践(Do's 和 Don'ts 表)
  8. 故障排查
  9. 相关指南 / 官方文档
  10. 文档元数据页脚

功能/示例文件

单个功能文件,例如 optimize.mdpr.md

  1. YAML frontmatter(如果适用)
  2. H1 标题
  3. 目的 / 描述
  4. 使用说明
  5. 代码示例
  6. 自定义提示

分隔线

使用水平分隔线(---)来分隔文档中的主要区域:

---

## New Major Section

将它们放在引导性引用块之后,以及文档中逻辑上不同的部分之间。


标题

层级

级别 用途 示例
# H1 页面标题,每个文档一个 # Slash Commands
## H2 主要章节 ## Best Practices
### H3 子章节 ### Adding a Skill
#### H4 再下一级子章节,较少使用 #### Configuration Options

规则


文本格式

强调

样式 使用时机 示例
粗体 (**text**) 关键术语、表格标签、重要概念 **Installation**:
斜体 (*text*) 技术术语首次出现、书名或文档名 *frontmatter*
Code (`text`) 文件名、命令、配置值、代码引用 `CLAUDE.md`

使用引述块做提示

对重要说明使用带粗体前缀的引述块:

> **Note**: Custom slash commands have been merged into skills since v2.0.

> **Important**: Never commit API keys or credentials.

> **Tip**: Combine memory with skills for maximum effectiveness.

支持的提示类型:NoteImportantTipWarning

段落


列表

无序列表

使用短横线(-),嵌套时使用 2 个空格缩进:

- First item
- Second item
  - Nested item
  - Another nested item
    - Deep nested (avoid going deeper than 3 levels)
- Third item

有序列表

用于顺序步骤、操作说明和排序项:

1. First step
2. Second step
   - Sub-point detail
   - Another sub-point
3. Third step

说明性列表

对键值对风格的列表,使用粗体标签:

- **Performance bottlenecks** - identify O(n^2) operations, inefficient loops
- **Memory leaks** - find unreleased resources, circular references
- **Algorithm improvements** - suggest better algorithms or data structures

规则


表格

标准格式

| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Data     | Data     | Data     |

常见表格模式

功能对比(3-4 列):

| Feature | Invocation | Persistence | Best For |
|---------|-----------|------------|----------|
| **Slash Commands** | Manual (`/cmd`) | Session only | Quick shortcuts |
| **Memory** | Auto-loaded | Cross-session | Long-term learning |

Do's and Don'ts:

| Do | Don't |
|----|-------|
| Use descriptive names | Use vague names |
| Keep files focused | Overload a single file |

快速参考:

| Aspect | Details |
|--------|---------|
| **Purpose** | Generate API documentation |
| **Scope** | Project-level |
| **Complexity** | Intermediate |

规则


代码块

语言标签

始终为语法高亮指定语言标签:

语言 标签 用途
Shell bash CLI 命令、脚本
Python python Python 代码
JavaScript javascript JS 代码
TypeScript typescript TS 代码
JSON json 配置文件
YAML yaml Frontmatter、配置
Markdown markdown Markdown 示例
SQL sql 数据库查询
Plain text (no tag) 期望输出、目录树

约定

# Comment explaining what the command does
claude mcp add notion --transport http https://mcp.notion.com/mcp

安装示例

安装说明请使用以下模式:

# Copy files to your project
cp 01-slash-commands/*.md .claude/commands/

多步骤工作流

# Step 1: Create the directory
mkdir -p .claude/commands

# Step 2: Copy the templates
cp 01-slash-commands/*.md .claude/commands/

# Step 3: Verify installation
ls .claude/commands/

链接与交叉引用

内部链接(相对路径)

内部链接全部使用相对路径:

[Slash Commands](01-slash-commands/README.md)
[Skills Guide](03-skills/README.md)
[Memory Architecture](02-memory/README.md)

从课程文件夹返回根目录或兄弟目录:

[返回主指南](README.md)
[相关:Skills](03-skills/README.md)

外部链接(绝对路径)

使用完整 URL,并使用具有描述性的锚文本:

[Anthropic's official documentation](https://code.claude.com/docs/en/overview)

章节锚点

链接到同一文档中的章节时,使用 GitHub 风格锚点:

[文件与文件夹命名](#文件与文件夹命名)
[作者检查清单](#作者检查清单)

相关指南模式

课程末尾要附上相关指南章节:

## Related Guides

- [Slash Commands](01-slash-commands/README.md) - 快速快捷命令
- [Memory](02-memory/README.md) - 持久上下文
- [Skills](03-skills/README.md) - 可复用能力

图表

Mermaid

所有图表都使用 Mermaid。支持的类型包括:

样式约定

使用 style block 保持颜色一致:

graph TB
    A["Component A"] --> B["Component B"]
    B --> C["Component C"]

    style A fill:#e1f5fe,stroke:#333,color:#333
    style B fill:#fce4ec,stroke:#333,color:#333
    style C fill:#e8f5e9,stroke:#333,color:#333

颜色调色板:

Color Hex Use For
Light blue #e1f5fe Primary components, inputs
Light pink #fce4ec Processing, middleware
Light green #e8f5e9 Outputs, results
Light yellow #fff9c4 Configuration, optional
Light purple #f3e5f5 User-facing, UI

规则


Emoji 用法

Emoji 的使用场景

Emoji 使用要 克制且有目的,只在特定场景中出现:

场景 Emoji 示例
Root README 章节标题 分类图标 ## 📚 Learning Path
Skill 等级指示 彩色圆点 🟢 Beginner, 🔵 Intermediate, 🔴 Advanced
Do's 和 Don'ts 对勾/叉号 ✅ Do this, ❌ Don't do this
复杂度评级 星星 ⭐⭐⭐

标准 Emoji 集合

Emoji 含义
📚 学习、指南、文档
快速上手、速查
🎯 功能、速查
🎓 学习路径
📊 统计、对比
🚀 安装、快速命令
🟢 初学者级别
🔵 中级别
🔴 高级别
推荐做法
避免 / 反模式
复杂度评级单位

规则


YAML Frontmatter

功能文件(Skills、Commands、Agents)

---
name: unique-identifier
description: What this feature does and when to use it
allowed-tools: Bash, Read, Grep
---

可选字段

---
name: my-feature
description: Brief description
argument-hint: "[file-path] [options]"
allowed-tools: Bash, Read, Grep, Write, Edit
model: opus                        # opus, sonnet, or haiku
disable-model-invocation: true     # User-only invocation
user-invocable: false              # Hidden from user menu
context: fork                      # Run in isolated subagent
agent: Explore                     # Agent type for context: fork
---

规则


图片与媒体

Logo 模式

所有以 Logo 开头的文档都使用 <picture> 元素,以支持深色/浅色模式:

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="resources/logos/claude-howto-logo-dark.svg">
  <img alt="Claude How To" src="resources/logos/claude-howto-logo.svg">
</picture>

截图

规则


语气与文风

写作风格

内容原则

原则 示例
Show, don't tell 提供可运行示例,而不是抽象描述
渐进式复杂度 先简单,后面再增加深度
解释“为什么” “Use memory for... because...” 而不只是 “Use memory for...”
可直接复制粘贴 每个代码块都应能直接粘贴使用
真实场景 使用实际场景,而不是牵强的例子

词汇


提交信息

遵循 Conventional Commits:

type(scope): description

类型

Type Use For
feat 新功能、示例或指南
fix Bug 修复、纠正、损坏链接
docs 文档改进
refactor 只重构、不改变行为
style 仅格式化改动
test 测试新增或修改
chore 构建、依赖、CI

作用域

使用课程名称或文件区域作为作用域:

feat(slash-commands): Add API documentation generator
docs(memory): Improve personal preferences example
fix(README): Correct table of contents link
docs(skills): Add comprehensive code review skill

文档元数据页脚

课程 README 以元数据块结尾:

---
**Last Updated**: March 2026
**Claude Code Version**: 2.1.97
**Compatible Models**: Claude Sonnet 4.6, Claude Opus 4.6, Claude Haiku 4.5

作者检查清单

提交内容前,请确认: