name: doc-syncer description: Detect stale documentation by cross-referencing git history against doc files. Audit, report, and patch. Supports full audit and automatic (silent) mode. tools: Read, Write, Edit, Bash, Grep, Glob
Keep documentation in sync with code. Detect drift, report it, and patch what can be patched automatically. Never invent content -- only reflect what actually changed in code.
$ARGUMENTS
Parse $ARGUMENTS to determine mode:
$ARGUMENTS starts with auto-mode scope:
Jump directly to AUTO MODE section below.Find all documentation files in the project:
# Standard doc files at root
ls README.md CLAUDE.md INSTALL.md CONFIGURE.md USAGE.md \
CONTRIBUTING.md CHANGELOG.md 2>/dev/null
# Docs directory
find docs -name '*.md' 2>/dev/null | head -50
Store the list as DOC_FILES.
If no docs found at all, report and stop.
For each file in DOC_FILES:
Get its last modification date:
git log -1 --format=%aI -- <file>
Get all commits touching the codebase since that date:
git log --oneline --since="<date>" \
--diff-filter=AMRD -- '*.py' '*.ts' '*.js' '*.tsx' \
'*.jsx' '*.rs' '*.go' '*.java' '*.c' '*.cpp' '*.h' \
'*.toml' '*.json' '*.yaml' '*.yml' '*.env.example' \
'Dockerfile' 'docker-compose.yml' 'Makefile' \
'package.json' 'Cargo.toml' 'pyproject.toml'
Adapt glob list to the project's actual stack.
For each commit, extract what changed:
git show --stat --name-only <hash>
git diff <hash>~1..<hash> --unified=3
Look for: new/renamed/deleted functions, new config keys, new CLI flags, changed endpoints, breaking changes, dependency adds/removes/upgrades, new features added, features removed or deprecated.
Cross-reference each change against the doc's content. Read the doc file and check if the change is reflected.
Feature delta detection — compare what the code provides vs what the docs describe:
git diff --stat between last doc edit and HEAD to
identify files added (A) or deleted (D).Apply doc-specific checks:
README.md
CLAUDE.md
INSTALL.md / CONFIGURE.md
USAGE.md
CONTRIBUTING.md
CHANGELOG.md
docs//*.md**
Inline comments (JSDoc, docstrings, rustdoc, godoc)
@param / @return types: match actual function signatures?Present a structured report:
DOC SYNC REPORT
===============
## <filename>
Last updated: <date> (<N commits since>)
1. [AUTO] <section> — <what's wrong>
Commit: <hash> — <message>
Fix: <proposed change>
2. [HUMAN] <section> — <what's wrong>
Commit: <hash> — <message>
Reason: <why this needs human judgment>
---
(repeat for each doc with drift)
Tagging rules:
Feature delta tags:
CHANGELOG entries are always tagged HUMAN — version bump and release notes are human decisions.
If no drift detected in any doc: print
DOC SYNC: all docs current and stop.
DOC SYNC — VALIDATION GATE
AUTO items : <count> (Claude will patch these)
HUMAN items: <count> (listed above for your review)
Apply AUTO patches? (yes / select items / cancel)
Wait for explicit approval. Do not proceed without it.
Apply only approved AUTO items:
After patching, re-read each modified file to verify no broken markdown, no orphaned references.
DOC SYNC COMPLETE
DOCS CHECKED : <count>
AUTO PATCHED : <count> items across <count> files
HUMAN PENDING: <count> items (see report above)
SKIPPED : <count> (user declined)
Triggered by other skills at end of session.
Input format: auto-mode scope: <file1> <file2> ...
Extract the file list from $ARGUMENTS.
These are files modified during the current session.
For each modified file, determine which docs might reference it:
If no relevant docs exist for the changed files → exit silently.
For each relevant doc, read it and check only the sections that could be affected by the scoped changes. No full git scan — compare the doc content directly against the current state of the modified files.
Also check for feature deltas in the scoped files:
Categorize findings:
doc-sync: patched <file> (<what changed>)SIGNIFICANT → surface to user before patching:
DOC SYNC — drift detected after this session:
<list of significant items with proposed fixes>
Apply? (yes / no / select)
Wait for approval.