py-code-visualizer context . --task "describe your task" --budget-tokens 4000
then paste the output into your AI.
Measured on httpx — a real open-source Python project
1,076 functions · 976 call edges · fixed a real bug (NO_PROXY IPv6 handling).
Reproduce: git clone https://github.com/encode/httpx && py-code-visualizer context . --task "..."
| Approach | Tokens | Claude Opus 5 cost | Signal/1k tokens |
|---|---|---|---|
| Feed the full source | 139,697 | $2.10 | 1× |
| Keyword grep (3 matched files) | 24,652 | $0.37 | 6× |
pyvisualizer --task |
~4,000 | $0.06 | 35× |
Costs use publicly listed input-token pricing (~$15/1M for Claude Opus 5). Signal = function-recall per 1,000 tokens; measured by comparing the pack's functions against the functions touched by the actual bug fix.
An AI agent navigating your codebase from scratch re-derives the architecture on every task — paying for thousands of tokens to reconstruct facts it could have looked up, and still getting them wrong. A context pack flips that: the structure is already parsed, every edge is real, and the pack is 97% smaller.
Describe the task. Get a focused pack.
You don't need to know the function name. Describe what you're about to fix — pyvisualizer maps the prose onto seed functions (symbols you name are highest priority, then lexical matches) and expands through the verified call graph:
Every function is real, every call edge is parsed from the AST with a
file:line. Full source is included for top-ranked functions
while the budget allows; the agent opens the cited line for the rest.
Circular dependencies are surfaced automatically.
Already know the function name? Use --focus:
The saving is model-agnostic — the dollar amount scales with price
97% fewer tokens means 97% cheaper context for every model. With frontier models, the absolute savings per task are significant:
| Model | Without pack | With pack | Saved / task | Team of 5 (20 tasks/day/month) |
|---|---|---|---|---|
| Claude Opus 5 | $2.10 | $0.06 | $2.04 | $6,100 / mo |
| Claude Sonnet 5 | $0.42 | $0.01 | $0.41 | $1,200 / mo |
| GPT-4o | $0.70 | $0.02 | $0.68 | $2,000 / mo |
| Gemini 1.5 Pro | $0.17 | $0.005 | $0.17 | $500 / mo |
Input-token cost only, using publicly listed pricing. Full-source cost: 139,697 tokens (httpx baseline). Pack cost: ~4,000 tokens. Output tokens (model response) are the same either way.
Make sure the agent actually uses it
A pack only helps if the agent reaches for it. export
writes the verified graph and injects a section into AGENTS.md — the file
Claude Code, Copilot, and Cursor all read automatically — telling the agent to query
the verified graph before deriving architecture from source.
Wire it into CI with py-code-visualizer export --check so a PR fails if
the committed ground truth goes stale — the agent always reads current facts.
Prefer the agent to query mid-task? Run the MCP server — Claude Code,
Cursor, or any MCP client gets search_code, context_pack, and
impact against the live verified graph:
What you got.
Your agents consume a verified, task-scoped slice of the architecture —
97% smaller than raw source, 35× more signal per token
than reading everything, with a file:line on every fact and not a single
guessed edge. On a team of 5 developers running 20 AI tasks per day, that is
$1,200–$6,100 per month back in your budget depending on your model.
Methodology — how the numbers were measured
Codebase: httpx v0.23.x commit 7d7c4f15 (pre-fix), 60 Python files, 1,076 functions, 976 call edges.
Task: Fix the NO_PROXY IPv6 bug (issue #2660). Ground truth: the 3 functions touched or needed to understand the fix — get_environment_proxies, urlparse, encode_host.
Metric: function-recall-per-1,000-tokens. Recall = (ground-truth functions in pack) ÷ 3. Token count = pack content characters ÷ 4 (standard estimate).
Conditions tested: full source (all .py files), keyword grep (files matching NO_PROXY/IPv6 keywords), pyvisualizer --strategy text (BM25-only), --strategy hybrid (BM25 + graph expansion). Two task descriptions: one naming functions explicitly, one using symptom-level prose only.
Best result: --strategy text, symptom-only description: recall = 1.00, 4,076 tokens, recall/1k = 0.245. All 3 ground-truth functions found.
Reproducibility: Commands are deterministic — same repo, same task, same output every run.
Built by Syed Mohd Haider Rizvi · LinkedIn · Source code