Skip to main content

Introducing Tolmap, a Code Map for Your Repository

· 12 min read
Marvin Zhang
Software Engineer & Open Source Enthusiast

Tolmap is a code map you can open in your browser. It groups related files into named districts, draws the dependencies between them, and lets you zoom all the way into the source. Open it when you inherit a repository, review a change outside the area you know, or want to see what else depends on the file you’re about to edit. When you hand the work to a coding agent, it can query the same map from the command line.

Why I built it​

A coding agent can take a task from issue to pull request while you have two or three files open. The next day, a teammate asks whether a change to one of those files affects the public API. You remember the edit. To answer the question, you still have to work out where that file sits and who imports it.

The name comes from Edward Tolman’s 1948 paper on cognitive maps. He distinguished a strip map, which gets you from a familiar starting point to a familiar goal, from a comprehensive cognitive map, which lets you find another route when your starting point or destination changes. The two or three files you touched give you a strip map of your last task. As agents write more of the repository, you spend less time building up the broader map by working through it yourself. Cognitive Maps in Rats and Men

The rats learned a winding route to the food in training. In the test, the route was blocked, and the path the rats chose most often pointed toward where the food had been, suggesting they had learned the layout. When code moves, agents that only remember steps can get stuck, and Tolmap’s map shows them where to look.

Training: rats follow a winding route from the start to the food. Test: the old route is blocked. Of 18 new straight paths, the one the rats choose most often points toward the former food location.

Original schematic based on Edward C. Tolman’s “Cognitive Maps in Rats and Men,” Psychological Review (1948), which reports the experiment by Tolman, Ritchie & Kalish (1946).

Google engineers use their internal Code Search tool as a code map. They browse code, follow cross-references, and jump to definitions. Tolmap gives you a spatial overview you can hold in your head as you move between files. “Code Search,” Software Engineering at Google, Chapter 17. I wrote earlier about reading source code to understand an unfamiliar project.

When producing a change takes less time, the people reviewing it still have to learn the code around it. That’s the cost I wrote about in July. Cheap Code, Scarce Attention

Walk through Vite​

Vite’s nine districts and six roads. Selecting module-runner & vite opens its 25-file card, then Zoom to district reveals file parcels including runner.ts and moduleRunnerTransport.ts.

VS Code’s folder tree shows where files live. Tolmap groups 25 connected files from four folders into one district and zooms straight from the whole repository to individual file parcels.

Suppose you’re reviewing a change to Vite’s module runner. Open module-runner & vite in the district index and check its neighbors. Click Zoom to district to see runner.ts, moduleRunnerTransport.ts, and the other files in that group. The map uses weighted Voronoi polygons for file parcels and labels them as you zoom in. These examples use tolmap@0.2.3 and a shallow checkout of Vite v7.3.0 at acf7e05. Vite source at that commit

Trace a dependency cycle between districts​

In Lenses → Saved lens → Debt, click Show on map for the first finding to follow the roads between plugins & vite and create-vite & playground. Only Computed · imports establishes an import link, and Declared — no edge claimed marks where that chain stops. Treat the red suggested cut as a heuristic to investigate in the source.

The Debt lens highlights the cycle between plugins & vite and create-vite & playground, with computed imports, declared stops, and a red suggested cut.

An editor’s file references show individual links. The Debt lens puts the roads that close a district cycle on one map.

Compare folders and packages against dependency districts​

Switch the index to Folders. It lists 151 files in packages/ and 116 in playground/, while the map keeps its dependency districts. Switch to the Package layer to color the same 272 files by package group. The layer shows four groups and reports five dependency districts that span packages.

The Folders index lists packages/ and playground/ beside the district map, then the Package layer colors the map by package and reports four groups and five mixed districts.

An editor shows the folder tree. Tolmap lets you compare that tree and package boundaries with groups formed by imports.

What you can do in Tolmap web​

District overview and dependency roads​

See Vite’s nine districts and the six roads connecting them across 272 mapped files, a repository-wide view beyond an editor’s file tree.

Vite’s district map with nine named districts, six dependency roads, and a sidebar showing 272 files and eight files without detected links.

District details and semantic zoom​

Open a district to see its folders and nearby districts, then zoom in to see the individual file parcels.

Zoomed-in parcels in module-runner & vite beside its district detail card.

Debt lens for district cycles​

Trace the roads that close a cycle, or inspect the lens’s god-file, hotspot, and no-inbound-edge findings from the mapped data.

Highlighted district-cycle roads beside the Debt lens evidence labels and the red heuristic suggested cut.

Complexity layer​

Compare the complexity scores across the map. vite & server ranks first by district median at 39.5, and css.ts leads the file ranking at 503.

Complexity layer showing vite & server first by district median at 39.5 and css.ts first among files at 503.

Folders index and Package layer​

Compare the folder tree and four package groups with the dependency districts, five of which span packages.

Package map showing four package groups across 272 files and five districts that mix packages.

See the 14 outgoing imports and eight incoming importers detected directly from source for runner.ts, plus eight files without detected links in the overview.

The selected runner.ts parcel with solid red import arcs, dashed blue importer arcs, and card counts of 14 and eight.

Agents query the same map​

When you give an agent a bounded task, you still have to check its result. Starting from the same map gives you something concrete to compare with the files the agent picked. For a change to the module runner, for example, I’d ask it to look at the direct importers before it proposes a patch. Introducing Agent Workbench

Selecting runner.ts on the zoomed Vite map highlights its 14 direct imports in solid red and its eight direct importers in dashed blue, reaching into vite & server and vite & node.

VS Code can list references to a file. The map puts all 22 direct static links from the command output below in district context.

From the registered Vite checkout at acf7e05, I ran tolmap deps packages/vite/src/module-runner/runner.ts --format text with tolmap@0.2.3. Here is the full standard output.

repository: 22 of 22 results
tolmap.query/v3 commit=acf7e05eaeb18e98f5e19e2d3e648950726f20d1 sha256=45d08130e8835013c798e747394cd7dc96bd4f1b98f94642378f6c494ca84746 limit=25
query={"kind":"deps","path":"packages/vite/src/module-runner/runner.ts","direction":"both","directions":{"in":{"total":8,"returned":8,"omitted":0},"out":{"total":14,"returned":14,"omitted":0}}} coverage={"refs":"hand","zero_edge_files":8,"calls_total":null,"calls_resolved":null,"unresolved":null,"lower_bound":true}
out packages/vite/src/module-runner/constants.ts [module-runner & vite]
out packages/vite/src/module-runner/createImportMeta.ts [module-runner & vite]
out packages/vite/src/module-runner/esmEvaluator.ts [module-runner & vite]
out packages/vite/src/module-runner/evaluatedModules.ts [module-runner & vite]
in packages/vite/src/module-runner/hmrHandler.ts [module-runner & vite]
out packages/vite/src/module-runner/hmrHandler.ts [module-runner & vite]
out packages/vite/src/module-runner/hmrLogger.ts [module-runner & vite]
in packages/vite/src/module-runner/index.ts [module-runner & vite]
in packages/vite/src/module-runner/sourcemap/index.ts [module-runner & vite]
out packages/vite/src/module-runner/sourcemap/index.ts [module-runner & vite]
in packages/vite/src/module-runner/sourcemap/interceptor.ts [module-runner & vite]
out packages/vite/src/module-runner/types.ts [module-runner & vite]
out packages/vite/src/module-runner/utils.ts [module-runner & vite]
in packages/vite/src/node/server/environments/runnableEnvironment.ts [module-runner & vite]
in packages/vite/src/node/server/index.ts [vite & node]
in packages/vite/src/node/ssr/runtime/serverModuleRunner.ts [module-runner & vite]
in packages/vite/src/node/ssr/ssrModuleLoader.ts [vite & node]
out packages/vite/src/shared/builtin.ts [module-runner & vite]
out packages/vite/src/shared/hmr.ts [module-runner & vite]
out packages/vite/src/shared/moduleRunnerTransport.ts [module-runner & vite]
out packages/vite/src/shared/ssrTransform.ts [module-runner & vite]
out packages/vite/src/shared/utils.ts [vite & server]
Lower bound over extracted imports; unresolved counts are unknown unless symbols were loaded.

The 14 outbound imports and eight inbound importers match the links in the viewer. The command uses the latest saved map by default. Pass its snapshot ID with --snapshot to query a specific map.

overview lists districts, where locates a file or symbol, deps lists direct imports and importers, and route finds a path along detected file imports. These commands read a saved map and return text or versioned JSON. The JSON includes the map hash, the commit when available, and the number of rows omitted. Tolmap v0.2.3 query reference

Get started in 30 seconds​

Open a terminal at the root of a Git checkout and run these three commands.

npm install -g tolmap@0.2.3
tolmap add .
tolmap web
Tolmap building a map from the Vite checkout and listing the generated vite.json file.

To export a standalone map, use tolmap build. Here tolmap@0.2.3 writes vite.json for Vite at acf7e05.

Open http://127.0.0.1:8787/. The viewer listens on loopback only and has no authentication. The local library indexes committed files. You can also run commands through npx tolmap without installing globally. Use npx tolmap@0.2.3 to pin this release. The CLI supports Python, Go, TypeScript, and Rust via --lang py|go|ts|rs.

The 0.2.3 package on npm supports Linux x64 with glibc 2.35 or newer, Node.js 22.14.0 or newer, and git on your PATH. Minimal images also need libstdc++6 and libgcc-s1. You can use it without a Rust or C++ toolchain. macOS, Windows, Linux arm64, and Alpine/musl are outside the current npm package’s platform support. The repository documents Docker and the Python source pipeline as alternatives. Tolmap README · npm distribution docs

Tolmap’s original source is MIT-licensed. The npm binary distribution is conveyed under GPL-3.0-or-later because it bundles libleidenalg and igraph. The corresponding source is attached to GitHub Releases v0.2.3. Awesome Tree-sitter added Tolmap under Tools → Analysis / navigation on November 29, 2026. Awesome Tree-sitter PR #12

Try it on a repository you know well. Pick a file you often review and check who imports it. If a connection you expected is missing, a small public example with the language and commit will help me track it down. Tolmap on GitHub