Skip to content
Back to skills

Codebase Map

ASecurity

Use to see or explain any repository's structure — code (folders → files → functions, imports and name references, cycles, hubs, complexity hotspots, test reach) and, where the repo holds a Claude Code setup, its agent workflow (stages → agents/skills → hooks → scripts) — or to size a change's surface before planning it. Generates .gate/graph.json and a drill-down .gate/graph.html from git, on demand. Also /codebase-map. Read-only; architecture-review and blast-radius call it.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
developmentpythongojavakotlinshellnodedjangogitfrontendsecurity

Works with

  • claude code

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add restierecon/tbv --skill codebase-map --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Codebase Map?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Codebase Map
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/restierecon-codebase-map/badge)](https://www.skillsdirectory.com/skills/restierecon-codebase-map)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: codebase-map
description: Use to see or explain any repository's structure — code (folders → files → functions, imports and name references, cycles, hubs, complexity hotspots, test reach) and, where the repo holds a Claude Code setup, its agent workflow (stages → agents/skills → hooks → scripts) — or to size a change's surface before planning it. Generates .gate/graph.json and a drill-down .gate/graph.html from git, on demand. Also /codebase-map. Read-only; architecture-review and blast-radius call it.
---

# Codebase map

The map is regenerated from git each time it's needed and never committed, so it can't
go stale. Nothing has to keep it in sync. It reads committed trees only, so commit
before you build.

## Commands (run from anywhere in the repo; Python 3, lizard for complexity)
- `python3 ~/.tbv/scripts/codebase-graph.py build [--coverage <report>] [--rules tbv/architecture.json] [--days 90]`
  writes `.gate/graph.json` and `.gate/graph.html` for HEAD (`--rev` for another
  revision) and prints a summary of at most 20 lines: GRAPH totals, a SEEN line
  saying how much of the repo it analysed and how, the flagged folders and files,
  and one SETUP line per Claude Code setup it found. It exits 1 when a setup's
  workflow.json has errors; the map is still written.
- `python3 ~/.tbv/scripts/codebase-graph.py impact (--base main | <files>…)` prints a
  CHANGE IMPACT block: direct and indirect dependents, modules reached, tests in reach,
  docs that mention the change, setup components it touches, cycles, and an estimated
  regression risk.
- `python3 ~/.tbv/scripts/codebase-graph.py check --rules <file> --base main` reports
  the architecture violations HEAD adds over the base. gate.sh's `arch` step runs it.
- `python3 ~/.tbv/scripts/codebase-graph.py features [--base main]` checks
  `FEATURES.md` (Feature map below). gate.sh's `features` step runs it.

## What it reads (any repo)
- **Every tracked text file is a node.** These are skipped and counted:
  - vendored folders (`node_modules`, `vendor`, `.venv`, …), binary files and files
    over 1 MB
  - build output (`dist`, `build`, `target`, `out`, `coverage`), at the top level or
    beside a package manifest. A source package named `build/` elsewhere stays.
- **Paths you pass** (`--coverage`, `--rules`, `--out`, impact files) are relative to
  where you run the command. The default `--out` is the repo's `.gate/`.
- **Links:**
  - `import`: parsed, for Python, JS/TS (relative paths), Go and Java/Kotlin.
  - `reference`: a script, config or CI file naming another file's path, or a unique
    file name (`source ./lib/x.sh`, `"$(dirname "$0")/gate.sh"`, `run: bin/deploy.sh`).
  - `mention`: a doc, or a string inside parsed code, naming a file. It shows in the
    map but is never a dependency.
- **Complexity:**
  - measured: lizard's languages.
  - estimated: shell, counting branches per function plus the script body.
  - not measured: other code, e.g. PowerShell or Makefiles.
  - n/a / other: docs, data and unknown text.
- **The SEEN line** gives these shares. A WARNING appears when more than 30% of the
  code has no complexity measure, so a blind map says so instead of looking clean.
- **Flags, each with a `why`:**
  - `cycle`: import cycles are high risk; cycles that go through name references are
    medium, since they may just be message strings.
  - `violation`: breaks a rule in architecture.json.
  - `hub`: 5 or more non-test modules depend on it.
  - `hotspot`: complexity ≥ 10 and changed 3 or more times.
  - `complex`: complexity ≥ 15.
  - `untested`: no test imports it, names it or reaches it, or coverage is under 50%.

## Facts (any repo, each with evidence)
`graph.json` → `facts`, shown on the code lens root and as one FACTS summary line:
- **Stack:** languages by production lines, dependency manifests at any depth (test
  fixtures excluded), and monorepo signals (workspaces, pnpm/lerna/nx/turbo/rush,
  repeated manifests).
- **Dependencies:** per manifest, split runtime / dev / optional / peer / indirect.
  Parsed for package.json, pyproject.toml (PEP 621, dependency groups, Poetry),
  requirements*.txt (a dev, test or lint name means dev), go.mod, Cargo.toml, Gemfile
  groups and composer.json. Other manifests are listed only.
- **Entry points:** what manifests declare (main, bin, scripts.start,
  [project.scripts]), conventional files (`__main__.py`, `main.go` with
  `package main`, root install/run scripts, Makefile), and container CMD/ENTRYPOINT.
- **Configuration:** variables in env templates, and variables production code reads
  (docstrings and tests excluded). A variable read but missing from the template is
  an `[ASK USER]`.
- **Delivery and tooling:** CI systems, containers and orchestration, security and
  ownership config, lint, format and type configs.
- **Intent vs reality:** the intent docs to read first (README, specs, ADRs). A path a
  doc names that exists nowhere in the repo is an `[ASK USER]`; fenced examples and
  paths relative to the doc are skipped.
- **Concerns:** TODO/FIXME/HACK/XXX markers in comments, counted separately for
  production and tests (test markers are coverage gaps, not debt), and the
  most-changed files.

Anything it can't establish is a `[TODO]`, never a guess. These facts feed
/init-codebase's onboarding brief.

## Workflow lens (a repo holding a Claude Code setup)
- **Detection:** a root with `agents/*.md`, `skills/*/SKILL.md`, `commands/*.md` or
  hooks in `settings.json`. Both a repo root (an assembled tbv install is one) and a project's
  `.claude/` count.
- **Components:**
  - agents (with model and tools from frontmatter), skills (with their files),
    commands, and the protocol (CLAUDE.md/AGENTS.md)
  - hooks: settings.json event → matcher → the script it runs
  - scripts: file nodes from the code lens, so you can drill down to their functions
- **Links between components** come from paths and names in their files: `skills/x`,
  `/x`, "x skill", backticked agent names, "x agent", table rows, and bare hyphenated
  names. Each link carries its file:line evidence.
- **`workflow.json`** at the setup root declares the stage order:
  ```json
  {"name": "…", "description": "…",
   "stages": [{"id": "review", "label": "Review", "description": "…", "when": "…",
               "uses": ["agent:reviewer", "skill:blast-radius", "script:gate.sh"],
               "next": ["audit", {"to": "build", "label": "REJECTED"}]}],
   "on_demand": ["skill:frontend-ui-engineering"]}
  ```
  Refs are `agent:` / `skill:` / `command:` / `script:<path or unique name>` /
  `hook:<Event>` / `protocol:`.
- **Verification:**
  - Errors: a ref that doesn't exist, a `next` that isn't a stage, or an agent, skill
    or command that no stage, hook, protocol file or on_demand entry reaches (directly
    or through other components).
  - Warning: an unreached script.
- **Without workflow.json** the lens groups components by kind.

## Limits (say them when you report)
- Name references find literal paths and names, not string-built ones. Dynamic
  imports, path aliases (`@/…`), DI wiring and reflection are invisible.
- Callers are per file, not per function. Before calling a function unused, grep for
  its name.
- Shell complexity is an estimate. Without `--coverage`, "untested" means no test
  reaches the code in a way the map can see.
- Very large repos produce large pages: Django is about 5,600 files and a 24 MB HTML
  file. Use `--out` and open it locally.

## Reading it (signals, not verdicts)
A flag is a reason to look, not a defect. A 40-line function that reads top to bottom
can be fine. A 3-line function that only forwards a call can still be a problem
(apply the deletion test from architecture-review). Read the code behind a flag before
proposing a change. Rank by what hurts change most: import cycles and violations, then
hubs that are hotspots, then the rest.

## Reporting to a human (≤ 15 lines)
Lead with the GRAPH, SEEN, FACTS and SETUP lines (include any WARNING, [ASK USER] or ERROR). Then, for each
high-risk item: name, signals, and the `why` that matters most. Then a link to the
HTML: open it with the Artifact tool or send the file, and never paste its contents.
End with one suggested next step.

## Fitness rules (tbv/architecture.json, set by a human in /grill)
```json
{"no_new_cycles": true,
 "forbid": [{"from": "src/domain/**", "to": "src/infra/**", "why": "ADR-004: domain stays free of I/O"}]}
```
- **Globs:** `**` crosses directories; `*` stays within one.
- **What counts:** `forbid` applies to dependencies (imports, plus references from
  scripts and config). `no_new_cycles` (default true) looks at import cycles only.
- **Where the rules live:** the gate reads them from `main`, so a slice can't loosen
  them on its branch. It compares against the merge-base and fails only on violations
  the diff adds, so legacy ones show in the map as flags instead. With no merge-base
  (a shallow clone), it warns and compares against the base tip.
- **Zone edges:** edges with both ends inside both zones are ignored, so `src/** ↛
  src/legacy/**` and `src/legacy/** ↛ src/**` both work.

## Feature map (FEATURES.md, committed)
The generated map shows structure; `FEATURES.md` says which feature owns it. Read it
before searching for where a behaviour lives.
```markdown
## checkout - Checkout
A shopper pays for their cart and gets an order confirmation.
- code: src/checkout/
- tests: tests/checkout/
- docs: docs/checkout.md
- uses: cart, payments
```
- **Lines:** `code:`, `tests:`, `docs:` take comma-separated paths. A folder ends in
  `/`, `*` stays in one folder, `**` crosses folders, and `README.md#section` points at a
  section. `uses:` names other feature ids.
- **Coverage:** every tracked file outside `tbv/` belongs to at least one feature.
  Repo-wide files go in a `project` entry, and code several features use in `shared`.
- **The check fails** on a heading that isn't `## <lowercase-id> - <Name>`, an unknown
  `- <word>:` line, a duplicate id, an entry with no paths, a path that matches nothing,
  a `uses` naming an unknown feature, and a file the change adds that no feature covers.
  Files older than the change only warn.
- **Keep it true in the same change:** a slice that adds, moves or deletes files edits
  the feature's entry in the same commit.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.