Haldwani Times
Haldwani Times
Technology

slurp-graph 1.5.1

slurp-graph 1.5.1
Photo / Illustration: Haldwani Times Editorial Desk

Skip to main content Switch to mobile version slurp-graph 1.5.1 Token-budget-aware graph navigation for AI coding agents. Serve exactly the noodles your LLM needs.

pip install slurp-graph==1.5.1 Copy PIP instructions

graphify builds the bowl. slurp serves exactly the noodles your LLM needs.

Website: imjuank.dev/slurp-web

A knowledge graph is a bowl of ramen — thousands of nodes tangled together. Your LLM doesn't need the whole bowl. Slurp scores every node against your query, then greedily selects the highest-relevance subgraph that fits within your token budget — and tells you exactly what it picked and why. Works standalone or as a companion to graphify.

slurp counts with tiktoken (cl100k_base), and --budget bounds that count on the final output. Claude does not tokenize like tiktoken: measured in this project with Anthropic's messages.count_tokens, Claude's count on slurp's output was about 1.56× the cl100k_base count. That is one measurement on one kind of text — an estimate, not a guarantee. To budget in estimated Claude tokens, scale every count:

slurp "auth flow" --budget 4000 --token-factor 1.56 # or: export SLURP_TOKEN_FACTOR=1.56 Counts round up, so the output stays at or under the budget in the scaled unit, and the header reports scaled tokens. For the MCP server, set it in .mcp.json: "env": {"SLURP_TOKEN_FACTOR": "1.56"} — it is read on every call. The default is 1.0, which changes nothing.

Measured with slurp benchmark on a real PrismaStats codebase (graphify graph, 2,111 nodes). Both sides are the text that would be sent, counted with tiktoken: the subgraph slurp prints for each query and budget, and the whole graph printed the same way — 117,828 tokens with the query's header and scores.

Mean savings: 96.1% · p50: 96.7% · Best case: 98.3% · Worst case: 93.3%

The output stays under the budget: 1,964–1,968 tokens at 2k, 3,926–3,928 at 4k, 7,841–7,847 at 8k (re-measured for v1.2.0; the savings are unchanged). On the same project's slurp index graph, slurp eval --retrieval finds 96.7% of the labelled nodes of its 15 questions at --budget 4000 (86.7% in v1.1.1).

Before v1.1.0 these figures were not honest. The budget counted a short per-node summary and no relationships, so on this graph --budget 8000 printed 40,368–41,582 tokens while the benchmark reported 8,000; measured on the real text, savings at 2k/4k/8k were 86.1–87.4% / 72.7–75.7% / 59.5–60.6%, not the figures shown then.

The default, 4000, was checked against the alternatives with slurp eval --retrieval: recall is the share of each question's labelled nodes inside the subgraph, and the tokens are the measured text sent (mean per question). PrismaStats is its slurp index graph (1,582 nodes, 15 built-in questions); slurp is its own graph (4,165 nodes, 16 questions labelled for this measurement by the same tool that tuned v1.2 — indicative, not an independent ground truth). Measured for v1.2.0, v1.1.1 in brackets:

4000 stays the default: in markdown — what slurp QUERY prints by default and the only format the MCP server sends — PrismaStats does not move from 4000 to 16000, and slurp gains one question at 8000 and another at 16000. JSON and YAML spend more tokens per node and catch up at 6000. Two things changed in v1.2: tests and import nodes no longer take places (on slurp's own graph three nodes in four are tests), and a node lends its neighbour boost to at most ten neighbours, so a hub's callers no longer fill the budget. One node is lost on the way: PrismaStats's dashboard_actions module (question arch-02), which v1.1.1 reached at 12000 only through the hundred callers of createAdminClient; v1.2 finds the other module of that question from 4000 on.

The v1.2 changes were decided on half of each project's questions, drawn once with a fixed seed, and checked on the other half: recall at 4000/8000 in markdown and JSON, averaged, went from 0.812 to 1.000 (PrismaStats) and 0.750 to 1.000 (slurp) on the tuning half, and from 0.780 to 0.893 and 0.562 to 0.750 on the held-out half. scripts/retrieval.py reproduces every figure in this section, split included.

Finding the code to change needs more. A later study (slurp v1.3.0, 14 open-source projects, 1,525 questions taken from commit history: the commit subject as the question, the definitions the commit changed as the answer, on the graph of its parent) looked for the budget past which more tokens find nothing new. For architecture questions like the ones above, the default is enough. For pinning down the specific function a change touches, recall keeps growing, about 10 points per doubling, up to 32000 with no plateau, in projects with more than about 2,000 candidate nodes (those slurp may return: no tests, no imports). There, in markdown, 4000 finds 34–68 % of the changed definitions, 16000 finds 52–75 % and 32000 finds 59–81 %. The default stays 4000: doubling the context for ten points is a trade-off, not an optimum. slurp_query's description tells the agent to pass 16000–32000 when it is after one specific function in a large project. v1.4.0 ranks better for exactly these questions: on six projects of that study it was not tuned on, recall at 4000 goes from 0.543 to 0.674 with the same tokens (Upgrading to v1.4.0). Details, in Spanish: conclusiones.md.

MRR does not depend on the budget. Its definition changed in v1.2: a relevant node's rank now counts only the nodes slurp can return — tests and imports, left out of selection, are left out of the ranking — because that is the order a reader meets them in. By the old definition, ranking every node, the scores and the ranks are the same as in v1.1.1; see slurp eval.

Latency of one slurp_query call through the MCP server's real handler (mcp._handle, the function slurp serve runs for each request), timed with time.perf_counter, at budget: 4000. Measured for v1.1.0 on an Apple M4, Python 3.12; three runs of each, the range shown.

Original method (v0.7.0): the PrismaStats graphify graph (2,111 nodes, 3,421 edges), ten queries — auth flow, prisma schema, database pool, player stats, admin permissions, match events, dashboard data, chat context, league standings, login logout — run once to warm the caches, then timed; the figure is the mean of the ten. v0.7.0 recorded no script or query list, so the queries are new; run the same way, the two releases around that change land close to the figures published then.

Current method (v1.1.0): caches cleared, then five queries three times (15 calls). Cold is the first call, which computes PageRank and costs every node it looks at; warm is the median and the maximum of the other fourteen.

v1.1.0 is about 1.5 ms slower per hot query than v0.7.0 by the original method, and does more for it: the budget costs relationships as well as nodes, and the text it returns is rendered and counted before it is sent. The per-component timings v0.7.0 listed (PageRank, token counting, greedy selection) are not repeated: they were not re-measured, and the greedy one gave the same 10.69 ms as the whole query.

Reproduce these figures with scripts/latency.py, in a checkout of the repository (the script is not shipped in the package). Each run is a fresh process, so caches start empty:

uv run python scripts/latency.py path/to/graph.json --method both --runs 3 # Another release, on the same machine and graph: git archive v0.7.0 slurp | tar -x -C /tmp/v070 uv run python scripts/latency.py path/to/graph.json --method original --src /tmp/v070 It prints one JSON line per run and a summary with the range of each figure. Re-run on the same PrismaStats graph with v1.1.1: 11.35–11.55 ms by the original method, and 9.93–10.08 ms for v0.7.0 through --src.

PageRank cache — PageRank depends only on the graph, never on the query, so it is computed once per graph object instead of once per query.

Token count cache — the token cost of every node and relationship, as the formatter writes it, is memoised across queries, keyed by item, format and encoding. An item's text does not depend on the query (scores are costed at their widest), so neither does its cost.

Greedy heap — the subgraph selector used to scan every remaining candidate on each iteration, which is O(n²). It now uses a lazy max-heap: scores still mutate as neighbors get boosted, so a boost pushes a fresh entry and superseded entries are discarded when they surface. Ties break by node id, which also makes the selection deterministic — the previous scan broke ties by set iteration order, so the same query could return a different subgraph on every process start.

Graph staleness — the MCP server records the graph file's mtime and reloads it when it changes on disk, invalidating both caches. Before, a server started before a re-index would keep answering from the graph it read at boot, with no way for the client to know. Responses that triggered a reload carry "graph_reloaded": true.

Requires Python 3.12+. Don't have Python? Install uv — it bundles a Python runtime and is the fastest path.

Install uv (if you don't have Python yet):

# macOS / Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows (PowerShell) powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" Then: uv tool install slurp-graph

Non-Python projects (JS, TypeScript, Go — install slurp globally so it's on your PATH):

uv tool install slurp-graph # recommended: isolated environment, no conflicts pipx install slurp-graph # same idea if you already have pipx pip install slurp-graph # works if Python's bin/Scripts dir is on your PATH Windows: pip install places slurp.exe in Python's Scripts folder, which may not be on PATH by default. If slurp is not found after install, see adding Python Scripts to PATH, or use uv tool install instead (it handles PATH automatically).

Python projects (adds slurp as a project dependency):

uv add slurp-graph # or pip install slurp-graph When using uv add, run slurp as uv run slurp or activate the virtual environment first. For the MCP server with uv add, see the note in MCP Integration.

PyPI package: slurp-graph — CLI command: slurp

Check what you have with slurp --version.

📖 Full usage guide (automatic MCP mode + manual CLI): USAGE.md

New to slurp? Run slurp init in your project root — it detects your language, indexes your codebase, and configures the MCP server in one step.

slurp init Then query it:

slurp "player stats" --graph graph.json --budget 4000 Real output with v1.4.0, on a 2,111-node graph of a Next.js codebase:

╭─ Slurp — Subgraph for: "player stats" (budget: 4,000 tokens) ╮ │ Selected 103/2111 nodes · 3,926/4,000 tokens used (4.9%) │ ╰──────────────────────────────────────────────────────────────╯ ## Relevant Nodes ### PlayerStatsInsert · score: 0.96 → File: types/database.ts ### PlayerStats · score: 0.96 → File: types/database.ts ### recalcularPlayerStats() · score: 0.95 → File: lib/supabase/admin-actions.ts ### updatePlayerStatsAdmin() · score: 0.94 → File: lib/supabase/admin-actions.ts ### getPlayerStatsAdmin() · score: 0.94 → File: lib/supabase/admin-actions.ts … ## Key Relationships - admin_page_admindashboardpage → calls → supabase_admin_actions_getadminstats - admin_page_admindashboardpage → calls → supabase_admin_actions_getultimosaccesos - admin_page_admindashboardpage → calls → supabase_admin_actions_getusagestats … --- 💡 1356 more nodes scored 0.15 or more but did not fit the budget — increase --budget to include them 💡 642 nodes scored below the minimum score 0.15 — a bigger budget will not include them (see --min-score) 💡 10 test nodes are left out by default — --include-tests to let them compete The closing tip separates the reasons a node is missing: it did not fit the budget (more budget brings it in), it scored below --min-score (no budget will), or it is test code or an import node, left out by default (--include-tests and --include-imports let them compete).

Nodes are ordered by relevance, and each carries the score that put it there. A node's one-line description appears under its heading when the graph has one — slurp index does not write descriptions, so the line is absent above.

Add --inject-code to embed the actual function body next to each node:

slurp "recalcularPlayerStats" --graph graphify-out/graph.json --budget 2000 --inject-code --min-score 0.8 --project-root . ### recalcularPlayerStats() · score: 1.00 → File: lib/supabase/admin-actions.ts ```typescript export async function recalcularPlayerStats(playerNombre: string, clubId: string, temporada: string) { const adminClient = await createAdminClient(); // 1. Buscar jugador en players const { data: player } = await adminClient .from("players") .select("id") .eq("nombre", playerNombre) .eq("club_id", clubId) .eq("temporada", temporada) .single(); ... } ``` … cut at 100 lines; the block continues at line 1240 of lib/supabase/admin-actions.ts The language tag is inferred from the file path, so the block is fenced as typescript here without being told. Add --project-root when the graph does not sit at the root of the source tree. A body is cut after 100 lines, and the line under the block says so and where the rest is: recalcularPlayerStats is longer.

Pipe the output directly into your LLM prompt, save it to a file, or use slurp export to format it as a ready-to-paste system prompt block.

Guided one-command setup. New to slurp? Run slurp init in your project root — it builds a graph that keeps itself current, registers the MCP server, approves it for Claude Code and tells your agent when to use it.

slurp init # from your project root — no flags needed slurp init --yes # accept the plan as shown (CI / scripting) slurp init --keep-graphify # serve graphify's graph instead of building slurp's slurp init --instructions versioned # paragraph in CLAUDE.md / AGENTS.md instead of CLAUDE.local.md It shows the whole plan and asks before writing anything:

Builds slurp's own graph, refreshed before every answer (see Keeping the graph current). With no graph yet it goes to graphify-out/graph.json; next to a graph slurp did not build — graphify's — it goes to graphify-out/slurp-graph.json and graphify's file is never touched (--keep-graphify serves graphify's instead, read-only); a graph slurp built is reused. The language is detected by counting indexable files, ignoring vendored trees like node_modules/ and .venv/ (folders above the project root never count).

Writes .mcp.json pointing at the slurp binary it detected — works with both uv tool install and pip install layouts. An existing .mcp.json is never clobbered: slurp asks first, and other MCP servers in the file are preserved.

Approves slurp for Claude Code in .claude/settings.local.json at the git root: "enabledMcpjsonServers": ["slurp"] (the project server) and "mcp__slurp__*" in permissions.allow (its tools) — the two approvals .mcp.json alone does not give. It merges without duplicating, never touches a file that is not valid JSON (it prints the fragment instead), keeps a server listed in disabledMcpjsonServers disabled and leaves deny/ask rules about slurp in place, and says so.

Tells the agent when to use slurp: a short paragraph, by default in CLAUDE.local.md (local, not versioned). When the project has only an AGENTS.md, the new file starts with @AGENTS.md so Claude Code keeps reading it. --instructions versioned writes to CLAUDE.md and/or AGENTS.md instead, none writes nothing. Running init again replaces the block between its markers; a file that already mentions slurp_query is left alone.

Keeps local files out of git: .slurp/, .claude/settings.local.json and CLAUDE.local.md go to an existing .gitignore unless git already ignores them — and so does the lock file beside slurp's graph (graphify-out/.slurp-graph.json.lock) when the project versions graphify-out/. With no .gitignore nothing is created and the summary says so. Claude Code ignores a .claude/settings.local.json that git tracks, so in a project that versions it the approval from step 3 does not apply: init says so and prints the exact git rm --cached command, and leaves taking the file out of git to you.

The summary also prints the configuration for Codex, Gemini CLI and Cursor, to copy by hand — slurp does not write them. Finish by restarting your AI coding assistant. The workspace-trust dialog Claude Code shows the first time you open a folder is still Claude Code's.

The main command. Scores all graph nodes against your query and selects the optimal subgraph within the token budget.

slurp "auth flow" --graph graph.json --budget 4000 slurp "payment processing" --format json slurp "JWT validation" --explain slurp "database schema" --inject-code --min-score 0.3 slurp "prisma models" --backend openai Flag Default Description --graph, -g auto-discover Path to graph.json. Repeatable — see federation. --graph-label derived from path Project name for each --graph, in the same order. --budget, -b 4000 Upper bound, in tokens, on the text slurp prints — nodes, relationships, header and all, measured on the final output in the chosen format. If not even one node fits, the output is the header with the budget it would need. With --format json or yaml a node costs more, so use about 6000–8000 for the recall markdown gets at 4000 (see Choosing a budget). --format, -f markdown Output format: markdown, json, or yaml. --model, -m cl100k_base Tiktoken encoding for token counting. --explain off Print per-node score breakdown: final / structural / semantic. --no-audit off Skip writing to .slurp/audit.jsonl. --neighbor-decay 0.7 Score multiplier applied to neighbors of each selected node — to at most 10 of them per node, the most relevant on their own, so a hub with a hundred callers does not lend its score to all of them. --min-score 0.15 Minimum relevance score; nodes below this are excluded before selection. The same default applies to export, benchmark, eval, diff --budget, the MCP server and the library. On slurp index graphs every node is code and gets the +0.3 code boost, so 0.15 filters nothing there — the budget is the limit; on graphify graphs it keeps unrelated documents and concepts out. --token-factor 1.0 Multiply every token count, for a reader that does not tokenize like tiktoken. Also $SLURP_TOKEN_FACTOR; the flag wins. See Counting tokens below. --viz off Open an interactive graph visualization in the browser. --viz-output PATH — Save visualization HTML to file (without opening browser). --ignore-file .slurpignore Path to node exclusion rules. --backend tfidf Scoring backend: tfidf (default) or openai (real embeddings). anthropic was retired in v1.0.7: Anthropic offers no embeddings endpoint. --inject-code off Embed source code blocks for each selected node (requires ≤30 nodes). --project-root graph dir Root directory for resolving source_file paths. --include-tests off Let test code compete for a place in the subgraph. --include-imports off Let import nodes compete for a place in the subgraph. --no-refresh off Do not refresh slurp's own graph first; only warn if it is out of date. Also SLURP_REFRESH=0. See Keeping the graph current. --refresh-timeout S 2 Seconds to wait for a refresh before answering from the previous graph; 0 never waits. Also SLURP_REFRESH_TIMEOUT. Tests and imports are left out by default. Test code (anything under a tests/, test/, __tests__/ or spec/ directory, or in a file a test runner collects — see slurp explain) and the import nodes slurp index writes for every import statement never take a place in the subgraph unless you pass --include-tests or --include-imports. On slurp's own graph three nodes in four are tests: they carry the name of what they test, outscored the code itself and filled the budget. They stay in the graph — PageRank still counts the calls from tests, which measured better than dropping them — and the closing tip says how many were left out. The same flags exist on export, benchmark and eval, and as include_tests / include_imports on the MCP tools slurp_query and slurp_suggest.

Auto-discovery (when --graph is omitted):

./graphify-out/slurp-graph.json — slurp's own graph next to graphify's; it exists only if you or slurp init chose it, so it comes first

./graphify-out/graph.json

./.graphify/graph.json

export, explain, impact, stats and advisor take the same --no-refresh and --refresh-timeout.

Multi-graph federation

Query across multiple codebases simultaneously.

A system split across repos is still one system, but slurp normally sees one graph at a time — a question about "auth flow" stops at the boundary of whichever repo you pointed it at. Pass --graph more than once to merge them into a single queryable graph:

slurp "auth flow" --graph prismastats/graphify-out/graph.json --graph slurp/graphify-out/graph.json Real output with v1.4.0, federating two unrelated projects: PrismaStats, a Next.js app (its graphify graph, 2,111 nodes), and slurp's own source at v1.2.0 (its slurp index graph, 4,465 nodes). The top and the end of the answer:

Federated: 2 graphs · 6,576 nodes total ╭─ Slurp — Subgraph for: "auth flow" (budget: 4,000 tokens) ╮ │ Selected 119/6576 nodes · 3,929/4,000 tokens used (1.8%) │ ╰───────────────────────────────────────────────────────────╯ ## Relevant Nodes ### actions.ts · score: 1.00 → File: lib/auth/actions.ts ### route.ts · score: 0.84 → File: app/auth/callback/route.ts ### GET() · score: 0.84 → File: app/auth/callback/route.ts … ## Key Relationships - prismastats::asistencia_page_asistenciapage → calls → prismastats::supabase_admin_createadminclient … --- 💡 2057 more nodes scored 0.15 or more but did not fit the budget — increase --budget to include them 💡 672 nodes scored below the minimum score 0.15 — a bigger budget will not include them (see --min-score) 💡 3374 test nodes and 354 import nodes are left out by default — --include-tests / --include-imports to let them compete Node ids are namespaced automatically. Two projects can both define main or load_graph without one silently overwriting the other — every id is prefixed with its project, as prismastats::supabase_admin_createadminclient above. If any original ids did appear in more than one graph, slurp says so in one line under the federation header; these two graphs share none, so the output above has no such line.

Project names come from the graph paths by default. Since most projects keep their graph at /graphify-out/graph.json — where every file stem is just graph — slurp walks up the path for a name that actually identifies the project. Override it with --graph-label, one per --graph, in the same order:

slurp "auth flow" \ --graph services/auth/graphify-out/graph.json \ --graph services/api/graphify-out/graph.json \ --graph apps/web/graphify-out/graph.json \ --graph-label auth --graph-label api --graph-label frontend The MCP server federates too, so your AI assistant can query every service at once through the same slurp_query tool. Responses carry graphs_count when more than one graph is being served:

slurp serve --graph services/auth/graph.json --graph services/api/graph.json In --viz, federated nodes show a Project field in the detail panel, and the legend gains a Projects section listing every project on screen.

One graph behaves exactly as before — no prefixes, no _project attribute, no federation header. Federation only engages from the second --graph onward.

Merging does not invent edges between projects: if api imports auth, that relationship exists in neither graph.json, so slurp does not fabricate it. Each project stays internally connected, and neighbor expansion does not cross project boundaries.

Print node and edge counts for a graph file.

slurp stats --graph graph.json Graph: graph.json Nodes: 2111 Edges: 3421 slurp audit

Show the history of queries logged to .slurp/audit.jsonl, plus the most frequently selected nodes.

slurp audit slurp audit --top-nodes 20 slurp audit --audit-dir /custom/.slurp Real output with v1.4.0, after five queries at --budget 3000 on slurp's own graph (budget selection, graph loader, mcp server, token counting, call graph extraction):

Query History (last 5 of 5) ┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━┓ ┃ # ┃ Timestamp ┃ Query ┃ Nodes ┃ Tokens ┃ ┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━┩ │ 1 │ 2026-11-27T22:23:23 │ budget selection │ 62 │ 2,948 │ │ 2 │ 2026-11-27T22:23:24 │ graph loader │ 69 │ 2,943 │ │ 3 │ 2026-11-27T22:23:24 │ mcp server │ 54 │ 2,948 │ │ 4 │ 2026-11-27T22:23:24 │ token counting │ 64 │ 2,948 │ │ 5 │ 2026-11-27T22:23:25 │ call graph extraction │ 73 │ 2,938 │ └──────┴─────────────────────┴───────────────────────┴───────┴────────┘ Top 10 Most Selected Nodes ┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓ ┃ Rank ┃ Node ┃ Times Selected ┃ ┡━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩ │ 1 │ slurp.cli │ 5 │ │ 2 │ slurp.loader.load_graph │ 5 │ │ 3 │ slurp.mcp.FederatedGraphState.check_reload │ 5 │ │ 4 │ slurp.mcp.GraphState.check_reload │ 5 │ │ 5 │ slurp.budget.full_graph_tokens │ 4 │ │ 6 │ slurp.budget.clear_node_token_cache │ 4 │ │ 7 │ slurp.cli.run │ 4 │ │ 8 │ slurp.mcp._handle │ 4 │ │ 9 │ slurp.scorer.score_nodes │ 4 │ │ 10 │ slurp.cli._find_graph │ 4 │ └───────┴────────────────────────────────────────────┴────────────────┘ Every query is appended as a JSON line (unless --no-audit is passed). Useful for tracking which parts of your codebase an AI agent visits most.

There is no savings column: savings are what slurp benchmark measures — the whole graph printed the same way and counted — and the log does not hold that measurement. Until v1.1.0 the column guessed it from the node count.

Recommends the optimal token budget based on your query history.

Guessing at --budget costs you either way: too low truncates the answer, too high pays for nodes the LLM never reads. Once .slurp/audit.jsonl holds a few dozen entries, the right number is already in your data — the advisor finds the past queries that resemble the new one and reads the budget off what they actually used.

slurp advisor "budget selection" --graph graph.json slurp advisor "auth flow" --graph graph.json Real output with v1.4.0 on slurp's own graph, after the five queries of the slurp audit example and budget selection heap at --budget 1500, 2500, 4000 and 6000:

╭────────────────────────────── Budget Advisor — "budget selection" ───────────────────────────────╮ │ Based on 5 similar past queries │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Recommended budget: 3,923 tokens Expected coverage: 93.3% of similar queries' selections Estimated cost: $0.0118 (claude-sonnet-5) Confidence: MEDIUM (5 similar queries) Similar past queries: "budget selection" → 2,948 tokens · 62 nodes "budget selection heap" → 1,477 tokens · 36 nodes "budget selection heap" → 2,453 tokens · 60 nodes "budget selection heap" → 3,923 tokens · 75 nodes "budget selection heap" → 5,882 tokens · 102 nodes Run with recommended budget: slurp "budget selection" --graph graph.json --budget 3923 And on PrismaStats, after twelve queries at --budget 3000 — auth flow alone and followed by callback, cookie, guard, jwt, login, logout, middleware, redirect, session, signup and token:

╭────────────────────────────────── Budget Advisor — "auth flow" ──────────────────────────────────╮ │ Based on 12 similar past queries │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Recommended budget: 2,946 tokens Expected coverage: 100.0% of similar queries' selections Estimated cost: $0.0088 (claude-sonnet-5) Confidence: HIGH (12 similar queries) Similar past queries: "auth flow" → 2,946 tokens · 97 nodes "auth flow callback" → 2,946 tokens · 85 nodes "auth flow cookie" → 2,943 tokens · 97 nodes "auth flow guard" → 2,943 tokens · 97 nodes "auth flow jwt" → 2,947 tokens · 98 nodes … and 7 more Run with recommended budget: slurp "auth flow" --graph graph.json --budget 2946 Flag Default Description --graph, -g auto-discovered Path to graph.json, used in the suggested command line. --audit-dir .slurp Directory containing audit.jsonl. --price-model claude-sonnet-5 Pricing model for the cost estimate (same models as slurp benchmark). --min-similar 3 Similar queries needed before a recommendation is considered confident. How it works. Past queries are tokenized with the same tokenizer used to score nodes — so authFlow, auth_flow and auth flow are one ask — and compared by TF-IDF cosine similarity. Anything at or above 0.3 counts as similar. The recommended budget is the 75th percentile of what those queries actually consumed: it fits three out of four comparable queries, where the mean would under-serve the heavier half and the max would pay for one outlier every time.

The advisor shows what each similar query used — tokens and nodes, both recorded when it ran — and no savings: the audit log does not hold the full-graph measurement that slurp benchmark compares against. Until v1.1.0 it estimated one from the node count.

Explains any node in natural language — what it does, its architecture, and the risk of changing it. With --no-llm, or whenever no provider is configured, it answers from the graph alone: an architectural role inferred from the node's position, its immediate neighbourhood, the share of the project that depends on it, and two or three commands that continue the investigation. No API key, no network.

slurp explain "recalcularPlayerStats" --graph graph.json --no-llm Real output with v1.4.0 on PrismaStats's graphify graph:

The role is read off the graph: more than ten callers make a central utility, many callers with few dependencies a shared utility, callers and callees both high an orchestrator, none of either isolated. Callers that live in test files are counted separately, so a helper exercised by sixty tests and two modules is not reported as having sixty-two dependants. A test file is one a test runner would collect: anything under a tests/, test/, __tests__/ or spec/ directory (or a .NET *.Tests project), a file named like test_*.py, *_test.go, *.spec.ts or *Test.java, and Rust's mod tests; latest_results.py is not one.

The risk band counts production callers only — the same rule slurp impact and slurp diff use, so the three always agree. Tests get their own line under ARCHITECTURE (→ Tested by: 72 tests in 9 files) and in the risk summary (10 production callers, 72 in tests). A node that only tests call is LOW but never called safe: No production callers · 12 tests call it — update them if you change its behaviour. A free-text slurp explain never lands on a test or an import node; name one exactly and you get it.

Providers. With no --provider, slurp auto-detects in this order:

If none are present, slurp uses the structural explanation — a deterministic description built from the graph alone. It is always produced first, so a missing SDK, an absent API key, or an unreachable endpoint degrades to it rather than failing.

Real output with v1.4.0, with nothing listening on the endpoint:

Architecture and risk are always computed from the graph, never written by the model. The LLM contributes only the prose under EXPLANATION; callers, callees, and blast radius are facts slurp already has, so the model is explicitly told not to restate them.

The risk is only as good as the graph's call edges. slurp index extracts them, across files, for Python, TypeScript/JavaScript, Go, Java and Rust — on PrismaStats's slurp index graph createAdminClient has 97 production callers and reads HIGH — and the other eleven languages read UNKNOWN, not LOW. A React component rendered as JSX () gets a renders edge since v1.5, and the pages that render it count as its dependants: on PrismaStats's slurp index graph, Button has 32 and reads HIGH. Until v1.4 JSX made no edge, and 530 of the 536 nodes in PrismaStats's .tsx files read LOW.

Saves LLM settings to .slurp/config.json so you don't pass flags every time.

slurp config set provider openai-compatible slurp config set model qwen2.5-coder slurp config set endpoint http://localhost:1234/v1 slurp config set api_key sk-... # stored, never echoed back slurp config show slurp config — .slurp/config.json ┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Key ┃ Value ┃ ┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ api_key │ ******** │ │ endpoint │ http://localhost:1234/v1 │ │ model │ qwen2.5-coder │ │ provider │ openai-compatible │ └──────────┴──────────────────────────┘ Effective provider: openai-compatible Effective model: qwen2.5-coder Effective endpoint: http://localhost:1234/v1 Keys: provider, model, endpoint, api_key, temperature. Precedence is flags → saved config → environment auto-detection, so an explicit flag is never overridden by a stored preference. slurp config show prints both what is saved and what slurp would actually use right now.

api_key is masked in all output but stored in plain text in .slurp/config.json, written with permissions 0600. Like slurp init, slurp config set adds .slurp/ to an existing .gitignore that does not mention it yet; it never creates one, and a rule you wrote — including !.slurp/ — is left alone. Without a .gitignore, keep .slurp/ out of version control yourself, or leave the key in an environment variable instead.

Know exactly what changed — and what it affects.

A git diff tells you which lines moved. It cannot tell you that the helper you just renamed is called from eleven other modules, or that the function you deleted was the only caller keeping a service alive. slurp diff compares two versions of your knowledge graph and reports the blast radius: what changed, what sits downstream of it, and which nodes are central enough that a reviewer should look at them by hand.

The workflow: before you merge

Index both sides of the change and diff them:

git checkout main && slurp index . --output main.json git checkout feature/auth-refactor && slurp index . --output feature.json slurp diff main.json feature.json --viz The --viz flag opens an interactive graph where the change is colour-coded: green for added nodes, red for removed, yellow for modified, and grey for untouched neighbors that are still connected to the change. You can see at a glance whether your refactor touched one isolated corner or pulled on a thread running through half the codebase.

Without --viz you get a Markdown impact report — pipe it into a PR description, a review checklist, or your AI assistant:

# Slurp Diff — Impact Analysis ## Summary - **✅ Low impact change** - **Impact score:** 0.1184 (🟢 low) — 1 production caller reached - 14 tests in 8 files touch the change - 1 nodes added · 1 removed · 0 modified - 2 edges added · 17 removed - 3 nodes in risk neighborhood ## Added Nodes (1) ### choose_subgraph (function) → File: slurp/budget.py ## Removed Nodes (1) ### slurp.budget.select_subgraph ## Affected Edges **Added (2):** - slurp.budget → contains → slurp.budget.choose_subgraph - slurp.budget.choose_subgraph → calls → slurp.budget.build_context **Removed (17):** - slurp.budget → slurp.budget.select_subgraph - slurp.budget.select_subgraph → slurp.budget.build_context - slurp.mcp._handle_suggest → slurp.budget.select_subgraph - tests.test_audit.TestAuditIntegration.test_pipeline_log_then_read → slurp.budget.select_subgraph - tests.test_audit.TestAuditIntegration.test_pipeline_multiple_queries_top_nodes → slurp.budget.select_subgraph - … ## Nodes at Risk Direct neighbors of changed nodes: - build_context (function) · centrality: 0.0057 - budget (module) · centrality: 0.0031 - _handle_suggest (function) · centrality: 0.0012 ## What to review Most connected nodes in the blast radius — review these first: 1. load_graph (function) · centrality: 0.0126 · slurp/loader.py 2. diff_graphs (function) · centrality: 0.0107 · slurp/diff.py 3. score_nodes (function) · centrality: 0.0103 · slurp/scorer.py 4. cli (module) · centrality: 0.0092 · slurp/cli.py 5. format_subgraph (function) · centrality: 0.0090 · slurp/formatter.py The change above renames select_subgraph in slurp v1.1.0 without touching its callers: seventeen edges go — fourteen from tests, one from the module that contains it, one its own call to build_context — so one production caller is left broken (mcp._handle_suggest) and the score is low. Until v1.0.7 the same kind of rename scored 0.0048 whatever it broke: the score was a share of the whole graph. Since v1.1.0 it counts callers — see below. The risk neighbourhood is read from the old graph where the deleted function still exists (until v1.1.1 it was looked up in the new graph and listed none of its callers), and since v1.2 it holds production code only: the fourteen tests get one line in the summary, and neither they nor import nodes appear among the nodes at risk or to review (v1.1.1 listed 17 at risk, _runner first to review).

The run finishes with a colour-coded summary panel and, if you did not pass --viz, the exact command to see the full picture:

╭───────────────────────────────────────── Impact Summary ─────────────────────────────────────────╮ │ │ │ ✅ Low impact change (impact score 0.1184) │ │ │ │ +1 added -1 removed ~0 modified │ │ │ │ See the full blast radius: │ │ slurp diff old.json new.json --viz │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ Flags

slurp diff old.json new.json slurp diff old.json new.json --hops 2 --viz slurp diff old.json new.json --budget 4000 slurp diff old.json new.json --viz-output reports/impact.html Flag Default Description --hops 2 Depth of impact neighborhood expansion. --viz off Open an interactive visualizer of the affected area in the browser. --viz-output PATH — Save visualization HTML to file (without opening browser). --budget, -b none Token budget; selects the most relevant nodes from the affected area. Impact score counts what could break: the distinct production callers of every deleted node, and of every node whose label, type or outgoing calls changed (tests, containing modules and import nodes do not count, and adding or dropping an import is not a change in what a node calls). It is 1 − e^(−D/k), with the scale and bands derived from the same thresholds slurp impact and slurp explain use, so the three always agree: 6+ callers is high, 2–5 medium, 0–1 low. Deleting a function with 97 callers scores 1.00 (high); adding an uncalled one scores 0. If a changed node is in a language with no call graph, a low score is reported as unknown instead, with the reason, and the report lists the callers it counted. --hops controls how far the blast radius is traced; --budget narrows the affected area down to what fits a token budget, so you can hand exactly the relevant slice to a reviewer or an LLM.

This is the only tool that shows you the blast radius of your code changes before you merge.

Export a context block ready to paste into an AI system prompt.

slurp export "auth flow" --format claude # XML tags slurp export "auth flow" --format chatgpt # [CODEBASE CONTEXT] block slurp export "auth flow" --format claudemd # ## Codebase Context for CLAUDE.md slurp export "auth flow" --output context.md All three formats include query, nodes selected/total, tokens used/budget, and coverage %.

Start an MCP stdio server (JSON-RPC 2.0) exposing five tools — slurp_query, slurp_explain, slurp_diff, slurp_suggest and slurp_impact.

slurp serve --graph graph.json slurp serve --graph graph.json --no-log Flag Default Description --graph, -g auto-discover Path to graph.json. Repeatable — see federation. --graph-label derived from path Project name for each --graph, in the same order. --log / --no-log --log Append every tool call to .slurp/session.log (only if .slurp/ exists). See slurp session. --no-refresh off Serve the graph as it is; answers still warn when it is out of date. Also SLURP_REFRESH=0. --refresh-timeout S 2 Seconds a call waits for a refresh. Also SLURP_REFRESH_TIMEOUT. Before each call the server refreshes slurp's own graph if the working tree changed — see Keeping the graph current. See MCP Integration for configuration.

Analyzes the blast radius of editing a file before making changes — no second snapshot needed. Where slurp diff answers this after the fact by comparing two graphs, slurp impact answers it beforehand from the graph you already have.

slurp impact lib/supabase/admin.ts --graph graph.json Real output with v1.2.1 on PrismaStats's graphify graph, complete — the list stops at ten files by design and counts the rest. AGENTS.md and all_tsx_exports.txt are text files: graphify's graph attributes three component nodes to each, and slurp lists the files the graph gives:

╭─ Impact Analysis — lib/supabase/admin.ts ─────╮ │ 2 definitions · RISK: HIGH · affects 69 files │ ╰───────────────────────────────────────────────╯ HIGHEST RISK NODE createAdminClient() — 130 production dependents (6.2% of codebase) AFFECTED FILES (top 10) lib/supabase/admin-actions.ts 31 dependents lib/supabase/cantera-actions.ts 14 dependents lib/supabase/dashboard-actions.ts 11 dependents lib/supabase/reports-actions.ts 8 dependents app/api/mis-partidos/route.ts 6 dependents …entrenamientos/favoritos/route.ts 5 dependents AGENTS.md 3 dependents all_tsx_exports.txt 3 dependents app/admin/configuracion/actions.ts 3 dependents app/admin/clubes/page.tsx 2 dependents … and 59 more files RECOMMENDATION Add integration tests before editing. 130 nodes depend on functions in this file. ───────────────────────────────────────────────────────────────────── Direct: 130 · Transitive: 48 · Tests: 0 · Impact score: 0.0843 The risk, the dependents and the affected files count production code only, as in slurp explain and slurp diff. The risk is rated on the direct dependents; the affected files are every file holding a dependent within --hops, direct or transitive, and the headline, the AFFECTED FILES list and affected_files in --output json count the same ones; each file's count (dependents_per_file in JSON) adds both kinds. Tests that call into the file get their own block — TESTS — 58 tests in 10 files call into this file, with the files that hold most — and import nodes are not counted as definitions. A SAFE TO EDIT block lists the definitions in the file that nothing calls at all, not even a test — the other half of the question. A node only tests call is listed under NO PRODUCTION CALLERS instead: LOW, but its tests break if it changes. A node called only from inside the same file is in neither: contained is not the same as safe. --output json carries safe_nodes, test_only_nodes, test_dependents and test_files.

Risk is UNKNOWN when the file's language has no call graph. slurp extracts calls for Python, TypeScript/JavaScript, Go, Java and Rust; the other eleven languages get definitions and imports only, so zero callers there means "not in the graph", not "nobody calls it". slurp impact then reports RISK: UNKNOWN with the reason, lists nothing as safe, and --output json carries "risk_level": "UNKNOWN" plus a risk_reason — gate on it as you would on HIGH. A graph whose calls edges cover that language (graphify extracts them for any language) is rated as usual. slurp explain and the MCP tools slurp_impact and slurp_explain say the same.

The path is matched on a normalised suffix, so slurp impact admin.ts finds lib/supabase/admin.ts without you having to know how the indexer spelled its paths. An exact match always wins over a suffix. A file with no nodes in the graph is answered, not refused: it reports that nothing was found and suggests re-indexing if the file is new.

Also exposed over MCP as slurp_impact(file_path, hops=2) — the tool an agent should reach for before editing anything.

Suggests related queries to explore after a query — drill down, sibling exploration, and high-risk dependency detection. It reads the nodes that sat just outside the token budget: connected enough to be neighbours, not relevant enough to be selected, which is exactly the shape of something you have not looked at yet.

SUGGESTED QUERIES slurp "page props client" — explore the connected area the budget left out slurp explain 'createClient' — high-risk dependency — 36 nodes depend on it Three kinds of suggestion, each fired only when the graph supports it (above, the drill-down does not):

Query text is built from the tokens that set the frontier apart from the rest of the graph, weighted by how rare each one is graph-wide — a term common inside the frontier and uncommon outside it wins. Import placeholders are excluded: they carry the name of what they import, so they describe wiring rather than subject matter. A suggestion that says nothing the original query did not is dropped, and when the budget already covers the neighbourhood the list is simply empty.

The same graph and query always give the same suggestions. The risk suggestion names the frontier node with the most dependants; on a tie, a definition comes before the file node that holds it (in v1.2.0's answer to this query, Badge before badge.tsx, 16 each), then the smallest node id. Until v1.2.0 a tie went to whichever node a set happened to yield first, which changed from one process to the next.

Also exposed over MCP as slurp_suggest(query, budget=4000), so an agent can ask what else is worth looking at without a second round trip through the terminal.

Shows what your AI assistant asked the MCP server — every call to any of the five tools.

slurp session --last 10 slurp session --tail slurp session --sessions # one row per server session Flag Default Description --last N 20 Number of most recent entries (or sessions) to show. --tail off Follow the log in real time (Ctrl+C to stop). --sessions off Summarise each server session: client, duration, calls per tool, when the first call came, files changed before it, edits that had a slurp_impact or slurp_explain on that file first, answers with a warning, p95 refresh time. --log-dir PATH .slurp Directory containing session.log. Real output, after an MCP client sent two slurp_query calls to slurp serve --graph graph.json on slurp's own graph — auth flow at budget 4000 and mcp server at 2000:

MCP Session Log — last 2 (.slurp/session.log) ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━┳━━━━━━━┓ ┃ Time ┃ Tool ┃ Asked ┃ Budget ┃ Nodes ┃ Tokens ┃ Graph ┃ ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━╇━━━━━━━━╇━━━━━━━┩ │ 2026-11-27T22:23:33 │ slurp_query │ auth flow │ 4,000 │ 83 │ 3,925 │ fresh │ │ 2026-11-27T22:23:33 │ slurp_query │ mcp server │ 2,000 │ 33 │ 1,955 │ fresh │ └─────────────────────┴─────────────┴────────────┴────────┴───────┴────────┴───────┘ Each line of .slurp/session.log (JSON) records the session (process and start time), the client and protocol revision, the tool and its arguments in short, how long the call took, the graph's state, the refresh time and the files that changed, nodes and tokens, and the error if it failed. A start event names the graph and its owner; an end event, when the client disconnects, lists every file that changed during the session — in a task an agent did, its edits. Lines written before v1.3 are still read.

No savings column, and no savings_pct in the log since v1.1.0: measuring the whole graph the way slurp benchmark does costs 70–700 ms per call, against 4–7 ms for the query, so the server does not do it. Older logs keep their savings_pct field, an estimate from the node count; it is not shown.

Use it to confirm your AI assistant is actually calling slurp. The log is written only when .slurp/ already exists — running any query manually creates it, and slurp serve --no-log turns logging off entirely.

Measure real token savings across queries and budgets. It measures the graph as it is: it never refreshes it, and warns on stderr when slurp's own graph is out of date.

slurp benchmark \ --graph graph.json \ --queries "auth flow" --queries "schema validation" \ --budget 2000 --budget 4000 --budget 8000 # Windows CMD: remove the backslashes and write on one line Benchmark Results — pricing: default ($3/MTok input) ┏━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓ ┃ Query ┃ Budget ┃ Tokens used ┃ Full graph ┃ Savings ┃ Cost (slurp) ┃ Cost (full) ┃ Nodes sel. ┃ Nodes total ┃ Coverage ┃ ┡━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩ │ select subgraph │ 2,000 │ 1,949 │ 318,075 │ 99.4% │ $0.0058 │ $0.9542 │ 69 │ 4013 │ 1.7% │ └─────────────────┴────────┴─────────────┴────────────┴─────────┴──────────────┴─────────────┴────────────┴─────────────┴──────────┘ Summary ┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Metric ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ Mean savings │ 99.4% │ │ p50 savings │ 99.4% │ │ p90 savings │ 99.4% │ │ p95 savings │ 99.4% │ │ Best case │ 99.4% ('select subgraph', budget 2,000) │ │ Worst case │ 99.4% ('select subgraph', budget 2,000) │ │ Cost with slurp │ $0.0058 │ │ Cost without slurp │ $0.9542 │ │ Money saved │ $0.9484 (99.4%) │ └────────────────────┴─────────────────────────────────────────┘ Retrieval quality is not measured here: see `slurp eval --retrieval`. One query at one budget, run against slurp's own graph (4,013 nodes) with v1.1.0.

Outputs a per-run table and aggregate stats: mean savings, p50/p90/p95, best/worst case. Both sides are measured the same way since v1.1.0: Tokens used is the text slurp prints for that query and budget, and Full graph is the whole graph printed by the same formatter with the same header — so Savings compares two texts produced alike. The former Precision column is gone: it compared the selection with the scorer's own notion of a relevant node, which measures nothing; use slurp eval --retrieval for recall and MRR against labelled nodes.

Measures response quality with and without slurp context, using an LLM judge. Like slurp benchmark, it never refreshes the graph it measures and warns when it is out of date.

slurp benchmark measures how many tokens the selector saves. It says nothing about whether the answer is still correct. slurp eval closes that loop: each question is answered twice — once from a budgeted subgraph, once from the entire graph — and an LLM judge scores both against a known ground truth.

slurp eval --graph graph.json --budget 4000 --provider anthropic slurp eval --graph graph.json --questions my-questions.json --output results.json slurp eval --dry-run # list the questions, call no LLM slurp eval --retrieval # recall + MRR of relevant_nodes — no LLM, no cost, reproducible slurp eval --retrieval --format json # same, budgeted and measured as JSON Real run with v0.9.5 against a 1,796-node Next.js codebase, 15 questions, budget 4,000 (before v1.1.0, so the slurp context was larger than the budget — see the note below):

slurp win rate: 46.7% (7/15) Mean score with slurp: 0.770 Mean score baseline: 0.784 Token savings: 79.9% Quality/token slurp: 0.000061 Quality/token baseline: 0.000012 The honest conclusion: slurp does not improve quality when the model has unlimited context. With the whole 62,810-token graph in the prompt, a large-context model finds the answer on its own — the baseline scored marginally higher (0.784 vs 0.770).

What slurp improves is efficiency, radically: 5× more quality per token, at 12,865 tokens per question instead of 62,810. And it improves quality when the budget is restrictive or the graph is too large to fit at all — which is the case slurp exists for.

Per-question, slurp won the multi-hop flow questions ("what is the full call chain from…") and lost the whole-graph aggregation ones ("which files concentrate the most functions") — exactly what pruning to a subgraph would predict.

MRR counts the nodes slurp can return. Since v1.2 the rank of a relevant node is its position among the nodes selection may pick — tests and import nodes left out unless let in — because that is the order a reader meets them in. The rank over every node, the definition until v1.1.1, is reported beside it (mrr_all, first_rank_all, and a second figure in the panel when they differ). A relevant node that is itself a test or an import cannot be found with the defaults: it scores recall 0 and no rank.

Each question costs three LLM calls (answer with slurp, answer from the full graph, judge). The built-in set of 15 questions is therefore 45 calls; budget accordingly. The baseline context is built once and reused across questions.

In that v0.9.5 run, --budget capped the node selection, not the rendered prompt: budget 4,000 produced a 12,865-token context. Since v1.1.0 the budget bounds the text sent, so the same command sends at most 4,000 tokens per question; the run has not been repeated since.

Index the project's source code and generate graph.json without graphify or any LLM.

slurp index . # index current directory slurp index /path/to/project # specific path slurp index . --output custom/graph.json # custom output path slurp index . --watch # keep the graph current until Ctrl+C slurp index . --smart # only re-index what changed slurp index . --force # replace a graph another tool wrote The default output, graphify-out/graph.json, is also where graphify writes its own graph. If that file exists and was not written by slurp, slurp index asks before replacing it (the default answer is no, and a non-interactive run never overwrites). Keep both with -o graphify-out/slurp-graph.json, or replace it with --force. slurp init builds slurp's graph in graphify-out/slurp-graph.json by default when graphify's is there.

Real output, v1.5.1 on PrismaStats (the paths are placeholders). The retrieval figures in Choosing a budget use this project's v1.2.0 graph, 1,582 nodes and 1,852 edges; v1.5's React components add 56 nodes and the renders edges:

Indexing /path/to/prismastats ... ✓ 1638 nodes · 2285 edges · 185 files Parsers: Python (ast) · TypeScript (tree-sitter) Saved: /path/to/prismastats/graphify-out/graph.json Next: slurp "your query" --graph /path/to/prismastats/graphify-out/graph.json What is never indexed. Dependencies, caches and build output, wherever they sit below the project root: node_modules/, .venv/, venv/, vendor/, _vendor/, dist/, build/, coverage/, .git/, the Python caches and *.egg-info/, minified *.min.js bundles, and the build output of web frameworks — .next/ (Next.js), .nuxt/ (Nuxt), .svelte-kit/ (SvelteKit), .turbo/ (Turborepo), .vercel/ (Vercel CLI) and .output/ (Nitro: Nuxt 3, SolidStart). An out/ folder is skipped only when it holds a Next.js static export (an out/_next/ directory); otherwise it may be real code and is indexed. Folders above the project root never count. To leave out anything else, use .slurpignore.

Call graph — five languages (Python, TypeScript/JavaScript, Go, Java, Rust): slurp index extracts calls edges between functions, within a file and across them, enabling accurate risk analysis in slurp explain and impact propagation in slurp diff.

React components: renders (v1.5). A JSX usage of a component of the project, , is a renders edge from the function that renders it: a component defined in the same file or imported from another (named, default when the symbol is named like the binding, or through import * as Dialog), and one loaded with React.lazy or next/dynamic. Lower-case tags (

), components of libraries and a component passed as a prop (icon={Badge}) make none. A component wrapped in React's memo or forwardRef (const Button = React.forwardRef(...)) is a node, so its renderers count too. One edge per pair: a component that is also called as a function keeps calls. renders counts wherever calls does — dependants and risk in explain, impact and diff, and the ranking's walk. JSX in a .js file is read by the regex fallback, with the same rules: the TypeScript grammar does not parse it.

Return type propagation: srv := NewServer() followed by srv.Start() now generates a call edge for Go, Rust, Java and TypeScript. The return type must be declared and must name a type defined in the project — an inferred TypeScript return, or one naming a third-party type, still emits nothing.

Anything that cannot be resolved with certainty emits no edge — stdlib and third-party calls, a method on an object of unknown type, a chained or computed callee. A missing edge is a gap; a wrong edge is a lie about the codebase, so ambiguity always resolves to silence. Both endpoints of every calls edge are guaranteed to be nodes that exist in the graph.

Cross-file calls resolved in all five languages — an imported symbol followed by a call generates a direct calls edge to the real definition, not a dead end at the import placeholder. Resolution runs after every file is indexed, so it sees the whole project.

Python: from X import f followed by f(), plus import X as m + m.f().

TypeScript/JavaScript: named, namespace, default and aliased imports resolved. type-only imports ignored. @/ aliases and barrel exports supported.

Java: import statements resolved to their target class. Static imports and wildcard imports with unique candidates supported.

Rust: use crate::, use super::, and {A, B, C} multi-symbol imports resolved. Glob imports with unique candidates supported.

Go: package imports resolved by directory matching. Explicit and automatic aliases supported. Dot imports with unique candidates. package main excluded from the index.

An import only resolves when its module is part of the project. That single rule is what keeps from pathlib import Path from binding to a local class of the same name, and import { useState } from 'react' from binding to a local react.ts.

Go methods are nested under their receiver, so a method's node id is pkg.Struct.Method. A package is a directory, not a file, so auth.Login() is answered by every file in auth/, and package main is excluded from the index because it is never importable. A local variable typed by a struct literal or a var declaration resolves.

Java declares every variable and field type, so nothing has to be inferred from an initialiser — a field resolves whenever its declared type is a class this file can name, which is what makes dependency-injected collaborators navigable. Method parameters are not yet read, and inheritance does not cross files: a method inherited from a base class in another file resolves to nothing.

Rust methods live in impl blocks, not in the struct, so a method's node id is module.Type.method and every impl Type block — including impl Trait for Type — contributes to the same type. The self receiver (self, &self, &mut self) resolves to the enclosing impl, Self:: and Type:: to an associated function, and a trait's default method resolves through impl Trait for Type when the trait is declared in the same file. Types are declared in Rust — parameters, struct fields and let annotations — so nothing is inferred from an initialiser; Type::new() also resolves through a return type declared as Self.

Two things are deliberately silent. Macros never produce an edge, including the calls written inside them: println!, vec! and format! are macro invocations, and even assert_eq!(build(), 1) yields nothing, because a macro body is an opaque token tree whose contents are not parsed as code. External traits are ignored — to_string(), clone() and into() resolve to nothing, as does any receiver whose type is not declared in the file. A bare helper() never resolves to a method either: Rust has no implicit receiver, so inside impl Gateway a bare submit() is a free function, not self.submit.

A return type only propagates within one file. srv := NewServer() resolves when NewServer is declared in the same file as the call. A constructor imported from elsewhere does not carry its type across, so srv.Start() emits nothing there. An explicit type — a var declaration, a let x: T annotation, a parameter or a field — always resolves, cross-file included. Rust is the one place a wrapper is deliberately not unwrapped: Option is an Option, and e.run() on it does not compile, so binding through it would invent an edge the compiler rejects. Go's (T, error) is destructured at the assignment, so it binds.

Without the ts extra, TypeScript falls back to regex, which blanks comments and string literals before scanning and resolves everything above except methods inherited from a base class. Without the java extra, Java falls back to regex, which resolves everything above, including static imports across files. Without the rust extra, Rust falls back to regex, which also resolves everything above: across 600 files from crates.io the two branches agree exactly on 589 of them. Every regex fallback is anchored on declaration lines, so two declarations sharing a single line leave the second one unseen. The remaining 11 languages still emit contains and imports_from only.

Incremental re-indexing with --smart

Re-parsing every file after a two-line edit is wasted work. Every graph slurp index writes carries a manifest — the files it indexed, with stat and content hash — and --smart compares it with the disk: no git needed. Only the files whose content changed are re-parsed.

slurp index . --smart Real output with v1.2.0 on a git checkout of slurp's own source, after a comment was added inside fit_to_budget in slurp/budget.py:

Indexing /path/to/slurp (smart mode) ... → Detected 1 changed file since the graph was built ✓ Updated 32 nodes · 54 edges in 0.1s Full index would take: ~0.3s (2× faster) Saved: /path/to/slurp/graphify-out/graph.json Next: slurp "your query" --graph /path/to/slurp/graphify-out/graph.json The result is always the graph a full index would build. Cross-file call resolution reads symbols from every file, so an edit that adds, removes or renames a file or a definition — or changes a file's imports — can change how other files resolve their calls. Those edits run a full index instead, and say why:

Real output with v1.2.0, after a new function was appended to the same file:

A graph written by slurp ≤ 1.2 has no manifest: for it --smart asks git what changed since the commit the graph was built from (built_at_commit) — committed, staged, unstaged and untracked — plus any file modified after the graph was written, and falls back to a full index without a repository or a recorded commit. The rewritten graph carries a manifest from then on.

--dry-run lists the files it would touch and exits without writing:

slurp index . --smart --dry-run It also runs a full index when there is no existing graph to update.

Keeping the graph current with --watch

slurp index . --watch After indexing, --watch checks the manifest every second and refreshes once a whole second passes with nothing else changing — so a save that writes twice, or a git checkout of a hundred files, is one refresh. New, deleted and renamed files and .slurpignore changes are all seen; skipped directories (node_modules/ and the rest) never wake it. It prints one line per refresh — ↻ 1 file changed (lib/util.py) — smart update in 0.1s — and stops with Ctrl+C. It needs no file-system events and no extra package (watchdog is no longer a dependency).

You only need it for tools that read graph.json outside slurp: the MCP server and the query commands keep the graph current on their own (see Keeping the graph current).

⚠️ Kotlin: the tree-sitter-kotlin grammar has known parsing issues — it fails on a class with a body followed by an object declaration, which is ordinary Kotlin. Slurp detects the broken parse tree and the regex fallback is active in practice. The extra is still declared so a fixed grammar release takes effect without a code change.

Every tree-sitter language falls back to a regex parser when its grammar is not installed. The fallback extracts strictly less — it cannot nest inner classes or reach into method bodies — so slurp index always prints which parser it used. Real output, v1.5.1 on PrismaStats without the ts extra (with it, the same project indexes to 1638 nodes and 2285 edges):

✓ 1577 nodes · 2114 edges · 185 files Parsers: Python (ast) · TypeScript (regex fallback) Install the 'ts' extra for full TypeScript support: pip install "slurp-graph[ts]" uv tool install "slurp-graph[ts]" uv tool install replaces the extras installed before: name every extra you use in one command, as in "slurp-graph[ts,java]". Python needs no extra (it uses the standard library). Go, Lua, Elixir and PowerShell are indexed by regex as their primary parser — no grammar is wired up for them, so their regex parser is the design rather than a degradation and is never reported as a fallback.

Install an extra with the tool you installed slurp with. pip adds it to what is already installed; uv tool install replaces the extras of the earlier install, so name every extra you want in one command: uv tool install "slurp-graph[ts,java]".

Each language records what matters for navigating that ecosystem: Java and C# annotations/attributes (@Service, [HttpGet]) plus access modifiers, Rust lifetimes and pub visibility, Ruby class methods and accessors, PHP magic methods (__get, __call), Kotlin data/sealed/suspend and extension receivers, Scala case classes and implicit, Swift computed properties and async. Relationships become typed edges — calls, renders (a JSX usage of a component), extends, implements (including Rust's impl Trait for Type), with (Scala), conforms_to (Swift), and mixin for Ruby's include/extend/prepend and PHP's trait use, Elixir's use/import/alias/require, and PowerShell's requires.

Broken-grammar guard. A tree-sitter grammar that returns a parse tree containing ERROR nodes silently drops whole declarations. Slurp checks for that after every parse and treats it as a parser failure: it warns on stderr and falls back to regex, which extracts less per declaration but does not lose most of the file.

After indexing, the full query pipeline works as usual:

slurp "auth flow" --graph graphify-out/graph.json --budget 4000 Keeping the graph current

slurp's own graph follows the working tree. Before every answer — each MCP call, and slurp QUERY, export, explain, impact, stats and advisor in the terminal — slurp checks whether any file changed since the graph was built, and if one did it refreshes the graph before answering: edits, new, deleted and renamed files and .slurpignore changes included, uncommitted work too. The answer is the one a full index would give.

The check costs a few stat calls. Every graph slurp writes carries a manifest (a top-level "slurp" key in graph.json): the files it indexed with their size, mtime and a content hash, and the mtime of every directory it walked. A file is read only when its stat moved; a touch or an identical rewrite changes nothing. Measured on throwaway copies: 0.4 ms per call on PrismaStats (185 files), 0.2 ms on slurp's own source.

A refresh takes the fast path when it can. An edit inside function bodies re-parses only that file (30 ms on PrismaStats, 84 ms on slurp); anything else runs a full index (0.29 s and 0.59 s). Without git: the manifest is enough.

A call waits at most 2 seconds for a refresh. Past that it is answered from the previous graph, with a warning first in the answer (over MCP) or on stderr (in the terminal), and the refresh goes on; the next call gets the new graph. In the terminal the command finishes the refresh before it exits — finishing graph refresh… (Ctrl+C to skip; the graph stays as it was).

--refresh-timeout S (or SLURP_REFRESH_TIMEOUT) changes the limit; 0 never waits. --no-refresh (or SLURP_REFRESH=0) turns refreshing off — slurp still checks, and warns when the graph is out of date. For the MCP server, set them in the env block of .mcp.json or in its args.

slurp benchmark and slurp eval never refresh: a measurement needs a fixed graph. They warn on stderr when it is out of date. slurp diff reads the two files you give it.

Graphs slurp did not build are read-only. graphify's graph — or any graph without the manifest — is served as it is, never rewritten and never locked. When files it covers changed after it was built, answers say so: 2 files this graph covers changed after it was built; slurp doesn't rebuild graphify graphs — rerun graphify. A graph written by slurp ≤ 1.2 is adopted (one full index writes its manifest) when nine in ten of its files exist under the project; otherwise it is read-only too, and slurp index once fixes that.

Writing is safe. A new graph is written to a temporary file next to the old one and moved into place, so a reader sees one graph or the other, never half of one; a writer whose graph changed under it (graphify, another slurp) drops its result and reloads instead of overwriting. An advisory lock (.graph.json.lock beside the graph, never deleted) keeps two slurp processes from indexing the same project at once; slurp index run by hand waits for it.

The state of the graph behind each MCP answer is also in its _meta, under dev.imjuank.slurp/graph: status (fresh, refreshed, stale, failed or readonly), refresh_ms and changed_files. .slurp/audit.jsonl and the session log record the same status.

Slurp is the query layer for graphify. Run graphify on your codebase, point slurp at the output.

graphify . # generates graphify-out/graph.json slurp "auth flow" --budget 4000 # auto-discovers graphify-out/graph.json Supported node fields:

{ "id": "authenticate_user", "label": "authenticate_user", "type": "function", "description": "Validates credentials and returns JWT.", "importance": 9, "source_file": "src/auth/service.py", "source_location": "L42" } slurp never rebuilds or rewrites graphify's graph: it is served read-only, and answers say when files it covers changed after it was built. For a graph that keeps up with your edits, let slurp init build slurp's own beside it (graphify-out/slurp-graph.json) — see Keeping the graph current.

The type, description, importance, source_file, and source_location fields are optional but improve scoring and enable --inject-code. Any graph with id + label on nodes and source/target on edges will work.

Both links (graphify/NetworkX serialization) and edges are supported. Additional formats are auto-detected by extension:

Use slurp convert or the convert_graph() API to export between formats.

Run slurp as an MCP server so Claude Code (or any MCP-compatible agent) can query the graph directly.

.mcp.json — for global installs (uv tool install, pipx, pip):

{ "mcpServers": { "slurp": { "command": "slurp", "args": ["serve", "--graph", "/absolute/path/to/graphify-out/graph.json"] } } } .mcp.json — if you installed with uv add inside a Python project:

{ "mcpServers": { "slurp": { "command": "uv", "args": ["run", "slurp", "serve", "--graph", "graphify-out/graph.json"] } } } Windows: Use forward slashes or escaped backslashes in the graph path: "C:/Users/you/project/graphify-out/graph.json". If slurp isn't found, replace "command": "slurp" with the full path — find it with where slurp (CMD) or Get-Command slurp | Select-Object Source (PowerShell).

Five tools exposed. Claude Code calls them automatically, each answering a different question. The server runs over stdio and returns formatted markdown — no HTTP, no ports. slurp_query always answers in markdown, with budget 4000 unless the client asks for another. Its description and the server's instructions tell the agent that the default answers architecture questions and that pinning down one specific function in a large project needs 16000–32000; see Choosing a budget.

All five are declared readOnlyHint and idempotentHint. Claude Code uses those hints to run the calls in parallel and to retry them after a reconnection, not to approve them; Codex does count them: with default_tools_approval_mode = "writes" it does not ask about read-only tools. They stay read-only although a call may refresh graph.json — a cache derived from the code, never the code. slurp_explain reads the same graph slurp_query serves, so the two never answer from different snapshots in one session.

No approvals. slurp init writes what Claude Code needs to call the tools without asking: the project server enabled (enabledMcpjsonServers) and mcp__slurp__* allowed, in .claude/settings.local.json. Without it Claude Code asks once for the server and before each call unless you answer "don't ask again".

When to call which tool. The server's instructions — what Claude Code and Codex read before the first call — say when to reach for slurp before grep, and which tool fits which moment: slurp_query when starting a task, slurp_impact before editing a file, slurp_explain before changing a function. Each tool's description says the same from its side; slurp_query is marked anthropic/alwaysLoad, so with tool search on its description is there from the start. With graphify's graph the texts say slurp does not rebuild it.

Protocol versions. The server answers initialize with the revision the client asks for when it speaks it — 2025-11-25, 2025-06-18, 2025-03-26 or 2024-11-05 — and with 2025-11-25 otherwise. A client of revision 2026-07-28 names it in each request and is served without a session (server/discover answers too). From 2025-11-25 on, invalid arguments — a negative budget, a missing query, a budget too small for one node — come back as a tool error (isError: true) the model can read and correct; earlier revisions get JSON-RPC -32602, as an unknown tool always does.

The graph is current. Before each call the server checks the working tree and refreshes slurp's own graph if something changed (see Keeping the graph current); the check runs in the background at startup and never holds initialize. slurp serve takes --no-refresh and --refresh-timeout, or SLURP_REFRESH / SLURP_REFRESH_TIMEOUT in the env block.

A failure inside a tool comes back as isError: true with a readable message; it never takes the server down, and the next call still works.

Exclude nodes by type, file path, or ID pattern. Create .slurpignore in your project root:

# Exclude documentation nodes type:document type:markdown # Exclude test files file:tests/** file:**/*.test.ts # Exclude generated code id:generated_* Pass a custom path with --ignore-file path/to/.slurpignore.

Power-iteration PageRank without numpy. nx.pagerank() requires numpy. Slurp implements a 20-line pure-Python power-iteration algorithm (convergence: Σ|rank_new − rank_old| < N × tol). Same result, no heavy dependency.

TF-IDF without scikit-learn. Hand-rolled TF-IDF with smoothed IDF (log((N+1)/(df+1)) + 1) and cosine similarity. The tokenizer splits camelCase and snake_case, so authenticate_user scores on both authenticate and user. The score_nodes() interface is backend-agnostic — swap to real embeddings with --backend openai without touching any caller. (--backend anthropic is refused since v1.0.7, and score_nodes(backend="anthropic") raises a ValueError since v1.1.0: Anthropic offers no embedding model, and its docs point to Voyage AI.)

A ranking that reads paths and follows the query (v1.4). The semantic part compares the query with a node's name and also with the terms of its file path and of the class or module that holds it (generic ones such as src, lib or index left out), at the name's weight. The structural part is a PageRank personalised on the query: a walk that restarts at the ten best production matches and follows calls (and, since v1.5, renders) and contains both ways, computed by local push so that it only touches their neighbourhood. A query that matches nothing keeps the global PageRank. Chosen on 1,525 questions from commit history and validated once on six projects it was not chosen on — see Upgrading to v1.4.0.

YAML serializer without PyYAML. _yaml_scalar() renders Python primitives as valid YAML scalars using json.dumps() for strings that need quoting (JSON string literals are valid YAML 1.1). No PyYAML dependency.

lru_cache on the tiktoken encoder. tiktoken.get_encoding() reads tokenizer data from disk on first call. Caching with lru_cache(maxsize=8) means repeated token-counting calls within a single run hit memory, not disk.

+0.3 score boost for file_type == "code" nodes (clamped to 1.0). Documentation nodes compete unfairly with code in technical queries. The boost is bounded so it cannot override a genuinely high structural+semantic score.

--inject-code capped at 30 nodes. Code blocks are 50–200 tokens each. At 30 nodes, that's up to 6,000 extra tokens — manageable. At 200 nodes it would explode the context budget. The cap is enforced in both the CLI (warning message) and inject_code() (hard guard), so the formatter never receives oversized input.

✅ v0.1.0 — loader, scorer, budget, formatter, audit — core pipeline, full tests, slurp QUERY + slurp stats

✅ v0.2.0 — --explain, .slurpignore, --viz interactive HTML, --min-score, camelCase/snake_case tokenizer, --neighbor-decay

✅ v0.3.0 — slurp serve (MCP stdio), slurp diff, slurp export (claude/chatgpt/claudemd), PyPI publish as slurp-graph

✅ v0.4.0 — --backend openai|anthropic (optional embeddings), slurp benchmark, GraphML + Neo4j CSV loader, convert_graph()

✅ v0.5.0 — --inject-code: extract real function bodies from source files and embed them in the context output

✅ v0.6.0 — slurp index .: standalone static indexer (Python ast, TypeScript/JS, Go) — graphify is now optional

✅ v0.6.1 — slurp init: guided one-command setup — language detection, indexing and MCP config in one step

✅ v0.6.2 — slurp benchmark cost estimation in USD per model, --price-model

✅ v0.6.3 — --viz-output: save the interactive HTML to a file without opening a browser

✅ v0.6.4 — MCP session log, slurp session, --log — every query the server answered, on the record

✅ v0.6.5 — slurp diff impact headline, "what to review" section, CLI summary panel

✅ v0.7.0 — MCP performance: 8.1× faster end-to-end, PageRank and token caches, deterministic greedy heap, auto-reload on a stale graph

✅ v0.8.0 — 16-language indexer (Java, Rust, C#, Ruby, PHP, Kotlin, Scala, Swift, C, C++, Lua, Elixir, PowerShell), _BaseVisitor refactor, broken-tree guard on every grammar

✅ v0.8.1 — premium --viz redesign: type colors, glow, smart label inference, quiet nodes, legend, project panel

✅ v0.9.0 — slurp index --smart (git-aware incremental, 21× faster), slurp advisor, multi-graph federation, sdist 98.7% smaller

✅ v0.9.1 — slurp explain: LLM node explanations across 4 providers with a structural fallback, slurp config

✅ v0.9.2 — Python call graph: calls edges between functions, real risk levels in slurp explain

✅ v0.9.3 — TypeScript/JavaScript call graph, tree-sitter with a regex fallback

✅ v0.9.4 — Python and TypeScript/JavaScript cross-file call resolution — imports followed to the real definition

✅ v0.9.5 — slurp eval: LLM-judge quality benchmark, 5× better quality per token

✅ v0.9.6 — Go call graph: receiver methods, struct initialisers, package-local resolution

✅ v0.9.7 — Java and Rust call graphs: DI fields and super/this/static for Java, impl blocks, self receiver and trait resolution for Rust

✅ v0.9.8 — Java and Rust cross-file call resolution: static and wildcard imports, use crate::/super::, multi-symbol and glob imports

✅ v0.9.9 — Go cross-file call resolution: package aliases, dot imports, package main excluded — all five call-graph languages now resolve across files

✅ v1.0.0 — Production release: complete call graph for Python, TypeScript/JS, Go, Java and Rust with cross-file resolution. slurp explain, slurp eval, slurp advisor, slurp init, federation, smart reindex, premium viz.

✅ v1.0.1 — Return type propagation: srv := NewServer() followed by srv.Start() resolves for Go, Rust, Java and TypeScript, within a file

✅ v1.0.2 — Structural slurp explain: architectural role, neighbourhood context, risk as a share of the project, and follow-up commands — 90 lines down to 28

✅ v1.0.3 — MCP gains slurp_explain and slurp_diff

✅ v1.0.4 — --suggest: follow-up queries read off the subgraph's frontier, plus the slurp_suggest MCP tool

✅ v1.0.5 — slurp impact: blast radius of editing a file before you edit it, no second snapshot needed, plus the slurp_impact MCP tool

✅ v1.0.6 — Security patch: an environment API key is never sent to an endpoint from a project's .slurp/config.json; config.json is written 0600 and slurp init adds .slurp/ to .gitignore; --inject-code stays inside the project root; slurp index asks before replacing a graph graphify wrote (--force to skip); the viz works offline (vis-network vendored) and graph text can no longer break its