Graphify Hands-On: Code Knowledge Graphs for AI Agents Cut Token Use 95%

The author tests Graphify, an open-source tool that builds code knowledge graphs for AI coding agents, on the httpx repository, demonstrating 2-second graph builds, 95% token reduction for navigation queries, and practical limitations like name ambiguity between code and documentation.

DeepHub IMBA
DeepHub IMBA
DeepHub IMBA
Graphify Hands-On: Code Knowledge Graphs for AI Agents Cut Token Use 95%

What Graphify Is

Graphify is an Apache-2.0 licensed open-source Python command-line tool that uses tree-sitter to parse a project and generates three files in a graphify-out/ directory: graph.html — an interactive force-directed graph viewable in a browser. GRAPH_REPORT.md — a summary of "super nodes" (god nodes), community partitions, and surprising connections. graph.json — the full code knowledge graph, queryable via explain, path, and query commands.

Code structure extraction runs locally with a deterministic parsing pipeline. For documents, PDFs, images, video, or naming, the tool can optionally call an LLM (after configuration).

Installation and Test Setup

Test environment: Debian 13 with Python 3. The PyPI package name is graphifyy (two trailing y's):

python3 -m venv venv
venv/bin/pip install graphifyy  # installed 0.9.92
git clone --depth 1 https://github.com/encode/httpx testbed/httpx

The test target is httpx, a popular Python HTTP client with ~17,750 lines of Python code plus docs and changelog — large enough for meaningful analysis, and the author knows some expected answers for verification.

Building the Graph: 2 Seconds, 0 Tokens

Running graphify update . inside the repo builds the graph without any LLM calls:

Re-extracting code files in . (no LLM needed)...
 AST extraction: 101/101 uncached files (100%) [8 workers]
[graphify watch] Rebuilt: 2233 nodes, 4453 edges, 166 communities

First build took 2.1 seconds. After modifying one file, an incremental rebuild took 1.6 seconds. Token cost reported as Token cost: 0 input · 0 output.

Output file sizes: graph.json 1.7 MB, graph.html 1.9 MB, GRAPH_REPORT.md 24 KB. Markdown docs ( CHANGELOG.md, docs/api.md) are also included as nodes.

Report Accuracy

The report's "super nodes" correctly identify httpx core components:

1. Response - 170 edges
2. Request - 111 edges
3. Changelog - 79 edges
4. Client - 69 edges
5. AsyncClient - 51 edges
6. BaseClient - 45 edges

88% of edges are labeled EXTRACTED (directly from source), 12% INFERRED (inferred, average confidence 0.91). Every edge carries a source type so users can distinguish extracted vs. inferred relationships. The "surprising connections" section adds little value — it merely lists changelog entries or doc titles linked to Client, which are expected associations.

Querying: Where Token Savings Come From

Using tiktoken's cl100k encoding, the author measured three queries:

graphify explain "httpx/_client.py::Client"
graphify path "httpx/_client.py::Client" "DigestAuth"
graphify query "how does a request get sent through the transport"

explain on Client: 628 tokens, listing 69 associations with file paths and line numbers (e.g., --> HTTPTransport [uses] [INFERRED] httpx/_client.py:L731). Reading the full _client.py would cost 13,659 tokens.

path between Client and DigestAuth: single-line output showing a three-edge path:

Client <-contains- _client.py -imports_from-> _auth.py -contains-> DigestAuth

.

query (natural language): 1,728 tokens. BFS finds 536 nodes, displays 82, with a TRUNCATED notice; full results require --budget 14720.

For "where is X and what relates to it" questions, graph queries consume ~1/20th the tokens of reading entire files. However, modifying a function still requires opening the source file because the graph only points to locations, it does not contain the code content itself.

Friction Points

Name ambiguity. Running graphify explain "Client" fails because Client matches both the class in httpx/_client.py and a heading in docs/api.md. The error suggests using path::symbol format (e.g., httpx/_client.py::Client), which works. Shared indexing of code and docs makes common names prone to collisions.

Worth Installing?

For code-centric workflows, Graphify is worth trying: free, runs locally, builds graphs in seconds. Before an agent opens source files, it can use explain and path to locate relevant modules and their connections, cutting initial navigation token overhead. The graphify update . command can even be added to a Git hook so agents query the graph first, then read source code.

Project repository:

github.com/Graphify-Labs/graphify
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

knowledge graphTree-Sittercode-navigationhttpxtoken optimizationAI coding agentsgraphifypython-tool
DeepHub IMBA
Written by

DeepHub IMBA

A must‑follow public account sharing practical AI insights. Follow now. internet + machine learning + big data + architecture = IMBA

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.