codemap
Skill8 starsChanged 5 months agoMITView on GitHub
Generate and incrementally maintain an interactive architecture map plus a per-module code-quality audit (health scores 0-100, smell findings, lines-of-code, and a clickable dependency graph) for any codebase. Use when the user wants to visualize a project's functional modules, audit or score code quality, check whether the architecture map is stale / up to date, incrementally refresh it after code changes, or auto-fix the findings of a specific module. Module audits are run by independent subagents against a fixed rubric. Triggers: "architecture map", "module map", "audit the codebase", "score the code", "visualize the project", "is the arch map current", "update the architecture diagram", "fix module X".
16 other projects use a version of this.
Adopted by
Most recently taken up by
- thistleknot/skillstheir own version, first seen Nov 8, 2026
- openyida/openyidatheir own version, first seen Nov 3, 2026
- hmjBill/skillstheir own version, first seen Oct 29, 2026
- jellydn/my-ai-toolstheir own version, first seen Oct 18, 2026
- mike22890/opencode-skills-entheir own version, first seen Oct 15, 2026
- htdxd/codemap-skilltheir own version, first seen Oct 9, 2026
Used with
Projects with it also use clonedeps and simplify.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
mike22890Skillclonedeps
将项目依赖的第三方库源码克隆到本地,便于深入阅读和调试。当需要查看库的实现细节、阅读源码、调试第三方依赖、理解 SDK/framework 内部机制、查看 node_modules 之外的原始代码、分析开源库架构、学习他人代码、查看依赖的 TypeScript 类型定义时使用。
Also in 4 projects that use this
Hugging FaceSkillsimplify
Refactor code after tests pass. The "Refactor" phase of Red-Green-Refactor.
Also in 4 projects that use this
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- JordanCoin/codemap★ 710same name
- akitaonrails/my-skills★ 283same name
- openyida/openyida★ 231same name
- jellydn/my-ai-tools★ 127same name
- ulpi-io/browse★ 15same name
- lglucas/ai-dev-operating-system★ 12same name
- beadnall/codemap★ 8same name
- shalomb/agent-skills★ 3same name
- htdxd/codemap-skill★ 2same name
- arkan/skills★ 1same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 5 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 15 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 135
Keep the top model for decomposition, theme synthesis, and fixes only.
- Very specific: line 143
update, notinit: After the first build, only ever run update — it re-audits just the git-changed modules (needs_audit), so … - Very specific: line 145
Structure-first for big repos: Run init in structure-only mode (decompose + scan --write + render, *no audits*) to get the map and LoC …
- Very specific: line 154
Use when no modules.json exists yet.
- Distinctive: line 186
Run on the cheapest capable model, read targeted excerpts, and batch the small/leaf modules per *Token efficiency* + STANDARDS.md.
- Very specific: line 192
Render: run the render command. Then stamp the git baseline so future updates can diff from here: python3 scripts/scan.py --root <proj> …
- Distinctive: line 198
Use when the user asks "is the architecture map up to date / still accurate?".
- Very specific: line 201
Read the JSON: report up_to_date, the stale list (code changed since audit),
- Very specific: line 211
Use after code changes, or when check found drift.
- Very specific: line 217
Read the report's git block: commits (since meta.rev, the last run) and changed_modules (modules those commits touched).
- Very specific: line 226
Refresh
reportThemes: if the changes are material (otherwise keep them). - Very specific: line 240
coverage: add missing unit tests for the module's public surface and the behaviors named in its findings.
- Distinctive: line 255
Keep test-author distinct from fixer and auditor.
- Distinctive: line 259
Use when the user says "fix the findings in module X" / "auto-fix the worst offenders".
- Very specific: line 269
Baseline (test-author subagent): Ensure the module has tests that lock its CURRENT behavior.
- Very specific: line 284
Re-audit (auditor subagent, independent): Only after PASS: re-score the module → scan.py --write → apply_audit.py → render.
“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
codemap — Architecture Map & Code-Quality Audit
Builds and maintains three coupled artifacts for a project:
modules.json— the source of truth: every functional module (not file) with its paths, dependencies, coupling, LoC, content hash, score, grade, tags, findings.codemap.html— a self-contained interactive map (layered modules, dependency highlighting, health coloring, audit-report view).codemap.md— the written report (per-layer scores, per-module LoC table, worst offenders, cross-cutting themes).
The HTML and MD are always regenerated from modules.json by render.py. Never
hand-edit them. The state file makes everything incremental: a content hash per
module tells us exactly what changed and what needs re-auditing.
Standard
The scoring rubric, smell taxonomy, severity levels, and the required subagent prompt
are fixed in reference/STANDARDS.md — read it and follow it verbatim. The state
schema is in reference/DATA_MODEL.md. Do not improvise scoring or invent tags.
The standard is configurable per project. A machine-readable copy lives in
reference/standard.json (rubric, severities, coupling, and the tag list with
descriptions). A project may override it by placing its own standard.json next to the
state file (<project>/.codemap/standard.json) — render.py picks the project
file first, else the skill default, and injects it into the map's editable Standard
page. Honor the project's tag set: when .codemap/standard.json exists, audit
modules using its tags (including any custom tags the user added) — that is how users
capture their own definition of a problem. Keep STANDARDS.md (the prose + subagent
prompt) and standard.json (the machine copy) in sync if you change the defaults.
Conventions
SKILL_DIR= this skill's directory. Scripts are atSKILL_DIR/scripts/*.py, template atSKILL_DIR/assets/template.html. Use python3, stdlib only.Everything lives under
<project>/.codemap/— one folder, not.claude/:config.json— the user's saved preferences (UI language, output location, title…).modules.json— the state (source of truth).standard.json— optional per-project custom audit standard.codemap.html+codemap.md— the generated outputs (default).
The output location is a user preference: if they want the HTML/MD committed/visible, let them point it at
docs/instead (ask — seeinitstep 0). Setmeta.htmlPath/meta.mdPathto wherever the outputs land so the reciprocal links are correct (both outputs sit in the same dir, so the in-page link uses the basename).- A re-render command (run after any state change):
python3 SKILL_DIR/scripts/render.py --state <state> \ --template SKILL_DIR/assets/template.html \ --out-html <htmlPath> --out-md <mdPath>
Targeting modules without reading the whole state (query.py)
modules.json can be large. To decide what to audit/fix/test, DO NOT read the whole
file — use scripts/query.py to select exactly the modules you need and get back just
ids, file globs, or findings. This keeps agent context small.
# ids of every C-and-below module (feed a fix/audit loop)
python3 SKILL_DIR/scripts/query.py --state <state> --max-grade C --format ids
# modules carrying a specific problem (compact table)
python3 SKILL_DIR/scripts/query.py --state <state> --tag dual-format
# only the file globs to read for the D/F modules → read just those files
python3 SKILL_DIR/scripts/query.py --state <state> --max-grade D --format paths
# the exact findings to fix for one tag, as text
python3 SKILL_DIR/scripts/query.py --state <state> --tag glue --format findings
# what needs re-auditing
python3 SKILL_DIR/scripts/query.py --state <state> --needs-audit --format idsFilters (AND-combined): --max-grade {A..F} (that grade and worse), --min-score/--max-score,
--tag T (repeatable; ANY, or --match-all), --sev HIGH|MED|LOW, --band, --coupling,
--needs-audit. Output --format: ids | paths | findings | table | json | count. Use
--format paths to read ONLY the relevant source, and --format ids to drive the
per-module subagent loop — never load the full modules.json just to pick targets.
Hard rules
- Every module score comes from an independent sub-task. One sub-task audits one
module against its
paths, using the prompt inreference/STANDARDS.md. Never score inline in the main thread; never copy one module's score to another. Run them in parallel where the platform supports it (see Capabilities & platform mapping). - Scripts are deterministic; only decomposition, auditing, and theme-synthesis are
model work.
scan.py/render.py/apply_audit.pynever make quality judgments. modules.jsonis the only thing you edit by hand (structure/decomposition). HTML/MD are generated. Runscan.py --writebefore every render so LoC/hashes are fresh.- Functional modules, not files. A module is a capability (a store, a handler
group, a feature folder, a plugin). Map each to a glob set in
paths. Give every module a 1-linedesc("what it does", shown on click) authored inmeta.lang(setmeta.langto"zh"/"en"; it localizes the UI chrome — module names/ids are never translated). - Four separate, independent subagent roles — never merge two: auditor (scores quality), test-author (writes tests), fixer (changes code), acceptance/verifier (proves no regression). A fix is accepted ONLY when an independent acceptance subagent shows the pre-fix green tests are still green and the build/typecheck is clean. A fixer may not write/edit its own tests or grade its own work — that defeats the gate.
Capabilities & platform mapping
This workflow needs three capabilities. Each has a graceful fallback, so it runs on any agent — only the convenience changes, never the rules above.
| Capability | Native (Claude Code) | Codex / Cursor | Fallback if unavailable |
| Independent sub-tasks (one auditor/fixer per module) | Agent tool, many in parallel | their subagent/task tool | Audit modules one at a time in the main thread — still one module per pass against the rubric, never batch-scoring. Slower, fully valid. |
| Structured result (the audit JSON) | schema on the Agent call | tool-specific schema, or just ask for JSON | Ask the sub-task to return only the JSON object; apply_audit.py validates it and rejects malformed/inconsistent results — no schema feature required. |
Ask the user (preferences on init) | AskUserQuestion | tool's prompt UI | Ask in plain text, or apply defaults (lang=en, output .codemap/, title = repo folder name) and tell the user how to change them in .codemap/config.json. |
The non-negotiables (independent per-module audit, deterministic scripts, the four-role fix gate) hold on every platform; the table only changes how you spawn the work.
Token efficiency
Almost all the cost is the per-module audit sub-tasks reading code — the scripts are nearly free. Levers, biggest first:
- Audit on the cheapest capable model. The audit is read-code + apply-fixed-rubric +
emit-JSON; a small/fast model does it well, and
apply_audit.pyrejects bad output. Keep the top model for decomposition, theme synthesis, and fixes only. - Read targeted, not whole. The audit prompt (STANDARDS.md) greps markers and reads
only the flagged regions; a huge file is scored from its size + a few excerpts, not a
full read. Use
query.py --format pathsso a sub-task opens only its module's files. - Batch the small modules. Group tiny / low-coupling leaves (≤ ~150 LoC) into one
sub-task that audits each independently (see STANDARDS.md). Core / large / high-coupling
modules stay solo. This cuts the number of spawns (each spawn re-pays system-prompt +
rubric overhead).
query.py --max-score 100 --format jsonthen group by loc/coupling. update, notinit. After the first build, only ever runupdate— it re-audits just the git-changed modules (needs_audit), so steady-state cost is tiny.- Structure-first for big repos. Run
initin structure-only mode (decompose +scan --write+ render, no audits) to get the map and LoC instantly and cheaply; the HTML renders unscored modules fine. Then fill scores over time withupdate/ on-demand audits, cheapest-first or worst-suspected-first.
Command: init (first build)
Use when no modules.json exists yet. (Also accepts generate as an alias.)
Ask the user for preferences first (use
AskUserQuestionif available, else just ask in plain text; or apply the defaults from Capabilities & platform mapping), then save them to<project>/.codemap/config.json:- UI language —
enorzh(localizes the map chrome + report; module names are never translated). →meta.lang. - Output location — where the HTML/MD go. Default
.codemap/(kept with the tool data); offerdocs/if they want them committed/visible. →meta.htmlPath/meta.mdPath. - Project title (defaults to the repo/folder name) and an optional one-line subtitle,
in the chosen language. →
meta.project/meta.subtitle.
Write
config.jsonlike:{"lang":"zh","project":"My App","subtitle":"…","outputDir":".codemap", "htmlFile":"codemap.html","mdFile":"codemap.md"}and apply it to
metawhen you buildmodules.json. Re-readconfig.jsonon later runs so preferences persist.- UI language —
- Decompose the project into functional modules. Explore the tree (parallel Explore
agents for big repos). Identify capabilities and group them into bands (visual
layers in data-flow order, e.g. UI → stores → transport → │wire│ → app → handlers →
core → persistence → plugins). For each module record
id, label, band, path, paths (globs), coupling, deps, desc. Addbands,spine(the critical request path), andmeta(project, htmlPath, mdPath, spineDesc). Write this tomodules.json(no scores yet). Coupling = structural centrality (low/med/high/core); core = the spine hubs. - Compute size:
python3 scripts/scan.py --root <proj> --state <state> --write. It reports every module asunaudited. - Audit — one independent sub-task per module, in parallel. For each id in
needs_audit, spawn a sub-task with thereference/STANDARDS.mdprompt (filled with the module's label/paths). Collect each JSON result and apply it:python3 scripts/apply_audit.py --state <state> --id <id> --json '<result>' [--rev <git rev>]. Run on the cheapest capable model, read targeted excerpts, and batch the small/leaf modules per Token efficiency + STANDARDS.md. Structure-only mode: for a huge repo (or a fast/cheap first pass) you may SKIP this step entirely — render the map with no scores (it renders unscored modules fine), then fill scores later withupdate. - Synthesize
reportThemes(4–7 cross-cutting patterns) from the collected findings and write them intomodules.json. - Render: run the render command. Then stamp the git baseline so future updates
can diff from here:
python3 scripts/scan.py --root <proj> --state <state> --stamp-rev. Report the result: avg score, grade spread, worst offenders, and the two artifact paths.
Command: check (is the map current? — read-only)
Use when the user asks "is the architecture map up to date / still accurate?".
python3 scripts/scan.py --root <proj> --state <state>(no--write).- Read the JSON: report
up_to_date, the stale list (code changed since audit), unaudited (new modules with no score), and empty (paths match nothing → likely deleted modules). Thegitblock shows the commits since the last codemap run (meta.rev) and which modules they touched — surface those commits so the user sees recent history at a glance. Do not modify anything; offer to runupdate. - Also sanity-check for new capabilities not yet in
modules.json(a quick look at new top-level dirs / large new files). New modules are model-discovered, not scan-detected.
Command: update (incremental refresh, git-aware)
Use after code changes, or when check found drift. Re-audits only what changed, and
uses git to show recent history and scope the work.
- Reconcile structure first (cheap): if modules were added/removed/renamed, edit
modules.json(add new module entries withpaths; dropemptyones; fix globs). - Scan + git diff:
python3 scripts/scan.py --root <proj> --state <state> --write. Read the report'sgitblock:commits(sincemeta.rev, the last run) andchanged_modules(modules those commits touched). Show the user the recent commits — this is the fast "what changed" view. The audit set isneeds_audit(= stale + unaudited); content-hash staleness already includes everythingchanged_moduleslists (plus any uncommitted edits), so re-auditneeds_audit. Ifgitis null the project isn't a git repo — fall back to content-hash staleness only. - Re-audit only those modules, each with its own independent subagent (same protocol
as
initstep 3). Apply each viaapply_audit.py --id <id> --rev <head>. Fresh modules keep their cached audit — that is the whole point of the content hash. - Refresh
reportThemesif the changes are material (otherwise keep them). - Render, then stamp the baseline:
python3 scripts/scan.py --root <proj> --state <state> --stamp-revcaches the current HEAD intometa.rev, so the nextupdate/checkdiffs from here. Summarize which modules were re-scored and how their score moved, with the commits that caused it.
Command: test <module> (generate tests)
A test-author subagent generates tests for a module — independently of fixing. This
is also the prerequisite for a safe fix (it builds the regression net). Two modes:
- characterization (default before a fix): lock the module's CURRENT observable behavior so a later change can't silently alter it. Assert "same as today", not "correct".
- coverage: add missing unit tests for the module's public surface and the behaviors
named in its
findings.
Steps:
- Detect the repo's test framework + location (pytest / jest / vitest / go test / …) from existing tests near the module; match their style and placement. Do NOT invent a new framework or harness.
- One test-author subagent writes tests against the module's
paths, runs them, and iterates until green on the CURRENT (unmodified) code. It reports: files added, what behavior is now locked, and a coverage note. If a test only passes by asserting a known bug, it must FLAG the bug, not bake it in as desired behavior. - Tests are real source — they stay in the tree (they are the regression net). Record
their globs in the module's
testsfield inmodules.json. Re-runscan.py --writeandrender.py(test LoC is tracked but excluded from the module's own audit scope).
Keep test-author distinct from fixer and auditor.
Command: fix <module-or-finding> (auto-fix, regression-gated)
Use when the user says "fix the findings in module X" / "auto-fix the worst offenders". A fix is only accepted if an independent acceptance subagent proves no regression. Four separate subagents (hard rule 5): test-author → fixer → acceptance → auditor.
- Scope (via
query.py). Resolve the target set withquery.pyinstead of reading the whole state — e.g.--max-grade C --tag dual-format --format idsfor "all C-and- below dual-format modules", then--format findingsfor just the findings to fix and--format pathsfor just the files to read. Confirm with the user before risky fixes (duplication merges, dual-format removal touching a protocol, deleting "dead" code — first verify it is truly unused). - Baseline (test-author subagent). Ensure the module has tests that lock its CURRENT
behavior; if coverage is thin, run
test <module>(characterization mode) first. Run the module's tests + the narrowest build/typecheck on the UNMODIFIED code and record the green baseline (which tests pass, build/type status, key outputs). If you can't get a green baseline, STOP and tell the user — auto-fixing without a behavioral net is not safe. - Fix (fixer subagent,
isolation: "worktree"). Give it the module's paths, findings, andreference/STANDARDS.mdrules; implement the fix and preserve behavior. The fixer must not edit tests (no moving the goalposts) and must not touch files outside its paths without flagging. - Acceptance gate (independent verifier subagent — NOT the fixer). Re-run the SAME
baseline tests + build/typecheck on the fixed code. Return
{pass: bool, regressions: [...], evidence: "..."}. PASS only if every baseline-green test is still green and there are no new build/type errors. On FAIL: report the regression with evidence and revert / hand back to the fixer — do not accept. - Re-audit (auditor subagent, independent). Only after PASS: re-score the module →
scan.py --write→apply_audit.py→ render. Show before/after score AND the acceptance evidence (tests run, all green, build clean). - Never auto-commit unless asked. Report honestly — a fix that fails the gate is
reported as failed, not merged. Record the outcome in the module's
lastFixfield.
Notes
- Coupling vs score are independent (structural vs quality) — see DATA_MODEL.md. The map can color by either (toggle in the header).
- Big repos: parallelize decomposition (Explore) and auditing (one agent per module). Chunk audits if there are many dozens of modules.
- Determinism: same
modules.json→ identical HTML/MD. Commitmodules.jsonso the audit history and incremental diffs are reviewable. - Languages: the engine is language-agnostic —
pathsglobs and LoC counting work for any stack; the subagent reads whatever code the globs point at.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

