Skip to main content
AI ToolingKnowledge GraphsDeveloper Tools

Graphify: Turning Your Codebase Into a Knowledge Graph

How AST parsing, semantic extraction, and community detection are changing the way AI understands code.

Dhiwin Samrich
Dhiwin SamrichAI/ML Engineer
May 2026·7 min read

The Problem: AI Assistants Are Blind to Your Architecture

You paste a file into Claude or Copilot and ask for help. The AI gives a great answer — for that file. But it has no idea that the function you're modifying is called by 12 other modules, that it shares a Redis connection pool with the auth service, or that the comment at the top is outdated by three refactors. Every AI coding session starts cold. Graphify fixes this.

"The best AI coding assistant is the one that understands your whole system — not just the file you pasted."

What Graphify Actually Does

Graphify is an open-source tool that scans your entire codebase and converts it into an interactive knowledge graph. Not just a dependency tree — a full semantic graph that captures concepts, relationships, design rationale from docs, and cross-module connections that aren't obvious from imports alone.

The Extraction Pipeline

The pipeline runs in two phases. First, Tree-sitter parses all 33+ supported languages locally — no API calls, no code leaving your machine. It extracts functions, classes, types, and their relationships at the AST level.

# Install and run Graphify on your project
uvx graphify scan ./your-project
# Outputs: graphify-out/graph.html, GRAPH_REPORT.md, graph.json

Second, an LLM of your choice (Claude, Gemini, OpenAI, or a local Ollama model) processes your documentation, PDFs, README files, and even images to extract the semantic meaning behind the code.

Community Detection with the Leiden Algorithm

Raw graphs are noise. Graphify applies the Leiden community detection algorithm to partition the graph into thematic clusters — grouping related concepts even when they're spread across different directories or modules. It also surfaces "god nodes": highly-connected concepts that are load-bearing for the whole system and usually the first thing that breaks under refactoring.

Key Insight "God nodes" — concepts with the most edges — are almost always the first things that break under a refactor. Graphify surfaces these before you touch a line of code.

The Output: Three Deliverables

Every run produces a graph.html for browser-based interactive exploration, a GRAPH_REPORT.md summarising key insights and suggested queries, and a graph.json that can be queried programmatically or served via an MCP server directly to your AI assistant.

MCP Server Integration

This is the killer feature. Graphify exposes an MCP server that plugs directly into Claude Code, Cursor, Copilot, and 15+ other AI coding assistants. Add this to your ~/.claude/mcp.json:

{
  "mcpServers": {
    "graphify": {
      "command": "uvx",
      "args": ["graphify", "serve", "--graph", "./graphify-out/graph.json"]
    }
  }
}

Instead of pasting files, your AI assistant can now query the graph — asking "what modules depend on the payment service?" and getting structured answers backed by the full codebase.

Why Confidence Scoring Matters

Not every relationship in a codebase is explicit. Graphify tags each edge with a confidence level:

# Edge confidence levels in graph.json
{
  "source": "auth_middleware",
  "target": "redis_client",
  "confidence": "EXTRACTED",   # Directly parsed from AST
  # vs "INFERRED"  — semantically derived
  # vs "AMBIGUOUS" — low confidence, needs review
}
Pro Tip Filter your MCP queries to only EXTRACTED edges when you need certainty. Use INFERRED edges for discovery and exploration.

My Take: The Missing Layer for AI-Assisted Development

The future of AI coding assistance isn't about better models — it's about better context. A developer who knows the whole system will always outperform one who only sees the current file. Graphify gives AI assistants that system-level awareness. For anyone building or maintaining a complex codebase, it's the kind of tooling that fundamentally changes how you work with AI.

Share
Let's Talk-Knight's Gambit-Game On-
Consultant