Docs Sync
Prerequisites
- - git
- gh (GitHub CLI, authenticated via
gh auth login)
Keep project documentation current with code changes. Three modes:
- 1. Content sync — update doc content after code changes
- Site management — maintain doc site structure and navigation
- Docs audit — identify stale docs that need attention
Repo Discovery
Before doing anything, discover the project's documentation setup:
- 1. Run
git rev-parse --show-toplevel to find the repo root - Check for
.docs-sync.yml at the repo root — if it exists, read it and use its
values for all paths, roles, and site config
- 3. If no config file, auto-discover:
- Doc site engine: look for
mkdocs.yml,
docusaurus.config.js,
.vitepress/config.*
- Doc directory: look for
docs/,
documentation/,
wiki/
- Known doc files: scan for common patterns (see Doc Roles below)
- Convention files:
CLAUDE.md,
AGENTS.md,
CONTRIBUTING.md
- 4. Run
gh repo view --json name,owner to confirm the repo
Config File: .docs-sync.yml
Optional config file at repo root. All fields are optional — auto-discovery fills gaps.
See docs-sync.yml in the skill directory for a starter.
CODEBLOCK0
Doc Roles
Roles tell the skill what kind of content a file contains, so it knows how to update it.
| Role | Content | Updated when... |
|---|
| INLINECODE15 | User-facing feature descriptions, shortcuts, status | New feature added, feature behavior changes |
| INLINECODE16 |
App structure, data flow, patterns, diagrams | New components, changed patterns, refactors |
|
conventions | Dev setup, coding rules, build commands | Build process changes, new conventions adopted |
|
changelog | Version-based change history | Any significant change (follows format: keep-a-changelog, conventional, custom) |
|
readme | Project overview, install instructions, quick start | Major features, install process changes |
|
api | API reference, endpoints, function signatures | Public API changes |
|
guide | Tutorials, how-tos, walkthroughs | Workflow changes, new capabilities |
|
custom | Anything else — describe in the
description field | Based on your description |
Auto-Detection (No Config)
Without a config file, the skill detects roles by filename:
| Pattern | Inferred role |
|---|
| INLINECODE24 , INLINECODE25 | INLINECODE26 |
INLINECODE27 , *design*, INLINECODE29 |
architecture |
|
CLAUDE.md,
AGENTS.md,
CONTRIBUTING.md,
*convention* |
conventions |
|
CHANGELOG*,
CHANGES*,
HISTORY* |
changelog |
|
README* |
readme |
|
*api*,
*reference*,
*endpoint* |
api |
|
*guide*,
*tutorial*,
*howto* |
guide |
Files not matching any pattern are skipped unless listed in the config.
Workflow: Content Sync
When the user says docs need updating (or after a PR merge):
- 1. Identify what changed — determine the scope of code changes:
- If a PR number is provided:
gh pr view <N> --json files,title,body
- If a commit range:
git diff --name-only <range>
- If unspecified:
git diff --name-only HEAD~1 (last commit)
- Read the actual diffs for changed files to understand
what changed, not just
which files
- 2. Map changes to affected docs — for each changed file, determine which doc
roles are affected:
- New UI component →
features,
architecture
- Changed data model →
architecture
- New keyboard shortcut →
features
- Changed build command →
conventions
- Bug fix →
changelog (if tracking fixes)
- New API endpoint →
api,
readme (if it's a headline feature)
- 3. Read current docs — read each affected doc file to understand current content,
structure, and style
- 4. Draft updates — write the specific changes needed for each doc:
- Match the existing writing style and structure
- Add to existing sections rather than creating new ones (unless clearly needed)
- For
changelog: add entry under the appropriate version/section
- For
features: add or update the feature entry, not rewrite the whole file
- For
architecture: update the affected section, preserve diagrams
- 5. Apply or propose — based on user preference:
-
Direct apply: edit the files, commit to a branch, report what changed
-
Review first: show the proposed changes and ask for approval
-
Issue: create a GitHub issue listing which docs need updating and why
Quality Checklist
Before committing doc updates:
- - [ ] Each update matches the existing style of that doc file
- [ ] No content was removed that's still accurate
- [ ] New entries are placed in the correct section (not appended randomly)
- [ ] Cross-references between docs are consistent
- [ ] Changelog entries follow the file's existing format
- [ ] Feature descriptions are user-facing (not implementation details)
Workflow: Site Management
When docs are added, moved, or deleted — keep the site structure current.
mkdocs
- 1. Read
mkdocs.yml and parse the nav: section - For new docs: determine the correct nav section based on the doc's role and path
- Add the entry to
nav: in the right position - For moved docs: update the nav path
- For deleted docs: remove the nav entry
docusaurus
- 1. Check
sidebars.js or INLINECODE68 - For auto-generated sidebars: ensure the doc has correct frontmatter (
sidebar_position, sidebar_label) - For manual sidebars: add/update/remove entries
vitepress
- 1. Check
.vitepress/config.* for sidebar configuration - Add/update/remove sidebar entries as needed
General Rules
- - Preserve existing organization — don't reorganize the nav, just maintain it
- Follow naming patterns — if existing entries use Title Case, match that
- Respect ordering — add new entries at logical positions, not always at the end
- Update indexes — if a section has an
index.md with a list, update it too
Workflow: Docs Audit
When the user asks "which docs are stale?" or "audit my docs":
- 1. Discover all doc files (see Repo Discovery)
- For each doc file, check
git log -1 --format="%ar" -- <path> for last modified - Compare with recent code changes in related areas
- Report docs that may be stale:
- Doc hasn't been updated in a long time but related code changed recently
- Doc references files/functions/patterns that no longer exist
- Doc describes behavior that the code no longer implements
- 5. Suggest specific updates needed for each stale doc
Important Rules
- - Match existing style — read the doc before updating it. Don't impose a new format.
- Be surgical — update the specific section that changed, don't rewrite entire docs
- Features are user-facing — don't write "Added SyncSettingsView.swift", write
"Added sync settings with enable/disable toggle, status indicator, and Sync Now button"
- - Don't remove accurate content — only remove content that's now wrong
- Commit to a branch — never push directly to main
- One concern per update — if a PR changed both features and architecture, update
both docs but keep the changes focused on what actually changed
- - Respect repo conventions — if the repo has CLAUDE.md or CONTRIBUTING.md, read
and follow its branch naming, commit message, and PR conventions
文档同步
前置条件
- - git
- gh(GitHub CLI,通过 gh auth login 进行身份验证)
保持项目文档与代码变更同步。支持三种模式:
- 1. 内容同步 — 在代码变更后更新文档内容
- 站点管理 — 维护文档站点结构和导航
- 文档审计 — 识别需要关注的过时文档
仓库发现
在执行任何操作前,先发现项目的文档配置:
- 1. 运行 git rev-parse --show-toplevel 查找仓库根目录
- 检查仓库根目录是否存在 .docs-sync.yml — 如果存在,读取并使用其中的所有路径、角色和站点配置
- 如果没有配置文件,自动发现:
- 文档站点引擎:查找 mkdocs.yml、docusaurus.config.js、.vitepress/config.*
- 文档目录:查找 docs/、documentation/、wiki/
- 已知文档文件:扫描常见模式(参见下方文档角色)
- 约定文件:CLAUDE.md、AGENTS.md、CONTRIBUTING.md
- 4. 运行 gh repo view --json name,owner 确认仓库
配置文件:.docs-sync.yml
位于仓库根目录的可选配置文件。所有字段均为可选 — 自动发现会填补空缺。
参见技能目录中的 docs-sync.yml 作为入门模板。
yaml
将文档文件映射到角色,以便技能知道内容归属
docs:
- path: docs/features.md
role: features
- path: docs/architecture.md
role: architecture
- path: CHANGELOG.md
role: changelog
format: keep-a-changelog
- path: CLAUDE.md
role: conventions
- path: README.md
role: readme
文档站点配置(可选)
site:
engine: mkdocs # mkdocs | docusaurus | vitepress
config: mkdocs.yml # 站点配置路径
auto_nav: true # 文档变更时更新导航
文档角色
角色告诉技能文件包含何种内容,以便知道如何更新它。
| 角色 | 内容 | 更新时机 |
|---|
| features | 面向用户的功能描述、快捷键、状态 | 新增功能、功能行为变更 |
| architecture |
应用结构、数据流、模式、图表 | 新增组件、模式变更、重构 |
| conventions | 开发设置、编码规则、构建命令 | 构建流程变更、采用新约定 |
| changelog | 基于版本的变更历史 | 任何重要变更(遵循格式:keep-a-changelog、conventional、custom) |
| readme | 项目概述、安装说明、快速入门 | 主要功能、安装流程变更 |
| api | API 参考、端点、函数签名 | 公共 API 变更 |
| guide | 教程、操作指南、演练 | 工作流变更、新功能 |
| custom | 其他任何内容 — 在 description 字段中描述 | 基于你的描述 |
自动检测(无配置)
没有配置文件时,技能通过文件名检测角色:
| 模式 | 推断角色 |
|---|
| feature、capability | features |
| architect、design、structure |
architecture |
| CLAUDE.md、AGENTS.md、CONTRIBUTING.md、
convention | conventions |
| CHANGELOG
、CHANGES、HISTORY* | changelog |
| README* | readme |
|
api、
reference、
endpoint | api |
|
guide、
tutorial、
howto | guide |
不匹配任何模式的文件将被跳过,除非在配置中列出。
工作流:内容同步
当用户表示文档需要更新时(或在 PR 合并后):
- 1. 识别变更内容 — 确定代码变更范围:
- 如果提供了 PR 编号:gh pr view
--json files,title,body
- 如果是提交范围:git diff --name-only <范围>
- 如果未指定:git diff --name-only HEAD~1(上次提交)
- 读取变更文件的实际差异,了解变更了什么,而不仅仅是哪些文件变更了
- 2. 将变更映射到受影响的文档 — 对于每个变更文件,确定哪些文档角色受影响:
- 新增 UI 组件 → features、architecture
- 数据模型变更 → architecture
- 新增键盘快捷键 → features
- 构建命令变更 → conventions
- 错误修复 → changelog(如果跟踪修复)
- 新增 API 端点 → api、readme(如果是重点功能)
- 3. 读取当前文档 — 读取每个受影响的文档文件,了解当前内容、结构和风格
- 4. 起草更新 — 为每个文档编写具体需要的变更:
- 匹配现有的写作风格和结构
- 添加到现有章节而非创建新章节(除非明确需要)
- 对于 changelog:在适当的版本/章节下添加条目
- 对于 features:添加或更新功能条目,而非重写整个文件
- 对于 architecture:更新受影响的章节,保留图表
- 5. 应用或提议 — 基于用户偏好:
- 直接应用:编辑文件,提交到分支,报告变更内容
- 先审查:展示提议的变更并请求批准
- 创建 Issue:创建 GitHub Issue,列出哪些文档需要更新及原因
质量检查清单
在提交文档更新前:
- - [ ] 每次更新匹配该文档文件的现有风格
- [ ] 未删除仍然准确的内容
- [ ] 新条目放置在正确的章节(而非随机追加)
- [ ] 文档间的交叉引用保持一致
- [ ] 变更日志条目遵循文件的现有格式
- [ ] 功能描述面向用户(而非实现细节)
工作流:站点管理
当文档被添加、移动或删除时 — 保持站点结构最新。
mkdocs
- 1. 读取 mkdocs.yml 并解析 nav: 章节
- 对于新文档:根据文档的角色和路径确定正确的导航章节
- 在 nav: 的正确位置添加条目
- 对于移动的文档:更新导航路径
- 对于删除的文档:移除导航条目
docusaurus
- 1. 检查 sidebars.js 或 sidebars.ts
- 对于自动生成的侧边栏:确保文档具有正确的前置元数据(sidebarposition、sidebarlabel)
- 对于手动侧边栏:添加/更新/移除条目
vitepress
- 1. 检查 .vitepress/config.* 中的侧边栏配置
- 根据需要添加/更新/移除侧边栏条目
通用规则
- - 保留现有组织 — 不要重新组织导航,只需维护它
- 遵循命名模式 — 如果现有条目使用标题大小写,保持一致
- 尊重排序 — 在逻辑位置添加新条目,而非总是放在末尾
- 更新索引 — 如果某个章节有带列表的 index.md,也一并更新
工作流:文档审计
当用户询问哪些文档过时了?或审计我的文档时:
- 1. 发现所有文档文件(参见仓库发现)
- 对于每个文档文件,检查 git log -1 --format=%ar -- <路径> 获取最后修改时间
- 与相关区域的近期代码变更进行比较
- 报告可能过时的文档:
- 文档长时间未更新但相关代码近期有变更
- 文档引用了不再存在的文件/函数/模式
- 文档描述了代码不再实现的行为
- 5. 为每个过时文档建议具体需要的更新
重要规则
- - 匹配现有风格 — 在更新前阅读文档。不要强加新格式。
- 精准修改 — 只更新变更的具体章节,不要重写整个文档
- 功能面向用户 — 不要写添加了 SyncSettingsView.swift,而应写添加了同步设置,包含启用/禁用开关、状态指示器和立即同步按钮
- 不要删除准确内容 — 只删除现在错误的内容
- 提交到分支 — 永远不要直接推送到主分支
- 每次更新关注一个事项 — 如果 PR 同时变更了功能和架构,更新两个文档但保持变更聚焦于实际变更的内容
- 尊重仓库约定 —