Skip to content

Creating Code Maps

Nick Kwiatkowski edited this page Nov 25, 2026 · 1 revision

Creating Code Maps

clif graph builds a map of a whole project: every function and file, and the calls, instantiations, inheritance and includes between them. On an 11,700-file workspace that is around 60,000 nodes and 105,000 edges in roughly ten seconds.

Every declared function is in the map, whether or not anything calls it. Code nothing reaches is not dropped: it becomes its own island, with its own root, which the HTML report draws as a separate tree and --detached lists on its own.

clif graph [options] <dir> [...]

Quick examples

clif graph .                                       # summary to the terminal
clif graph --format html --out map.html .          # interactive report
clif graph --level package --format dot . | dot -Tsvg > map.svg
clif graph --db .clif/codemap.db .                 # save to SQLite, and cache
clif graph --under packages/shop --format html --out shop.html .
clif graph --entry '../prs' --entry 'tasks/*' .    # code a runner invokes by name

Options

Option Default Description
--format <f> text text, json, jsonl, dot, mermaid, html
--level <l> function function, call, file, package (see Levels)
--out <file> stdout Write here instead of stdout
--db <file> — Save the map to a SQLite database, and reuse its per-file cache so unchanged files are not parsed again
--no-cache — With --db, rebuild every file
--from <id> — Keep only what these node ids reach (repeatable)
--live — Keep only what an entry point reaches
--detached — Keep only what no entry point reaches
--under <path> — Scope to a path prefix, keeping the nodes just outside it that an edge crosses into (marked as boundary nodes)
--under-strict — With --under, cut hard at the prefix instead
--unresolved — Include calls that resolved to nothing
--builtins — Include calls to built-in CFML functions
--no-infer-args — Do not type untyped arguments from their callers
--entry <glob> — Also treat matching files as entry points (repeatable). A bare directory name matches everything beneath it. Private methods are never marked
--utility <glob> — Mark files as infrastructure rather than application code (repeatable)
--hide-utility — Open the HTML report with utility code switched off (the toggle remains)
--one-config — Read every file under the scan root's .clif.json instead of each file's nearest one
--workers <n> GOMAXPROCS Scan parallelism
--limit <n> 20 List length in the text report
--quiet — No progress on stderr

--entry and --utility add to the codemap block of .clif.json rather than replacing it.

Levels

--level Nodes Use it for
function (default) Functions and files Everything; files carry the relationships functions cannot (extends, includes, new Foo())
call Functions, plus pages whose top-level code calls something A strict call graph: shortest paths, real cycles, functions nobody invokes
file One per file Module-scale dependency structure
package One per directory The level that renders as a picture of a large project

Calls from top-level .cfm page code are attributed to the file node, and they count: on a real workspace, file-level callers accounted for 74,226 of 107,683 call sites.

Formats

Format Description
text Summary: counts, top fan-in, islands (--limit entries per list)
json The canonical artifact; everything else is a view of it
jsonl One node or edge per line, for streaming tools
dot Graphviz. Pipe to dot -Tsvg
mermaid Mermaid diagram. Capped on purpose; collapse to --level package first for big maps
html A single self-contained file (embedded 76 KB D3 bundle, no CDN, works offline)

The HTML report has six views:

View What it shows
Edge bundling Hierarchical bundling, grouped by island, then directory
Force Force layout giving each island its own centre; canvas rendering above ~1,200 nodes
Dependency matrix No occlusion at any size
Islands The disconnected pieces
Drill-down Starts at top-level directories and expands one level per click; not capped
Focus One node and everything within n hops, a ring per hop; click to re-centre; not capped

The codemap block in .clif.json

"codemap": {
  "entry":   ["../prs", "tasks/*"],                  // files a runner invokes by constructed name
  "utility": ["packages/tass/core/context.cfc"],    // infrastructure
  "hideUtility": true                                // HTML report opens with utility hidden
}
Key Type Description
entry string[] Globs of files treated as entry points (release scripts, scheduled tasks, plugins)
utility string[] Globs of infrastructure files. Marked, never excluded: counts and rankings still include them
hideUtility boolean Start the HTML report with utility code toggled off

A package is treated as utility when collapsing only if all of it is.

The SQLite database

--db <file> writes the map to SQLite and reuses a per-file cache next time. The cache is keyed on each file's content hash and a fingerprint of every indexed component, so editing any .cfc triggers a full rebuild while editing .cfm pages does not (roughly 15 s cold vs 7 s warm on a large workspace).

The schema is a supported interface:

-- what the most code depends on
SELECT id, in_degree FROM nodes ORDER BY in_degree DESC LIMIT 20;

-- functions nothing reaches, in one package
SELECT id, file, line FROM nodes
WHERE kind = 'function' AND reachable = 0 AND file LIKE 'packages/tass/%';

-- the most-depended-on application code, infrastructure set aside
SELECT id, in_degree FROM nodes
WHERE kind = 'function' AND utility = 0
ORDER BY in_degree DESC LIMIT 20;

-- choosing utility files: high fan-in per function means infrastructure
SELECT file, SUM(in_degree) AS fan_in, COUNT(*) AS fns,
       CAST(SUM(in_degree) AS REAL) / COUNT(*) AS per_fn, MAX(utility)
FROM nodes WHERE kind = 'function' GROUP BY file ORDER BY per_fn DESC;

Node ids: a function is "<file>::<lowercased name>" (for example packages/tass/core/user.cfc::checkpermslist); a file is its path relative to the map root.

The same database feeds the MCP server: clif mcp --db .clif/codemap.db.

Per-application configs

A workspace is often several applications side by side, each with its own .clif.json. By default each file is resolved under its own nearest config, because applying one application's componentResolvers to another's source silently resolves nothing. --one-config restores single-config behaviour.

From the editor

The clif.generateCodeMap command builds a report from the running server's index (no CLI needed), and clif.showCodeMapStats reports how much of the workspace the map resolves.


Framework routes

Convention-based routing is invisible to static analysis: a dispatcher builds a component path and method from a dotted route in a URL or attribute, so every routed controller method looks uncalled. The routes block in .clif.json describes the convention (see Other Options); with it, the LSP adds route edges to the code map, go-to-definition from a route to its controller method or view, and a document link on each resolvable route.

clif routes

clif routes [options] <dir> [...]

Reports the routes found and what they resolve to, so the routes config can be checked against the code.

Option Default Description
--format <f> text text, md, json
--out <file> stdout Write here instead of stdout
--unresolved — List only routes that resolved to nothing
--json — Shorthand for --format json
--limit <n> 5 Routes listed per group; 0 for all
--quiet — No progress on stderr
clif routes --unresolved .                         # to the terminal
clif routes --format md --out routes.md .          # a report to keep
clif routes --format json . | jq                   # for a script

Each JSON finding:

Field Description
route The route string, e.g. admin.users.edit
source Where it was found: attribute (data-view="a.b.c"), query (href="x.cfm?do=a.b.c"), property ({ view: "a.b.c" }) or function (redirect("a.b.c"))
name The attribute, parameter, property or function name that held it
file, line Location
targets Resolved controller methods and view files (empty when unresolved)

The markdown report groups unresolved routes by shape (shared prefixes, dialog/popup segments, action verbs), because a whole group is usually one missing rule rather than many problems, and it distinguishes prefixes whose controller is found but whose method is not.

← Running the CLIF command-line tool · Home

Clone this wiki locally