Docs Sync
Prerequisites
- git
- gh (GitHub CLI, authenticated via
gh auth login)
Keep project documentation current with code changes. Three modes:
- 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:
- 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
- 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
- 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.
# Map your doc files to roles so the skill knows what content belongs where
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
# Doc site configuration (optional)
site:
engine: mkdocs # mkdocs | docusaurus | vitepress
config: mkdocs.yml # path to site config
auto_nav: true # update navigation when docs change
Doc Roles
Roles tell the skill what kind of content a file contains, so it knows how to update it.
| Role |
Content |
Updated when... |
features |
User-facing feature descriptions, shortcuts, status |
New feature added, feature behavior changes |
architecture |
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 |
*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 |
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):
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
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)
Read current docs — read each affected doc file to understand current content,
structure, and style
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
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:
Workflow: Site Management
When docs are added, moved, or deleted — keep the site structure current.
mkdocs
- 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
- Check
sidebars.js or sidebars.ts
- For auto-generated sidebars: ensure the doc has correct frontmatter (
sidebar_position, sidebar_label)
- For manual sidebars: add/update/remove entries
vitepress
- 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":
- 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
- 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
1---2name: docs-sync3description: Keep project documentation in sync with code changes. Identifies which docs need updating after a PR merges or code changes, drafts the updates, and manages doc site structure (mkdocs, docusaurus, vitepress). Use when: (1) a PR just merged and docs may need updating, (2) the user says "update the docs" or "sync docs", (3) a new doc was created and needs to be added to site navigation, (4) the user wants to audit which docs are stale. NOT for: writing docs from scratch for a new project (just write them), generating API reference docs from code comments (use typedoc/jazzy/etc.), or content that isn't developer documentation.4---56# Docs Sync78## Prerequisites910- git11- gh (GitHub CLI, authenticated via `gh auth login`)1213Keep project documentation current with code changes. Three modes:14151. **Content sync** — update doc content after code changes162. **Site management** — maintain doc site structure and navigation173. **Docs audit** — identify stale docs that need attention1819## Repo Discovery2021Before doing anything, discover the project's documentation setup:22231. Run `git rev-parse --show-toplevel` to find the repo root242. Check for `.docs-sync.yml` at the repo root — if it exists, read it and use its25 values for all paths, roles, and site config263. If no config file, auto-discover:27 - Doc site engine: look for `mkdocs.yml`, `docusaurus.config.js`, `.vitepress/config.*`28 - Doc directory: look for `docs/`, `documentation/`, `wiki/`29 - Known doc files: scan for common patterns (see Doc Roles below)30 - Convention files: `CLAUDE.md`, `AGENTS.md`, `CONTRIBUTING.md`314. Run `gh repo view --json name,owner` to confirm the repo3233### Config File: `.docs-sync.yml`3435Optional config file at repo root. All fields are optional — auto-discovery fills gaps.36See `docs-sync.yml` in the skill directory for a starter.3738```yaml39# Map your doc files to roles so the skill knows what content belongs where40docs:41 - path: docs/features.md42 role: features4344 - path: docs/architecture.md45 role: architecture4647 - path: CHANGELOG.md48 role: changelog49 format: keep-a-changelog5051 - path: CLAUDE.md52 role: conventions5354 - path: README.md55 role: readme5657# Doc site configuration (optional)58site:59 engine: mkdocs # mkdocs | docusaurus | vitepress60 config: mkdocs.yml # path to site config61 auto_nav: true # update navigation when docs change62```6364## Doc Roles6566Roles tell the skill what kind of content a file contains, so it knows *how* to update it.6768| Role | Content | Updated when... |69|------|---------|-----------------|70| `features` | User-facing feature descriptions, shortcuts, status | New feature added, feature behavior changes |71| `architecture` | App structure, data flow, patterns, diagrams | New components, changed patterns, refactors |72| `conventions` | Dev setup, coding rules, build commands | Build process changes, new conventions adopted |73| `changelog` | Version-based change history | Any significant change (follows format: keep-a-changelog, conventional, custom) |74| `readme` | Project overview, install instructions, quick start | Major features, install process changes |75| `api` | API reference, endpoints, function signatures | Public API changes |76| `guide` | Tutorials, how-tos, walkthroughs | Workflow changes, new capabilities |77| `custom` | Anything else — describe in the `description` field | Based on your description |7879### Auto-Detection (No Config)8081Without a config file, the skill detects roles by filename:8283| Pattern | Inferred role |84|---------|--------------|85| `*feature*`, `*capability*` | `features` |86| `*architect*`, `*design*`, `*structure*` | `architecture` |87| `CLAUDE.md`, `AGENTS.md`, `CONTRIBUTING.md`, `*convention*` | `conventions` |88| `CHANGELOG*`, `CHANGES*`, `HISTORY*` | `changelog` |89| `README*` | `readme` |90| `*api*`, `*reference*`, `*endpoint*` | `api` |91| `*guide*`, `*tutorial*`, `*howto*` | `guide` |9293Files not matching any pattern are skipped unless listed in the config.9495## Workflow: Content Sync9697When the user says docs need updating (or after a PR merge):98991. **Identify what changed** — determine the scope of code changes:100 - If a PR number is provided: `gh pr view <N> --json files,title,body`101 - If a commit range: `git diff --name-only <range>`102 - If unspecified: `git diff --name-only HEAD~1` (last commit)103 - Read the actual diffs for changed files to understand *what* changed, not just *which* files1041052. **Map changes to affected docs** — for each changed file, determine which doc106 roles are affected:107 - New UI component → `features`, `architecture`108 - Changed data model → `architecture`109 - New keyboard shortcut → `features`110 - Changed build command → `conventions`111 - Bug fix → `changelog` (if tracking fixes)112 - New API endpoint → `api`, `readme` (if it's a headline feature)1131143. **Read current docs** — read each affected doc file to understand current content,115 structure, and style1161174. **Draft updates** — write the specific changes needed for each doc:118 - Match the existing writing style and structure119 - Add to existing sections rather than creating new ones (unless clearly needed)120 - For `changelog`: add entry under the appropriate version/section121 - For `features`: add or update the feature entry, not rewrite the whole file122 - For `architecture`: update the affected section, preserve diagrams1231245. **Apply or propose** — based on user preference:125 - **Direct apply**: edit the files, commit to a branch, report what changed126 - **Review first**: show the proposed changes and ask for approval127 - **Issue**: create a GitHub issue listing which docs need updating and why128129### Quality Checklist130131Before committing doc updates:132133- [ ] Each update matches the existing style of that doc file134- [ ] No content was removed that's still accurate135- [ ] New entries are placed in the correct section (not appended randomly)136- [ ] Cross-references between docs are consistent137- [ ] Changelog entries follow the file's existing format138- [ ] Feature descriptions are user-facing (not implementation details)139140## Workflow: Site Management141142When docs are added, moved, or deleted — keep the site structure current.143144### mkdocs1451461. Read `mkdocs.yml` and parse the `nav:` section1472. For new docs: determine the correct nav section based on the doc's role and path1483. Add the entry to `nav:` in the right position1494. For moved docs: update the nav path1505. For deleted docs: remove the nav entry151152### docusaurus1531541. Check `sidebars.js` or `sidebars.ts`1552. For auto-generated sidebars: ensure the doc has correct frontmatter (`sidebar_position`, `sidebar_label`)1563. For manual sidebars: add/update/remove entries157158### vitepress1591601. Check `.vitepress/config.*` for sidebar configuration1612. Add/update/remove sidebar entries as needed162163### General Rules164165- **Preserve existing organization** — don't reorganize the nav, just maintain it166- **Follow naming patterns** — if existing entries use Title Case, match that167- **Respect ordering** — add new entries at logical positions, not always at the end168- **Update indexes** — if a section has an `index.md` with a list, update it too169170## Workflow: Docs Audit171172When the user asks "which docs are stale?" or "audit my docs":1731741. Discover all doc files (see Repo Discovery)1752. For each doc file, check `git log -1 --format="%ar" -- <path>` for last modified1763. Compare with recent code changes in related areas1774. Report docs that may be stale:178 - Doc hasn't been updated in a long time but related code changed recently179 - Doc references files/functions/patterns that no longer exist180 - Doc describes behavior that the code no longer implements1815. Suggest specific updates needed for each stale doc182183## Important Rules184185- **Match existing style** — read the doc before updating it. Don't impose a new format.186- **Be surgical** — update the specific section that changed, don't rewrite entire docs187- **Features are user-facing** — don't write "Added SyncSettingsView.swift", write188 "Added sync settings with enable/disable toggle, status indicator, and Sync Now button"189- **Don't remove accurate content** — only remove content that's now wrong190- **Commit to a branch** — never push directly to main191- **One concern per update** — if a PR changed both features and architecture, update192 both docs but keep the changes focused on what actually changed193- **Respect repo conventions** — if the repo has CLAUDE.md or CONTRIBUTING.md, read194 and follow its branch naming, commit message, and PR conventions