Claude dependency mapper
Skill Bakoware/claude-dependency-mapper/skills/claude-dependency-mapper
Map a project's dependency graph. Generates an Obsidian vault (obsidian-graph/) for human visualization and, for medium/large codebases, a compact PROJECT_MAP.md for token-efficient AI navigation. Decides the route by file count, wires up CLAUDE.md, adds .gitignore entries so the graphs are not committed, and installs a PostToolUse hook that auto-refreshes the graphs on source edits. Use when the user runs /claude-dependency-mapper or asks to set up / refresh the project dependency graph.From its SKILL.md
npx -y skills add Bakoware/claude-dependency-mapper --skill claude-dependency-mapperAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.9 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
claude-dependency-mapper
Standardizes dependency-graph generation across all of the user's projects with a single self-contained Node script. Produces two artifacts from the same analysis:
- Human graph — an Obsidian vault in
obsidian-graph/(one note per file with[[wikilinks]]). Open the folder as a vault → Graph View (Ctrl/Cmd+G). - AI graph — a compact single-file
PROJECT_MAP.md(adjacency list), generated only for larger projects where a precomputed index saves more tokens than it costs to keep fresh.
Route decision (by code-file count)
- < 40 code files → "directed": small enough that Grep/Glob exploration is cheap;
no
PROJECT_MAP.mdis maintained (a stale map would waste more tokens than it saves). CLAUDE.md tells future sessions to navigate by directed search. - >= 40 code files → "compact": a precomputed
PROJECT_MAP.mdis generated and CLAUDE.md instructs future sessions to read it first before fanning out.
The Obsidian human vault is generated in both cases.
Procedure
-
Confirm Node.js is available (
node --version). The script (Node, zero-dependency) parses imports for several languages — detected automatically by file extension:- JavaScript/TypeScript (
.ts .tsx .js .jsx .mjs .cjs .mts .cts .vue .svelte .astro) - Python (
.py .pyi) - Rust (
.rs) - Dart (
.dart)
Resolution is best-effort and regex-based (no compiler/LSP), so it's great for visualization but not a perfectly accurate graph — see Notes/limitations. If the project is in another language, tell the user it isn't parsed yet (adding one means adding an entry to the
LANGSregistry ingen-graph.mjs). - JavaScript/TypeScript (
-
Run the generator against the current project (it does everything and is idempotent):
node "<SKILL_DIR>/gen-graph.mjs"where
<SKILL_DIR>is this skill's directory. The script:- finds the source base (
src/if present, else the project root, excludingnode_modules, build dirs,.git, etc.), - generates
obsidian-graph/, - decides the route and, if "compact", writes
PROJECT_MAP.md, - inserts/refreshes a managed block in
.gitignore(ignoringobsidian-graph/andPROJECT_MAP.md), - inserts/refreshes a managed block in
CLAUDE.mdwith the route-specific guidance, - installs/refreshes a
PostToolUsehook in<project>/.claude/settings.json(matcherEdit|Write|MultiEdit) that re-runs the generator in--hookmode, - prints a final
RESULT: files=<n> route=<directed|compact> ...line.
Optional args: pass a project path as
argv[2]; override the threshold with--threshold=N; force a route with--route=directed|compact. - finds the source base (
-
Read the script's
RESULT:line and report to the user: file count, chosen route, what was created, and how to open the Obsidian vault. -
Tell the user the graphs now auto-refresh: the installed hook re-runs the generator whenever a source code file under the source base is edited. The hook runs quietly, only regenerates the graphs (it does not touch
.gitignore/CLAUDE.md/the hook), is gated to source files (other edits are ignored, no loop onobsidian-graph/), and never fails an edit. Re-run/claude-dependency-mappermanually only to re-apply config or change the threshold/route.
Auto-refresh hook
installHook() writes a project-scoped PostToolUse hook to
<project>/.claude/settings.json:
{ "hooks": { "PostToolUse": [
{ "matcher": "Edit|Write|MultiEdit",
"hooks": [ { "type": "command", "command": "node \"<skill>/gen-graph.mjs\" --hook" } ] } ] } }
In --hook mode the script reads the PostToolUse JSON from stdin, extracts
tool_input.file_path, and exits 0 immediately unless that file is a code file under the
source base (so non-source edits and writes inside obsidian-graph/ are no-ops). It then
regenerates the graphs with --quiet --no-config semantics, wrapped in try/catch so a
failure can never disrupt editing. Re-installing is idempotent (prior claude-dependency-mapper
hook entries are removed first), and other existing hooks in settings.json are preserved.
Notes / limitations
- The whole project tree is scanned (minus
node_modules, build dirs,.git, virtual envs,target, etc.); note ids are paths relative to the project root. - Resolution is regex-based and best-effort per language:
- JS/TS: relative paths +
@/→ source-base alias. Other tsconfigpathsaliases and dynamically string-built imports are not resolved. - Python: relative (
from . / .. import) and absolute (import a.b.c,from a.b import x) resolved against the project root andsrc/. Star/asignored; third-party/stdlib modules appear as external nodes. - Rust:
mod name;declarations give accurate file edges;use crate::/self::/super::are resolved best-effort to files (the trailing item name is dropped), otherusepaths are treated as external crates. Groupeduse a::{b, c}edges are not expanded. - Dart: relative imports and
package:<self>/…(resolved viapubspec.yamlname) become edges;dart:and otherpackage:imports are external.
- JS/TS: relative paths +
- Imports that don't resolve to a file in the project are listed under "Unresolved" in the Obsidian note (kept out of the graph edges).
- Both graphs are gitignored by design. If the user later wants
PROJECT_MAP.mdshared with a team, remove it from the managed.gitignoreblock.
What ships with it: 13 files
396.6 KB alongside SKILL.md, 4 of them executable
benchmark/
- assets/fig_cost_monthly_bi.png68.6 KB
- assets/fig_cost_monthly_usd.png47.4 KB
- assets/fig_cost_scaling_bi.png55.9 KB
- assets/fig_cost_scaling_usd.png39.2 KB
- assets/fig_roundtrips.png47.1 KB
- assets/fig_tokens_absolute.png45.0 KB
- assets/fig_token_savings.png48.9 KB
- benchmark.pyruns5.1 KB
- make_charts.pyruns7.9 KB
- README.md8.5 KB
- results.json971 B
- scaffold.pyruns2.6 KB
- gen-graph.mjsruns19.4 KB