Update documentation after commits. Syncs README, AGENTS.md, CHANGELOG, and docs/ with code changes. Use after commits or to analyze working tree changes.
Automatically update documentation to reflect code changes. Enforces the "README as landing page" pattern—README should be a concise entry point, with detailed documentation in docs/.
"Your README is not your documentation. It is an overview of your project... a gateway to other pieces of info."
| README.md | docs/ | |-----------|-------| | What is this? Why should I care? | How does everything work? | | Quick start (copy-paste ready) | Step-by-step tutorials | | Minimal examples | Complete API/command reference | | Links to detailed docs | In-depth configuration | | < 300 lines ideal | As long as needed |
/update-docs HEAD~3..HEAD to analyze specific commits/update-docs --working-tree to analyze uncommitted changes/update-docs --audit to check README health and suggest migrationsHEAD~N..HEAD: Analyze the last N commitsCOMMIT1..COMMIT2: Analyze a specific commit range--working-tree or -w: Analyze uncommitted changes in working tree--audit or -a: Audit README structure and suggest migrations to docs/When triggered by post-commit hook, check for .claude/doc-update-pending.json:
if [ -f .claude/doc-update-pending.json ]; then
COMMIT=$(jq -r '.commit_short' .claude/doc-update-pending.json)
fi
After processing, always clean up:
rm -f .claude/doc-update-pending.json
Update Docs Progress:
- [ ] Phase 1: Discover and audit documentation structure
- [ ] Phase 2: Detect changes (git diff or working tree)
- [ ] Phase 3: Route updates to correct location
- [ ] Phase 4: Migrate bloated README sections (if needed)
- [ ] Phase 5: Apply updates
- [ ] Phase 6: Update CHANGELOG (if exists)
- [ ] Phase 7: Create docs commit (if changes made)
# Primary
README.md, AGENTS.md, CHANGELOG.md, CONTRIBUTING.md
# Secondary (docs/)
docs/*.md, docs/**/*.md
# Config
package.json, pyproject.toml, Cargo.toml
Analyze README.md for signs it needs restructuring:
Red Flags (README is bloated):
| Signal | Threshold | Action |
|--------|-----------|--------|
| Total lines | > 500 lines | Recommend migration |
| Commands table | > 20 entries | Move to docs/commands.md |
| File structure tree | > 30 lines | Move to docs/file-structure.md |
| Configuration section | > 50 lines | Move to docs/configuration.md |
| Multiple H2 sections for same topic | Any | Consolidate in docs/ |
| Code blocks | > 10 blocks | Move examples to docs/ |
Check for these README sections that belong in docs/:
## Commands Reference → docs/commands.md
## API Reference → docs/api.md
## Configuration → docs/configuration.md
## File Structure → docs/file-structure.md
## Detailed Examples → docs/examples.md
## Troubleshooting → docs/troubleshooting.md
## Architecture → docs/architecture.md
A healthy README should have only:
# Project Name
One-line description.
## TL;DR / What is this?
2-3 sentences max.
## Quick Start
5-10 lines of copy-paste commands.
## Documentation
- [Commands Reference](docs/commands.md)
- [Configuration](docs/configuration.md)
- [Contributing](CONTRIBUTING.md)
## License
One line.
git diff --name-only <range>
git diff --stat <range>
git status --porcelain
git diff
git diff --cached
| Category | Examples |
|----------|----------|
| Skill/Command | .claude/skills/, .claude/commands/ |
| Structure | New directories, renamed files |
| Configuration | package.json, settings files |
| Feature | New functionality |
| Fix | Bug fixes |
| Change Type | Target File | NOT README |
|-------------|-------------|------------|
| New skill/command | docs/commands.md | ~~README commands table~~ |
| Skill description changed | docs/commands.md | |
| New config option | docs/configuration.md | |
| File structure changed | docs/file-structure.md | |
| New API endpoint | docs/api.md | |
| New workflow pattern | AGENTS.md | |
| Quick start broken | README.md | (exception) |
| Project description changed | README.md | (exception) |
| New major feature | README.md (one line) + docs/ (details) | |
Only update README.md directly for:
If routing requires a docs/ file that doesn't exist:
Template for new docs/ file:
# {Title}
{Brief description of what this document covers.}
## Overview
{Content migrated from README or new content}
---
*This documentation is auto-maintained. Last updated: {date}*
If Phase 1 audit found README sections that should be in docs/, migrate them.
See MIGRATION.md for:
For each routed update:
If new docs/ files were created, add links to README:
## Documentation
- [Commands Reference](docs/commands.md)
- [Configuration Guide](docs/configuration.md) ← NEW
- [File Structure](docs/file-structure.md)
Only update AGENTS.md when:
Do NOT auto-update:
If CHANGELOG.md exists, append entries.
Detect format from existing file:
## [Unreleased]
### Added
- New `docs/commands.md` for detailed command reference
### Changed
- Migrated commands table from README to docs/
### Fixed
- Fixed broken link in docs/setup.md
Rules:
git status --porcelain
git diff --stat
Documentation Updates
=====================
Migrations:
- README.md → docs/commands.md (142 lines moved)
New files:
- docs/commands.md (created)
Modified:
- README.md (replaced section with link)
- CHANGELOG.md (added entry)
Changes: +156 -142
git add <files>
git commit -m "docs: restructure documentation (README as landing page)
- Migrated commands table to docs/commands.md
- README now links to detailed docs
- Added CHANGELOG entry
Co-Authored-By: Claude <noreply@anthropic.com>"
docs/ directory.gitkeep if emptyProjects can customize via .claude/doc-sync-config.json. See CONFIGURATION.md for full schema.
Key options:
readme.maxLines: Warn threshold (default: 300)routing.*: Customize target docs/ filesautoMigrate: If true, migrations happen without asking--audit)When run with --audit, perform a full health check:
README Health Audit
===================
File: README.md
Lines: 847 (⚠️ > 500 recommended)
Sections that should be in docs/:
⚠️ "Commands Reference" (156 lines) → docs/commands.md
⚠️ "File Structure" (43 lines) → docs/file-structure.md
⚠️ "Configuration" (89 lines) → docs/configuration.md
✓ "Quick Start" (12 lines) — OK in README
✓ "License" (2 lines) — OK in README
Missing docs/ files:
✗ docs/commands.md (would receive 156 lines)
✗ docs/configuration.md (would receive 89 lines)
Recommendations:
1. Run /update-docs --migrate to restructure
2. README would go from 847 → ~150 lines
3. Creates 3 new files in docs/
Run migration? [Y/n]
See POST_COMMIT_HOOK.md for installation.
When triggered by hook:
autoMigrate: true in config| Situation | Action |
|-----------|--------|
| README.md does not exist in the project root | Skip README updates; route all changes to docs/ files and suggest creating a README |
| git diff returns no changes (nothing to analyze) | Report "No changes detected" and clean up any marker file; do not create an empty docs commit |
| Target docs/ file cannot be created (permissions or missing parent directory) | Create docs/ directory if missing; if permissions block creation, report the error and suggest manual resolution |
| Marker file (.claude/doc-update-pending.json) references a commit that no longer exists | Warn user that the referenced commit is unreachable, fall back to analyzing HEAD, and clean up the stale marker |
| Migration would move content but the destination file already has conflicting sections | Append new content below existing sections rather than overwriting; warn about potential duplication for manual review |
Always run at the end:
rm -f .claude/doc-update-pending.json
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer