Generate and maintain architecture documentation for any codebase. Produces CLAUDE.md, docs/CODEBASE_MAP.md, README.md, and AGENTS.md with mermaid diagrams, annotated file trees, and navigation guides.
- Works with any language or project type (not limited to TypeScript/JavaScript)
- Scans codebase with token counting to plan parallel analysis
- Spawns parallel subagents for large codebases (stays within context limits)
- Detects existing docs and runs in update mode (only refreshes stale sections)
- Generates navigation guides — "To add a new X: touch these files" — the most actionable documentation for AI agents
# Clone to your skills directory
git clone https://github.com/jeremyknows/update-docs.git ~/.claude/skills/update-docsClone the repo and point your agent's skill loader at the SKILL.md file:
git clone https://github.com/jeremyknows/update-docs.git ~/update-docs- Python 3.9+ (ships with macOS, most Linux distros)
- uv (recommended) — handles dependencies automatically
# Verify Python 3.9+
python3 --version
# Install uv (optional but recommended)
curl -LsSf https://astral.sh/uv/install.sh | shIf uv is not installed, the scanner falls back to python3 (requires pip install tiktoken manually).
# Test the scanner
uv run ~/.claude/skills/update-docs/scripts/scan-codebase.py . --format treeYou should see a file tree with token counts.
Just tell Claude what you need:
- "Update the docs for this project"
- "Create a CLAUDE.md and codebase map"
- "Map this codebase"
- "My docs are stale, refresh them"
- "I need architecture documentation"
- "Generate a README"
# In any project directory
/update-docs| File | Purpose | When |
|---|---|---|
docs/CODEBASE_MAP.md |
Full architecture map with mermaid diagrams, directory tree, module guide, data flow, navigation guide | Always |
CLAUDE.md |
Dense agent reference (50–200 lines) — stack, commands, patterns, constraints | Full + Update modes |
README.md |
User-facing documentation | Full mode (or when stale) |
AGENTS.md |
Deep module reference | Only for projects with 4+ modules |
| Mode | Trigger | Behavior |
|---|---|---|
| Full | No existing docs/CODEBASE_MAP.md |
Generate all docs from scratch |
| Update | Existing map with last_mapped timestamp |
Scope to changed files since last map |
| Map-only | User specifically asks for codebase map | Generate only docs/CODEBASE_MAP.md |
- Scan — Runs
scan-codebase.pyto get file tree with token counts (respects.gitignore) - Plan — Groups files by module, balances token budgets across subagents
- Analyze — Spawns parallel Sonnet subagents to read and analyze code (orchestrator never reads files directly)
- Synthesize — Merges subagent reports into documentation using templates from
references/doc-templates.md - Verify — Checks all file path references exist and mermaid syntax is valid
- Report — Lists what was created/updated, leaves changes for user review (never commits)
No configuration needed. The skill auto-detects project type, language, and framework from the scan results.
# JSON output (used by the skill)
uv run scripts/scan-codebase.py . --format json
# Tree view with token counts
uv run scripts/scan-codebase.py . --format tree
# Compact view sorted by token count
uv run scripts/scan-codebase.py . --format compact
# Increase max tokens per file (default: 50,000)
uv run scripts/scan-codebase.py . --max-tokens 100000
# See all options
uv run scripts/scan-codebase.py --help| Scenario | Use |
|---|---|
| TypeScript/JavaScript project needing inline JSDoc | generate-docs |
| Any project needing CLAUDE.md, README, codebase map | update-docs |
| TypeScript project needing both | Run both — generate-docs for JSDoc, update-docs for architecture |
update-docs does NOT generate inline code comments. It generates standalone documentation files.
- Subagent-only architecture — The orchestrator never reads codebase files directly. For very small projects (< 10 files), this adds overhead but keeps the approach consistent.
- Token estimation — Uses
tiktokenwithcl100k_baseencoding. Accurate for Claude models but may over/under-count for other model families. - No inline comments — Generates standalone
.mdfiles only. Usegenerate-docsfor JSDoc/TSDoc. - Git dependency for update mode — Update mode requires a git repo to detect changes since last mapping. Falls back to full mode if not a git repo.
- Max file size — Scanner skips files over 1MB or 50,000 tokens (configurable with
--max-tokens). - Root .gitignore only — Only reads the root-level
.gitignore. Nested.gitignorefiles in subdirectories are not parsed. - No .gitignore negation —
.gitignorenegation patterns (!pattern) are not supported; negated files will still be excluded.
| Symptom | Cause | Fix |
|---|---|---|
ERROR: tiktoken not installed |
uv not available and tiktoken not installed |
Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh |
| Scanner returns 0 files | All files matched ignore patterns | Check .gitignore; scanner respects it plus built-in excludes |
| Mermaid diagrams don't render | Node IDs contain special characters | File an issue — the sanity check should catch this |
| Update mode maps everything | No last_mapped in frontmatter |
Previous map was manually created without frontmatter; delete and re-run in full mode |
Permission denied on scanner |
Script not executable | chmod +x scripts/scan-codebase.py |
update-docs/
├── SKILL.md # Main skill — orchestration instructions
├── README.md # This file
├── LICENSE.txt # MIT (skill + scanner attribution)
├── .gitignore
├── scripts/
│ └── scan-codebase.py # Codebase scanner with token counting (from Cartographer, MIT)
└── references/
└── doc-templates.md # Output templates + mermaid conventions
- Cartographer by Bootoshi —
scan-codebase.pyis bundled from this project (MIT license). The "Opus orchestrates, Sonnet reads" pattern and navigation guide concept also originate from Cartographer.
MIT — see LICENSE.txt