DS DevShelfHub Projects · AI tools
Articles / Graphify: Turn Any Codebase Into a Queryable Knowledge Graph for AI Coding Assistants

AI Tools

Graphify Explained: The AI Tool That Turns Your Codebase Into a Knowledge Graph

By DevShelfHub

A complete technical research report on Graphify — the Y Combinator S26-backed open-source tool that turns any codebase into a queryable knowledge graph. Covers the full pipeline (tree-sitter AST, Leiden clustering, LLM semantic extraction), all 25+ AI assistant integrations, MCP server, PR triage, callflow-html export, comparison with grep/Sourcegraph/RAG, security model, and a final verdict.

Graphify Explained: The AI Tool That Turns Your Codebase Into a Knowledge Graph

Introduction

There is a gap at the center of every AI-assisted development workflow in 2026. AI coding assistants are remarkably capable at writing code, explaining functions, and fixing bugs — but they are architecturally blind. Ask Claude Code how authentication connects to the database in a 200K-line codebase and it starts grepping files, reading them one at a time, filling its context window, and hoping it lands on the right answer before running out of space.

Graphify ( github.com/safishamsi/graphify, MIT) is the fix. It turns your entire project — code, docs, SQL schemas, PDFs, images, and videos — into a queryable knowledge graph with a single command. Instead of making the AI read files, you give it a pre-built map it can traverse in seconds. It hit 69,000+ GitHub stars in roughly 2.5 months with zero marketing spend, was accepted into Y Combinator S26, and now integrates with 25+ AI coding assistants including Claude Code, Codex, Cursor, Gemini CLI, and GitHub Copilot CLI.

This is a complete technical deep-dive: how it works, what makes it different, when to use it, and what its real limitations are.

Key takeaways

  • /graphify . builds a knowledge graph of your entire project in one command — code, docs, PDFs, images, videos, live databases.
  • Code is extracted locally via tree-sitter (36 grammars, zero API cost). Your source code never leaves your machine.
  • Graph-first beats file-first for AI codebase navigation: pre-computed relationships are faster, cheaper, and richer than real-time file reading.
  • Persistent memorygraph.json survives session resets; AI never rediscovers the same relationships twice.
  • MIT licensed, YC S26 — free forever, institutionally backed, with an enterprise tier for Fortune 500 teams.

The problem: AI coding agents are architecturally blind

Modern AI coding agents use a fundamentally file-centric approach to codebase understanding: they search files, read files, and try to infer relationships from raw text. This works for small projects and simple questions. It breaks down fast at any serious scale.

Why grep and file reading fail AI agents

  • grep finds strings, not relationships. "What services depend on the payment module?" cannot be answered by text search — it requires an edge traversal.
  • Context window costs compound. Sending 500K tokens of codebase per question costs $7.50 at Claude Opus rates — and the model still can't synthesize 500K tokens coherently.
  • Session amnesia. Every new conversation starts from zero. The AI rediscovers the same relationships on every query, burning tokens and time.
  • Multi-file reasoning breaks. LLMs struggle to maintain coherent understanding of relationships across dozens of files read sequentially in a single context window.

The beginner-friendly analogy: imagine joining a huge company where instead of receiving an org chart, you're told to "figure out who reports to whom by reading everyone's emails one at a time." That's what every AI coding agent does with your codebase today. Graphify builds the org chart first.

What Graphify does: one command, a complete map

Run /graphify . inside your AI assistant and it reads every file in your project, extracts entities and relationships, clusters them with the Leiden algorithm, and produces three output files:

graph.html

Interactive browser visualization. Click nodes, filter by type, search relationships, zoom into communities. Open in any browser — no server needed.

GRAPH_REPORT.md

The curated highlights: god nodes, surprising cross-module connections, extracted design rationale from comments and docstrings, suggested questions.

graph.json

The full queryable graph. Your AI assistant queries this instead of re-reading raw files. Persistent across sessions — no more rediscovery.

Then query it directly:

/graphify query "what connects auth to the database?"
/graphify path "UserService" "DatabasePool"
/graphify explain "RateLimiter"

This is the shift from file-first navigation (search files, read files, infer relationships) to graph-first navigation (query pre-built relationships directly). It's the difference between a search engine that reads every web page fresh for every query vs. one that has already indexed the web.

How Graphify works: the pipeline

1

Input ingestion

Graphify accepts any mix of code files, documentation, PDFs, images, videos, database DSNs, and YouTube links. It merges .gitignore and .graphifyignore to determine what to process, then fans out extraction tasks to parallel workers.

2

AST parsing via tree-sitter (local, zero API cost)

For all 36 supported code languages, tree-sitter runs locally. Every function definition, class declaration, import statement, and function call is captured as structured data. Your source code never leaves your machine during this step.

3

Semantic extraction via LLM (docs, PDFs, images, video)

Non-code content routes through your configured AI backend. Graphify supports 14 backends: Gemini, Claude, OpenAI, DeepSeek, Kimi, AWS Bedrock (IAM), Azure OpenAI, and Ollama for fully offline operation. Video/audio is transcribed locally via faster-whisper before going to the LLM.

4

Node and edge creation with confidence tags

Every entity becomes a node; every relationship becomes a typed edge. Critically, each edge is tagged: EXTRACTED (AST-based, deterministic), INFERRED (LLM-based, probabilistic), or AMBIGUOUS (uncertain). You always know what was found vs. guessed.

5

Leiden clustering (community detection)

The Leiden algorithm (an improvement over Louvain) groups nodes into natural communities — the auth cluster, payment cluster, user management cluster — even when the code doesn't organize itself that way. It also surfaces god nodes: the most-connected concepts everything flows through.

6

Output generation

Three primary outputs (graph.html, GRAPH_REPORT.md, graph.json) plus optional exports: Obsidian vault, Markdown wiki, Mermaid call-flow HTML, Neo4j Cypher, GraphML, and SVG.

Codebase / Docs / Media / DBs
        │
        ├─── Tree-sitter AST Parser (local · no API cost)
        │         ↓
        └─── LLM Semantic Extractor (docs · PDFs · images · video)
                  ↓
          Graph Builder (nodes + edges + confidence tags)
                  ↓
          Leiden Clustering Engine (community detection · god nodes)
                  ↓
        ┌─────────────────────────────────────┐
        │  graph.json   graph.html   REPORT   │
        │  callflow-html  wiki  Neo4j  SVG    │
        └─────────────────────────────────────┘
                  ↓                ↓
        MCP Server              CLI Queries
    (query_graph, path,    (graphify query/path/explain)
     triage_prs, …)

Supported input formats

Category Details Extracted via
CodePython, TS, JS, Go, Rust, Java, C/C++, Ruby, C#, Kotlin, Scala, PHP, Swift, Lua, Zig, Elixir, Julia, Dart, Fortran, Pascal, SQL, Shell, Vue, Svelte, Astro, Groovy, PowerShell, + more (36 grammars)tree-sitter (local, free)
Structured dataSQL schemas, Terraform/HCL, MCP configs, pyproject.toml, go.mod, pom.xml, apm.yml. Also: live PostgreSQL via --postgres DSN, Salesforce Apex (.cls, .trigger)tree-sitter + regex (local)
DocumentationMarkdown, MDX, QMD, HTML, TXT, RST, YAML — wikilinks and cross-file links become graph edgesLLM API
Office / Google.docx, .xlsx (requires [office] extra); Google Docs/Sheets/Slides (requires gws auth + --google-workspace)LLM API
PDFsFull text extraction and semantic analysis (requires [pdf] extra)LLM API
ImagesPNG, JPG, WebP, GIF — described and linked to related code conceptsLLM API
Video / AudioMP4, MOV, MP3, WAV — transcribed locally via faster-whisper, then semantically analyzed. YouTube URLs supported.faster-whisper (local) → LLM
PapersArXiv URLs: /graphify add https://arxiv.org/abs/1706.03762LLM API

Core components deep dive

Graph Builder

The Graph Builder merges AST parser and LLM extractor output into a unified graph. Every entity becomes a node with a unique ID, type, file location, confidence tag, and optional rationale text. Every relationship becomes a typed, directional edge: calls, imports, references, depends_on, explains, related_to. Two graphs from different repos merge cleanly: graphify merge-graphs a.json b.json.

Semantic Extraction Layer

Handles everything tree-sitter cannot: natural language, images, audio, and inferring conceptual relationships between code and documentation. Training the LLM with --mode deep extracts more edges at higher API cost. Semantic relationships are always tagged INFERRED so you know what was discovered vs. computed.

A unique "Why" extraction: inline comments (# NOTE:, # WHY:, # HACK:), docstrings, and design rationale from docs become separate explanation nodes linked to the code they describe — giving the AI access to the developer intent behind each component.

Leiden Clustering Engine

The Leiden algorithm (an improvement over Louvain) produces three critical outputs:

  • Community clusters — groups of tightly-coupled components. In a web app: "auth cluster", "payment cluster", "user management cluster" — even when the code doesn't organize this way by folder structure.
  • God nodes — concepts with extremely high betweenness centrality that everything flows through. In most codebases: config objects, base classes, utility modules, shared data models. Knowing your god nodes tells you what to protect during refactors.
  • Surprising connections — edges between nodes in different clusters you wouldn't expect: hidden coupling, violation of module boundaries, or undocumented cross-concerns.

Tuning: --resolution 1.5 (finer clusters) · --resolution 0.5 (coarser) · --exclude-hubs 99 (suppress top 1% super-hubs) · --cluster-only (re-cluster without re-extracting)

Query Engine

# Natural language graph search
graphify query "what connects auth to the database?"
graphify query "show all services that depend on UserSession"

# Shortest path between two named entities
graphify path "UserService" "DatabasePool"
graphify path "APIGateway" "PaymentProcessor"

# Full context for a node — purpose, relationships, community, rationale
graphify explain "RateLimiter"
graphify explain "AuthMiddleware"

# Direct graph file queries (headless / CI)
graphify query "auth flow" --graph graphify-out/graph.json

MCP server integration

Graphify exposes the knowledge graph as a Model Context Protocol (MCP) server — the open standard for AI assistant tool access. Any MCP-compatible client can call into the graph with structured parameters and receive structured JSON responses.

# Local server (one per developer, stdio transport)
python -m graphify.serve graphify-out/graph.json

# Team-shared HTTP server (everyone points at one URL)
python -m graphify.serve graphify-out/graph.json \
  --transport http --host 0.0.0.0 --api-key "$SECRET" --port 8080

# Docker deployment
docker run -p 8080:8080 -v "$(pwd)/graphify-out:/data" graphify \
  /data/graph.json --transport http --host 0.0.0.0 --api-key "$SECRET"
MCP Tool Description
query_graphNatural language search across the entire graph
get_nodeRetrieve full metadata for a specific named entity
get_neighborsList all nodes directly connected to a given node
shortest_pathFind the shortest edge path between two named nodes
list_prsOpen pull requests with CI state and graph impact score
get_pr_impactWhich graph nodes are touched by a specific PR
triage_prsAI-ranked PR review queue sorted by complexity and risk

Supported AI platforms (25+)

Platform Support Install command Notes
Claude Code★★★★★ Fullgraphify installPreToolUse hooks fire before file reads
Codex (OpenAI)★★★★★ Fullgraphify install --platform codexUse $graphify not /graphify
Gemini CLI★★★★★ Fullgraphify gemini installPreToolUse hooks like Claude Code
Cursor★★★★☆ Stronggraphify cursor install.cursor/rules/ alwaysApply
GitHub Copilot CLI★★★☆☆ Goodgraphify install --platform copilotAGENTS.md instructions
VS Code Copilot Chat★★★★☆ Stronggraphify vscode installVia VS Code extension config
Kilo Code★★★★☆ Stronggraphify kilo installNative /graphify command + plugin
Aider★★★☆☆ Goodgraphify aider installSequential extraction
OpenClaw★★★☆☆ Goodgraphify claw installAGENTS.md instructions
Devin CLI★★★☆☆ Goodgraphify devin installDedicated install
Trae / Trae CN★★★☆☆ Goodgraphify trae installNo PreToolUse hooks; AGENTS.md

Installation and quick start

Requires Python 3.10+ and uv (recommended).

Step 1 — Install the package

# ⚠️  PyPI package is graphifyy (double-y). CLI command is still "graphify".
uv tool install graphifyy

# With all extras (PDF, video, MCP server, Neo4j, etc.)
uv tool install "graphifyy[all]"

# Granular extras
uv tool install "graphifyy[pdf,video,mcp]"

Step 2 — Register the skill with your AI assistant

graphify install          # auto-detects platform
graphify cursor install   # Cursor specifically
graphify gemini install   # Gemini CLI
graphify install --platform codex  # Codex

Step 3 — Build the graph and query it

cd ~/your-project

# Build the knowledge graph
/graphify .

# Open the visualization
open graphify-out/graph.html

# Query the graph
/graphify query "how does authentication work?"
/graphify query "what are the most important components?"
/graphify explain "PaymentProcessor"

# Set up auto-rebuild on every git commit (AST only, zero API cost)
graphify hook install

# Generate living architecture documentation
graphify export callflow-html

Add external content to the graph

# Add a research paper
/graphify add https://arxiv.org/abs/1706.03762

# Add a YouTube video (architecture walkthrough, conference talk)
/graphify add https://youtube.com/watch?v=...

# Add a live PostgreSQL schema
graphify extract . --postgres "postgresql://user:pass@host/db"

# Re-extract only changed files (fast incremental update)
/graphify . --update

Real workflow: debugging a production issue

Scenario: The error says NullPointerException in EnterpriseSessionValidator:127. Enterprise users can't pay. Standard users are fine.

Without Graphify

  1. Claude runs grep → 12 references across files
  2. Reads 4 files to understand the class
  3. Context window fills, stops reading
  4. Gives a partial answer
  5. 8–10 back-and-forth exchanges
  6. 15 minutes · $2–5 in tokens

With Graphify

  1. /graphify explain "EnterpriseSessionValidator" → purpose, 8 callers, 3 deps
  2. Notice EnterpriseLicenseChecker in the deps
  3. /graphify path "PaymentController" "LicenseDatabase" → full call chain
  4. Bug identified: caching issue for enterprise accounts updated within 24h
  5. 3 queries · 2 minutes · <$0.10

Graphify vs. alternatives

Tool Approach Strength Weakness
grep / ripgrepText pattern searchFast, universal, zero setupNo semantic understanding, returns raw text not relationships
SourcegraphCode intelligence platformProduction-grade, scales to huge orgsSaaS pricing, no knowledge graph, no AI assistant integration
Cursor indexingEmbedding-based semantic searchSeamlessly integrated in IDECursor-only, stateless, no relationship graph, no export
LLM file readingSending full files to LLMAccurate for small codebasesExpensive at scale, stateless, context window limits
Traditional RAGVector similarity retrievalGood for document Q&AReturns text fragments not relationships, poor at "what connects X to Y?"
GraphifyPre-computed knowledge graphLocal-first, 25+ integrations, multi-format, persistent, MCP server, PR analysisSetup time, LLM cost for non-code, learning curve

The fundamental difference: grep finds files; Sourcegraph finds code; RAG finds text fragments. Graphify finds relationships — and persists them so every subsequent question is cheaper and more accurate.

Pros and cons

Advantages

  • +Graph-first navigation — pre-computed relationships, not real-time file reading
  • +Persistent memory across sessions — no more rediscovery
  • +Code extracted locally via tree-sitter — zero API cost, zero data egress
  • +Multi-modal: code + docs + PDFs + images + video + live DBs in one graph
  • +25+ AI assistant integrations — works with your existing toolchain
  • +MCP server for structured programmatic access
  • +Git-committable graph for team knowledge sharing
  • +Confidence-tagged edges (EXTRACTED / INFERRED / AMBIGUOUS)
  • +PR graph-impact analysis and AI-ranked triage
  • +MIT licensed, 14 AI backends, fully offline via Ollama

Limitations

  • Initial graph generation for large doc-heavy repos takes significant time and API cost
  • PyPI naming confusion (graphifyy double-y) creates installation friction
  • Very large graph.html files become slow in the browser — use CLI queries instead
  • LLM dependency for semantic extraction of non-code content
  • Leiden extra only available for Python < 3.13 (fallback clustering for 3.13+)
  • PowerShell requires graphify . not /graphify . — minor Windows friction
  • Query learning curve — users default to file reading out of habit
  • Some platform integrations (Trae, Aider, OpenClaw) still maturing

Security and privacy

What stays local

  • All source code (AST extraction via tree-sitter)
  • SQL schemas, Terraform, package manifests
  • Video/audio transcription (faster-whisper, local)
  • No telemetry, no usage tracking
  • Query logs optional (GRAPHIFY_QUERY_LOG_DISABLE=1)

What routes through AI APIs

  • Documentation (Markdown, HTML, RST)
  • PDFs, Office documents
  • Images (PNG, JPG, WebP)
  • Video transcripts (after local transcription)
  • Always uses your chosen AI backend — no Graphify cloud

For fully offline operation, combine Ollama local inference with tree-sitter AST extraction: zero network traffic during the entire graph build. For air-gapped environments, AWS Bedrock (IAM-based) requires no API key.

Frequently asked questions

What exactly does /graphify . produce?
Three files in graphify-out/: graph.html (interactive browser visualization), GRAPH_REPORT.md (god nodes, surprising connections, suggested questions), and graph.json (the full queryable graph your AI assistant uses instead of re-reading raw files). Optional: callflow-html, wiki, Obsidian vault, Neo4j Cypher export.
Do I need an API key to use Graphify?
For code files — no. Tree-sitter extraction is entirely local. For non-code content (docs, PDFs, images, videos) you need an API key for your chosen backend. With Ollama you can run everything offline for free. When running via your IDE's AI session, the IDE's existing model connection is used — no extra keys needed.
Why is the PyPI package "graphifyy" with two y's?
The name graphify was already taken on PyPI by an unaffiliated package. The CLI command is still just graphify — you only see the double-y when running uv tool install graphifyy. The README warns: "Other graphify* packages on PyPI are not affiliated."
What is a "god node" and why does it matter?
A god node is a concept in the graph with extremely high betweenness centrality — many other nodes depend on it. In most codebases: config objects, base classes, DatabasePool, AuthMiddleware. Knowing your god nodes tells you what to protect during refactors, where to focus documentation, and which components create the most architectural coupling.
Can I commit graphify-out/ to git?
Yes — and it's encouraged. The README recommends committing graphify-out/ (excluding cost.json) so the entire team benefits from the graph without everyone needing to build it. A dedicated git merge driver prevents conflict markers when multiple developers commit changes simultaneously.
How does --update work for incremental rebuilds?
Graphify maintains a manifest of processed files with checksums. --update compares file modification times against the manifest, re-extracts only changed or new files, and patches the graph. graphify hook install sets up a post-commit git hook that runs AST-only incremental updates automatically on every commit with zero API cost.
How does graphify prs --triage work?
Graphify fetches open PRs, computes the set of graph nodes each PR touches (via get_pr_impact), then uses your configured AI backend to rank them by complexity (how many god nodes touched), risk (changes to high-centrality components), and conflict likelihood (PRs sharing graph communities). The result is an ordered review queue with reasoning.
Can Graphify handle multiple repositories (microservices)?
Yes. Use graphify merge-graphs a.json b.json to combine graphs from multiple repositories into one unified knowledge map. Cross-service dependencies become visible as edges between the two subgraphs. Particularly valuable for microservices architectures where understanding cross-service impact is hard.
What is the callflow-html export?
graphify export callflow-html generates an HTML page with Mermaid-rendered call-flow diagrams showing how requests flow through your system — effectively auto-generated architecture documentation. With graphify hook install, it regenerates on every git commit, keeping architecture docs permanently synchronized with the code.
Is there a graph size limit?
Default cap is 512 MiB, configurable via GRAPHIFY_MAX_GRAPH_BYTES=2GB. For very large corpora, use --token-budget to reduce semantic chunk size. For large graphs, prefer CLI queries or the MCP server over the browser visualization.

Final verdict

The big picture

Graphify is building the missing infrastructure layer between AI coding assistants and the codebases they're supposed to understand. The file-centric paradigm that has dominated software development since the 1960s is hitting its ceiling in the agentic AI era. A 50,000-file repo is not meaningfully navigable as a file tree — by humans or by AI agents. Graphify is an early, production-ready demonstration of what comes next: graph-centric coding, where relationships are first-class and pre-computed rather than inferred on-the-fly.

Use Graphify if you…

  • Use Claude Code, Codex, Cursor, or Gemini CLI on repos > 50 files
  • Want to reduce AI token costs on codebase navigation questions
  • Onboard new engineers to complex systems
  • Need living architecture documentation that stays current
  • Work in compliance-sensitive environments (local-first pipeline)
  • Manage multi-repo microservices architectures

Skip it if you…

  • Work on tiny projects (< 20 files) — overhead exceeds benefit
  • Run in restricted sandbox environments (no local process execution)
  • Need zero-setup, immediate value in under 5 minutes
  • Require Python 3.9 or below

Future potential score

9.5 / 10

69,000 GitHub stars in 2.5 months without marketing. Y Combinator S26. MIT licensed. 25+ integrations. The problem it solves (codebase blindness in AI agents) affects every serious AI coding team. The solution is technically sound — tree-sitter, Leiden, MCP, multi-modal, confidence-tagged. The architecture is right for the agentic AI era. The evaluation barrier is one command: /graphify .