with one click
codemap
// Generate comprehensive hierarchical codemaps for UNFAMILIAR repositories. Expensive operation - only use when explicitly asked for codebase documentation or initial repository mapping
// Generate comprehensive hierarchical codemaps for UNFAMILIAR repositories. Expensive operation - only use when explicitly asked for codebase documentation or initial repository mapping
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | codemap |
| description | Generate comprehensive hierarchical codemaps for UNFAMILIAR repositories. Expensive operation - only use when explicitly asked for codebase documentation or initial repository mapping |
You help users create and maintain a complete repository atlas for new contributors. The output is not a token-saving directory summary. It is a human-readable architecture map that lets someone understand the project, modules, entry points, workflows, configuration, state, dependencies, error handling, and common change paths before reading source code.
Every finished codemap.md must be useful to a new contributor. It must explain:
Prioritize completeness over brevity. Do not constrain sections to a short line count when more explanation is needed.
First, check if .slim/codemap.json exists in the repo root.
If it does not exist, check for legacy state at .slim/cartography.json.
If legacy state exists: move .slim/cartography.json to .slim/codemap.json,
then continue with change detection.
If .slim/codemap.json exists: Skip to Step 3 (Detect Changes) - no need to
re-initialize.
If neither file exists: Continue to Step 2 (Initialize).
README.md, important docs/*.md,
architecture notes, configuration examples, and script docs when they
explain features, commands, or usage.node_modules/**, dist/**, build/**, coverage output,
and *.min.js..gitignore automatically.node ~/.agents/skills/codemap/scripts/codemap.mjs init \
--root ./ \
--include "src/**/*.ts" \
--include "package.json" \
--include "README.md" \
--include "docs/**/*.md" \
--exclude "**/*.test.ts" \
--exclude "dist/**" \
--exclude "node_modules/**"
This creates:
.slim/codemap.json - file and folder hashes for change detectioncodemap.md files in relevant directories without overwriting
existing hand-written codemapscodemap.md has exactly one writer.
Leaf directories are written first, then intermediate directories, then
top-level directories, and the root Repository Atlas is finalized last.node ~/.agents/skills/codemap/scripts/codemap.mjs changes \
--root ./
node ~/.agents/skills/codemap/scripts/codemap.mjs update \
--root ./
Write directory codemaps from the deepest selected directories upward. The authoritative input for a parent directory is its own direct files plus the finished codemaps of its direct child directories. Do not split a large directory across multiple writers; handle it as a normal parent directory once its child codemaps are complete.
Use this order:
deepest leaf directories
↓
intermediate directories
↓
top-level directories
↓
root Repository Atlas
Read requirements are strict:
codemap.md of every selected direct child directory. Do not recursively reread
grandchildren source; the child codemaps are the authoritative source for child
internals.codemap.md file.A Module Codemap is incomplete if it skips any selected direct file, skips any selected direct child codemap, leaves starter skeleton text, or describes child internals without reading the child codemap first.
For every non-root directory with selected files, write a complete Module Codemap. It must contain these sections:
Once important directories are mapped, create or update the root codemap.md as
the first document a new contributor reads. It must not be only an aggregation
table. It must include explanatory narrative, flow descriptions, diagrams, and
links to deeper maps.
Before writing the root Repository Atlas, read the complete contents of every
selected direct file in the repository root and read the codemap.md of every
selected top-level directory. Do not finalize the root atlas before top-level
codemaps are complete.
The root Repository Atlas must contain these sections:
OpenCode auto-loads AGENTS.md into agent context on every session. To ensure
agents automatically discover and use the codemap, update (or create)
AGENTS.md at the repo root:
AGENTS.md already exists and already contains a ## Repository Map
section, skip this step — the reference is already set up.AGENTS.md exists but has no ## Repository Map section, append the
section below.AGENTS.md doesn't exist, create it with the section below.## Repository Map
A full codemap is available at `codemap.md` in the project root.
Before working on any task, read `codemap.md` to understand:
- Project architecture and entry points
- Directory responsibilities and design patterns
- Data flow and integration points between modules
- Key data types and entities
- Error handling and recovery strategies
For deep work on a specific folder, also read that folder's `codemap.md`.
This is idempotent — repeated codemap runs will detect the existing section and skip. No duplication.
Every finished codemap.md must contain two Mermaid diagrams:
flowchart LR or graph LR.sequenceDiagram for actor-to-component interactions or
flowchart TD for pipeline/control flow.Each diagram must be followed by prose explaining what nodes and arrows mean.
Do not finish a codemap that:
Before considering the codemap complete, verify that a new contributor can answer: