Skip to content
← back to writing
7 min read

I deleted the LLM from my codebase analysis tool

Brownfield Cartographer started as four LLM agents that wrote onboarding docs. It became a deterministic lineage engine that answers "what breaks if I change this?" across Python, SQL, dbt, and Airflow, with file-and-line evidence or an honest "unresolved".

#data-engineering#dbt#python#mcp#developer-tools

You’re about to rename a column in a staging model. What breaks?

Your language server can tell you who calls a Python function. Grep can find the string. Neither can tell you that a Python job writes the orders table with a raw SQL string, a SQL file transforms it, a dbt model reads the result through ref(), and an Airflow task three files away runs that model every night. The dependency crosses four languages, and in most of those hops it’s just a name inside a string.

That’s the question Brownfield Cartographer answers:

cartographer impact models/staging/stg_orders.sql    # what is downstream of this file?
cartographer lineage customers --direction upstream  # where does this table come from?
cartographer lineage customers::first_order          # which source columns feed this column?

It didn’t start out that way.

Version one had four agents#

The first Cartographer was a one-week 10 Academy brief, and it was very much an agent system. A Surveyor mapped modules with tree-sitter. A Hydrologist traced data flow. A Semanticist used an LLM to write purpose statements for each module. An Archivist re-ran everything on push. Out came a CODEBASE.md, a day-one onboarding brief, a documentation-drift report, and a LangGraph chat agent you could ask questions.

It produced good-looking documents. The trouble is that “good-looking” is the wrong bar for the question I cared about. If a tool tells you a change is safe and it’s wrong, you find out in production. An impact answer has to be something you can check, and an LLM-written summary of what a module “is for” is not something you can check against the code.

So in 0.5.0, I removed all of it.

Removed in 0.5.0
  1. LLM purpose statements per module
  2. Documentation-drift detection
  3. Domain clustering and day-one answers
  4. The LangGraph chat agent and the llm extra
What replaced it
  1. Static, offline analysis, no API key
  2. Every result carries file and line evidence
  3. Coverage reported on every answer
  4. Unsupported cases reported, never guessed

The changelog entry is blunt about it: “Focuses the project on dependencies that cross language boundaries… and removes all model-based code.” The CODEBASE.md and onboarding brief survived, but they’re now generated from the static index, not written by a model.

How it works now#

Pipeline

1
Scanner
Bounded, ignore-aware
↓
2
Analyzers
Python, SQL, dbt, Airflow, JS/TS
↓
3
Versioned index
Spans, coverage, diagnostics
↓
4
Query engine
Impact, lineage, deps
↓
5
CLI · API · MCP
Same answers everywhere

The scanner walks the repository once for every analyzer. It respects nested .gitignore and .cartographerignore files, prunes build and environment directories, rejects symlinks and junctions, and caps file size, total bytes, file count, and depth. It never executes repository code. A tool you point at an unfamiliar codebase shouldn’t run that codebase.

The analyzers each handle one kind of input, and they all write into one versioned index.json with source spans, coverage, and diagnostics. The query engine reads that index, and the CLI, the Python API, and the MCP server all use the same engine. They can’t disagree with each other, because there’s only one implementation.

Here’s what it looks like on dbt’s public jaffle_shop example. The whole analysis took about three seconds:

terminal
$ uvx --from brownfield-cartographer cartographer impact models/staging/stg_payments.sqlanalyze_impact | complete | snapshot eefa28cd4e13┌───────────────┬──────────────┬──────────────────────────────────────┐│ Symbol / node │ Relationship │ Evidence                             │├───────────────┼──────────────┼──────────────────────────────────────┤│ stg_payments  │ PRODUCES     │ models/staging/stg_payments.sql:1-26 ││ orders        │ PRODUCES     │ models/orders.sql:1-57               ││ customers     │ PRODUCES     │ models/customers.sql:1-70            │└───────────────┴──────────────┴──────────────────────────────────────┘

Every row has a file and a line range. If you don’t believe the answer, you can go look.

“Unresolved” is a valid answer#

The rule that shapes everything else: when Cartographer can’t determine something statically, it says so. It doesn’t guess, and a guess never shows up looking like a fact.

That plays out differently for each input:

  • SQL embedded in Python. SQL passed to execute, read_sql, Spark’s .sql(), and similar calls is parsed when it can be resolved from literals or string constants, including constants imported from another module. An f-string that only interpolates values (WHERE id = {order_id}) is resolved. One that interpolates a table name is reported as dynamic SQL.
  • SQL dialects. Each file is parsed with whichever dialect (DuckDB, BigQuery, Snowflake, Postgres, MySQL, Spark, T-SQL, Trino) yields the fewest invalid statements, and the dialect is recorded in the evidence as sql:<dialect>. You can see exactly which grammar produced a result, and pin one with --dialect.
  • dbt Jinja. Models whose Jinja is ref, source, config, literal set lists with for loops over them, and the project’s own macros with literal arguments are rendered. Anything beyond that, like package macros, is counted as unresolved.
  • Airflow. Tasks created in loops or with computed IDs are reported, not invented.

Column lineage#

Table-level lineage tells you customers depends on stg_orders. Column-level lineage tells you which column, and how. Every column edge is marked either copy, meaning the value passes through unchanged, possibly renamed, or derived, meaning the source column influences the value. That includes influence through CASE conditions, window PARTITION BY and ORDER BY keys, and aggregates.

The hardest cases are SELECT * and unqualified columns in joins, because the SQL alone doesn’t say where a column came from. Version 0.10.0 resolves them using the columns each table is known to have: from CREATE TABLE definitions, from fully resolved models, and optionally from a dbt catalog.json. A column that could have come from more than one source stays unresolved.

On real projects, that release added 18 column edges on dbt’s jaffle-shop and 77 on Cal-ITP’s data-infra warehouse. Of those 77, 25 were sampled and checked against the SQL, and none were wrong. No column that traced before the change was lost.

A benchmark that fails on false positives#

The accuracy benchmark is a small set of pinned corpora (jaffle_shop at a fixed commit, plus fixtures written to exercise Airflow, JS/TS imports, embedded SQL, Python imports, and warehouse SQL) with expected results written by reading the source, not by copying the analyzer’s output. It runs in CI, and --check fails on any false positive, any miss that isn’t listed as a known gap, and any known gap that’s suddenly found.

CorpusFactsExpectedPrecisionRecall
jaffle_shop_classiccolumns311.001.00
jaffle_shop_classiclineage81.001.00
airflow_dagstasks91.001.00
sql_warehousecolumns101.001.00
python_importscalls71.001.00
js_ts_appimports101.001.00

Built for agents to call#

The MCP server is read-only and exposes six tools: get_architecture, find_symbol, trace_dependencies, analyze_impact, trace_data_lineage, and get_code_context. Every response includes a snapshot ID, a status, and coverage, so an assistant can tell a complete answer from a partial one.

I tested it the way it would actually be used: in live Claude Code sessions. That turned up problems no unit test would have:

  • After an MCP SDK upgrade, tool errors were reaching the assistant only as “Error executing tool”. It couldn’t see why a call failed, so it couldn’t fix its own call. 0.7.0 restored the real reason, like Target not found or a hint about an ambiguous name.
  • A session asked about an Airflow task, trace_dependencies didn’t accept task IDs yet, and the assistant fell back to reading DAG code and missed a downstream task. 0.7.0 made the tool follow task order, and updated the tool descriptions, because the session hadn’t discovered column lineage either.
  • In 0.8.0, the server starts even before a repository is analyzed and tells the assistant the exact cartographer analyze command to run. In a live session, the assistant ran it without being asked and retried.

It’s listed in the official MCP Registry as io.github.Sanoy24/brownfield-cartographer, and the repo doubles as a Claude Code plugin marketplace.

Impact on every pull request#

The newest piece puts all of this into code review. cartographer diff --base main maps a branch’s changed lines to functions, SQL statements, dbt models, schema YAML, and Airflow tasks, then lists everything downstream with evidence. The merge base is analyzed too, so removed code counts: deleting a function reports the callers that still use it.

on: pull_request
permissions:
  contents: read
  pull-requests: write
jobs:
  impact:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0   # the merge base must be available
      - uses: Sanoy24/the-brownfield-cartographer@v0.10.0

The action keeps one comment up to date on the PR and writes the same report to the job summary, which still works for pull requests from forks.

PyPI releases, Oct 12 to Nov 4
0.3 → 0.10
SQL dialects, picked per file
8
read-only MCP tools
6
lines of repository code executed
0

Try it#

With uv installed, nothing needs to be installed permanently:

git clone --depth 1 https://github.com/dbt-labs/jaffle_shop && cd jaffle_shop
uvx --from brownfield-cartographer cartographer analyze .
uvx --from brownfield-cartographer cartographer lineage customers::number_of_orders

The lesson I took from this project is narrower than “LLMs are bad at code analysis.” They’re good at plenty of it. But for a question whose wrong answer costs you an incident, I want an answer I can verify, and a tool that’s honest about where its answers stop.

2026·shipped

Brownfield Cartographer: What Breaks If I Change This?

A local-first repository analysis engine that maps code structure, dependency impact, and data lineage across Python, SQL, dbt, and Airflow, with file-and-line evidence for every result.

Started as a 10 Academy TRP brief

On PyPI, deterministic, runs offline with no API key

PythonSQLdbtAirflowMCP