name: doc-syncer description: Detect stale documentation by cross-referencing git history against the project's actual doc layout. Auto-discovers root docs, docs/**, and .claude/{tasks,audits,memory}/. Stack-aware deploy-doc gating (DEPLOY.md only when non-trivial). Enforces README presence. Audit, report, 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, patch what can be patched automatically. Auto-discover what doc the project has and what it actually needs based on stack and deploy complexity. Never invent content -- only reflect what changed in code.
$ARGUMENTS
Parse $ARGUMENTS:
$ARGUMENTS starts with auto-mode scope:
Jump to AUTO MODE section.Auto-detect what doc files actually exist. No fixed list.
# Standard root doc files (only those that exist)
for f in README.md CLAUDE.md INSTALL.md CONFIGURE.md USAGE.md \
DEPLOY.md CONTRIBUTING.md CHANGELOG.md SECURITY.md \
CODE_OF_CONDUCT.md ARCHITECTURE.md ROADMAP.md LICENSE; do
[ -f "$f" ] && echo "$f"
done
# docs/ tree
find docs -name '*.md' 2>/dev/null
# .claude/ project-state docs
find .claude/tasks .claude/audits .claude/memory \
-name '*.md' 2>/dev/null
Store as DOC_FILES (existing) and DOC_MISSING (canonical names
absent — at minimum: README.md).
Detect project stack and deploy complexity. Drives later decisions about which docs are needed.
Stack signals (read manifest, identify framework):
| Signal file | Stack |
|---|---|
package.json — read dependencies |
Node/JS — React, Next.js, Astro, Vue, Svelte, Express, NestJS, etc. |
requirements.txt / pyproject.toml / Pipfile |
Python — Django, FastAPI, Flask, Streamlit |
Cargo.toml |
Rust — Axum, Actix, Tauri |
go.mod |
Go |
Gemfile |
Ruby/Rails |
composer.json |
PHP — Symfony, Laravel |
pubspec.yaml |
Dart/Flutter |
*.csproj / *.sln |
.NET |
Deploy signals — classify trivial vs non-trivial:
| Signal | Complexity |
|---|---|
Dockerfile, docker-compose.yml, compose.yaml |
NON_TRIVIAL |
fly.toml, render.yaml, railway.toml, vercel.json, netlify.toml |
NON_TRIVIAL |
.github/workflows/deploy*.yml, .gitlab-ci.yml w/ deploy stage |
NON_TRIVIAL |
kubernetes/, helm/, k8s/, manifests w/ kind: Deployment |
NON_TRIVIAL |
terraform/, pulumi/, serverless.yml, SAM template.yaml |
NON_TRIVIAL |
Makefile w/ multi-step deploy target |
NON_TRIVIAL |
Multiple env-specific configs (.env.production, .env.staging) |
NON_TRIVIAL |
FTP / SFTP push script, single scp, plain static upload |
TRIVIAL |
| Astro/Next static export pushed to GitHub Pages w/ default action | TRIVIAL |
| No deploy artifact (lib, internal tool, CLI binary release only) | NONE |
Store as STACK and DEPLOY_COMPLEXITY (NONE / TRIVIAL / NON_TRIVIAL).
Record evidence (which file triggered classification) for the report.
For each file in DOC_FILES:
Get last modification date:
git log -1 --format=%aI -- <file>
Get commits touching the codebase since that date. Adapt globs
to detected STACK:
git log --oneline --since="<date>" \
--diff-filter=AMRD -- <stack-specific source globs> \
'Dockerfile' 'docker-compose.yml' 'Makefile' \
'*.toml' '*.json' '*.yaml' '*.yml' '*.env.example'
For each commit, extract changes:
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, dep adds/removes/upgrades, new features, removed features.
Cross-reference each change against doc content.
Feature delta detection:
[ADDED].[REMOVED].git diff --stat between last doc edit and HEAD to
identify added (A) / deleted (D) files.Apply doc-specific checks. Skip docs not in DOC_FILES (handled
by STEP 5/6 if creation needed).
README.md — must exist; see STEP 5 if absent
INSTALL.md, CONFIGURE.md, USAGE.md, DEPLOY.md,
CONTRIBUTING.md, CHANGELOG.md)? Dead link → AUTO removal.
Missing link to existing doc → AUTO addition.CLAUDE.md
STACK?.claude/memory/decisions.md reflected when
architectural (framework choice, security stance, API versioning)?INSTALL.md
.env.example?CONFIGURE.md
USAGE.md
/api/v1/... rule)?DEPLOY.md
.env.example?DEPLOY_COMPLEXITY == TRIVIAL → file is overkill, propose
inlining content into README "Deploy" section. HUMAN.CONTRIBUTING.md
CHANGELOG.md
docs//*.md**
.claude/tasks/TODO.md
.claude/audits/*.md
.claude/memory/decisions.md / learnings.md / blockers.md
resolved?.claude/memory/journal.md / evals.md
Inline comments (JSDoc, docstrings, rustdoc, godoc)
@param / @return types match actual function signatures?If README.md ∉ DOC_FILES:
README is mandatory. Propose creation using typical GitHub layout —
include only sections relevant to detected STACK and
DEPLOY_COMPLEXITY. Use real project data (manifest name,
description, install/run commands). No placeholders.
Proposed template (HUMAN approval required):
# <project-name>
<one-line description from manifest or git remote>
## Features
- <bullet from detected entry points / commands>
- <bullet>
## Quick Start
\`\`\`bash
<install command from detected stack>
<run command from detected stack>
\`\`\`
## Documentation
- [Install](INSTALL.md) <!-- only if exists or proposed -->
- [Configure](CONFIGURE.md) <!-- only if exists or proposed -->
- [Usage](USAGE.md) <!-- only if exists or proposed -->
- [Deploy](DEPLOY.md) <!-- only if DEPLOY_COMPLEXITY == NON_TRIVIAL -->
- [Contributing](CONTRIBUTING.md) <!-- only if exists -->
- [Changelog](CHANGELOG.md) <!-- only if exists -->
## License
<from LICENSE file or manifest, else HUMAN>
Tag overall as HUMAN — user validates before write.
| State | Action |
|---|---|
DEPLOY_COMPLEXITY == NONE |
Skip. Don't propose DEPLOY.md. |
DEPLOY_COMPLEXITY == TRIVIAL AND no DEPLOY.md |
Skip. Suggest one-paragraph "Deploy" section in README. HUMAN. |
DEPLOY_COMPLEXITY == TRIVIAL AND DEPLOY.md exists |
Suggest deletion or inlining into README. HUMAN. |
DEPLOY_COMPLEXITY == NON_TRIVIAL AND no DEPLOY.md |
Propose creation. HUMAN. Template based on detected artifacts (Docker → image build + run + env; fly.toml → fly deploy + secrets; workflows → branch trigger + manual approval; k8s → kubectl apply + namespace + rollout). |
DEPLOY_COMPLEXITY == NON_TRIVIAL AND DEPLOY.md exists |
Apply standard drift detection (STEP 3-4). |
DOC SYNC REPORT
===============
PROJECT STACK : <detected stack>
DEPLOY : <NONE | TRIVIAL | NON_TRIVIAL — evidence>
DOCS PRESENT : <count> — <list>
DOCS MISSING : <list of canonical names not present>
## <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)
## CREATE PROPOSALS
- [HUMAN] README.md — bootstrap (template above)
- [HUMAN] DEPLOY.md — non-trivial deploy (Docker + fly.toml)
- ...
## REMOVE / INLINE PROPOSALS
- [HUMAN] DEPLOY.md — trivial deploy, inline into README instead
- ...
Tagging rules:
Feature delta tags:
[ADDED] — feature in code, not in docs. AUTO for list entry
with obvious wording, HUMAN if needs new section.[REMOVED] — feature in docs, not in code. AUTO for list entry
to delete, HUMAN if needs deprecation note.CHANGELOG entries always HUMAN. README/DEPLOY creation always HUMAN.
If no drift in any doc and no missing required doc:
DOC SYNC: all docs current and stop.
DOC SYNC — VALIDATION GATE
AUTO items : <count> (Claude will patch these)
HUMAN items : <count> (listed above for review)
CREATE items : <count> (README/DEPLOY proposals)
REMOVE items : <count>
Apply AUTO patches? (yes / select items / cancel)
Apply HUMAN/CREATE items? (per-item: yes / no / edit)
Wait for explicit approval. Do not proceed without it.
Apply only approved items:
<TODO> placeholders, no fabricated
feature descriptions.DOC SYNC COMPLETE
DOCS CHECKED : <count>
AUTO PATCHED : <count> items across <count> files
CREATED : <count> files
REMOVED : <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 file list from $ARGUMENTS. These are files modified
during the current session.
Map modified files to relevant docs:
.claude/memory/decisions.md change with architectural impact
→ CLAUDE.md, READMEIf no relevant docs exist for changed files → exit silently.
For each relevant doc, read it and check only sections affected by scoped changes. No full git scan — compare doc content directly against current state of modified files.
Feature deltas in scoped files:
Categorize:
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.
DEPLOY_COMPLEXITY == NON_TRIVIAL. Trivial
deploy belongs in README..claude/memory/journal.md and evals.md are append-only
logs — never edit..claude/memory/decisions.md / learnings.md / blockers.md
are user-curated registries — surface drift, don't auto-edit
(HUMAN only).