DEV Community

Cover image for Graphify: Transform Your Codebase Into a Queryable Knowledge Graph and Save AI Tokens
sizan mahmud0
sizan mahmud0

Posted on

Graphify: Transform Your Codebase Into a Queryable Knowledge Graph and Save AI Tokens

The Ultimate Guide to Using Graphify with Claude Code, Cursor, Copilot, and 15+ AI Coding Assistants

Are you tired of burning through API tokens every time your AI coding assistant re-reads your entire codebase? Meet Graphify — the open-source tool that maps your project into an intelligent knowledge graph, helping AI agents understand your code structure instantly without expensive token waste.

With over 41,600 GitHub stars and 4,600 forks, Graphify has become the go-to solution for developers looking to optimize their AI-assisted coding workflow while drastically reducing costs.


What Is Graphify?

Graphify is a Python-based tool that analyzes your entire project — including code, documentation, PDFs, images, and even videos — and creates a queryable knowledge graph. Instead of your AI assistant reading through thousands of files repeatedly, it can reference a structured map that shows:

  • Key concepts and their relationships in your codebase
  • God nodes — the most important, interconnected components
  • Surprising connections between disparate modules
  • Design rationale extracted from comments and documentation
  • Confidence-scored relationships (extracted, inferred, or ambiguous)

Think of it as giving your AI coding assistant a photographic memory of your entire project structure.


Why Graphify Saves You Money and Tokens

The Token Problem

Every time you ask your AI assistant about your codebase, it needs context. Without Graphify:

  • Claude Code or Cursor re-reads multiple files to understand relationships
  • GitHub Copilot struggles to grasp cross-module dependencies
  • Aider or OpenCode consume tokens analyzing the same code repeatedly

This costs you real money in API fees and slows down your development workflow.

The Graphify Solution

With Graphify installed:

  1. One-time extraction — Your codebase is analyzed once (code parsing happens locally with no API calls)
  2. Persistent knowledge — The graph is saved as three files your AI can reference instantly
  3. Minimal token usage — Your assistant reads a condensed GRAPH_REPORT.md instead of scanning hundreds of files
  4. Automatic updates — Git hooks can rebuild the graph incrementally when code changes

Result: Up to 90% reduction in token consumption for codebase queries.


How to Install Graphify

Graphify requires Python 3.10 or higher. Installation is straightforward:

# Recommended: Use uv or pipx for clean installation
uv tool install graphifyy && graphify install

# Alternative methods
pipx install graphifyy && graphify install
pip install graphifyy && graphify install
Enter fullscreen mode Exit fullscreen mode

Important: The official PyPI package is graphifyy (double-y), but the CLI command is simply graphify.

Platform-Specific Setup

Graphify works with 15+ AI coding assistants. Choose your platform:

AI Coding Assistant Installation Command
Claude Code (Linux/Mac) graphify install
Claude Code (Windows) graphify install --platform windows
Cursor graphify cursor install
GitHub Copilot CLI graphify install --platform copilot
VS Code Copilot Chat graphify vscode install
Codex graphify install --platform codex
OpenCode graphify install --platform opencode
Aider graphify install --platform aider
Gemini CLI graphify install --platform gemini
OpenClaw graphify install --platform claw
Factory Droid graphify install --platform droid
Trae graphify install --platform trae
Hermes graphify install --platform hermes
Kiro IDE/CLI graphify kiro install
Pi Coding Agent graphify install --platform pi
Google Antigravity graphify antigravity install

Using Graphify with Different AI Agents

With Claude Code

Claude Code has excellent Graphify integration. Simply type:

/graphify .
Enter fullscreen mode Exit fullscreen mode

This creates three essential files in graphify-out/:

  1. graph.html — Interactive visualization (open in browser)
  2. GRAPH_REPORT.md — Human-readable summary with key insights
  3. graph.json — Full graph data for programmatic queries

To make Claude Code automatically reference the graph:

graphify claude install
Enter fullscreen mode Exit fullscreen mode

Now every conversation starts with Claude understanding your project structure.

With Cursor

Cursor users get seamless integration:

/graphify .
graphify cursor install
Enter fullscreen mode Exit fullscreen mode

The graph becomes part of Cursor's context, dramatically improving code suggestions and reducing hallucinations about your codebase.

With GitHub Copilot CLI

graphify install --platform copilot
/graphify .
graphify copilot install
Enter fullscreen mode Exit fullscreen mode

Copilot can now reference the knowledge graph when generating code or answering questions about your project.

With VS Code Copilot Chat

graphify vscode install
/graphify .
Enter fullscreen mode Exit fullscreen mode

Your Copilot Chat now understands the broader context of your codebase without repeatedly analyzing files.

With Aider

Aider works beautifully with Graphify:

graphify install --platform aider
/graphify .
graphify aider install
Enter fullscreen mode Exit fullscreen mode

Aider can now make more intelligent refactoring decisions by understanding how components relate.

With Codex

Codex users need one additional config step:

graphify install --platform codex
Enter fullscreen mode Exit fullscreen mode

Then add this to ~/.codex/config.toml:

[features]
multi_agent = true
Enter fullscreen mode Exit fullscreen mode

In Codex, use $graphify instead of /graphify:

$graphify .
graphify codex install
Enter fullscreen mode Exit fullscreen mode

With Gemini CLI, OpenCode, and Others

The installation pattern is consistent:

# Install for your platform
graphify install --platform [gemini|opencode|claw|droid|trae|hermes|pi]

# Generate the graph
/graphify .

# Enable auto-loading
graphify [platform-name] install
Enter fullscreen mode Exit fullscreen mode

What Files Can Graphify Process?

Graphify supports an impressive range of file types:

Code (25+ Languages)

Python, TypeScript, JavaScript, React, Go, Rust, Java, C, C++, Ruby, C#, Kotlin, Scala, PHP, Swift, Lua, Zig, PowerShell, Elixir, Objective-C, Julia, Vue, Svelte, SQL

Documentation

Markdown, MDX, HTML, plain text, reStructuredText, YAML

Office Documents

Word (.docx), Excel (.xlsx) — requires pip install graphifyy[office]

PDFs

Extracts text and structure from PDF documents

Media

Images (.png, .jpg, .webp, .gif), videos (.mp4, .mov), audio (.mp3, .wav) — requires pip install graphifyy[video]

Web Content

YouTube URLs, arXiv papers, and other web resources

Privacy Note: Code files are processed locally using tree-sitter (no API calls). Documents, PDFs, and images are sent to your AI assistant's API using your own key.


Advanced Graphify Commands

Update Only Changed Files

Save tokens by re-processing only what's changed:

/graphify . --update
Enter fullscreen mode Exit fullscreen mode

Query the Graph Directly

graphify query "what connects authentication to the database?"
graphify path "UserService" "DatabasePool"
graphify explain "RateLimiter"
Enter fullscreen mode Exit fullscreen mode

Add External Resources

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

# Add a YouTube tutorial
/graphify add https://youtube.com/watch?v=...
Enter fullscreen mode Exit fullscreen mode

Auto-Rebuild with Git Hooks

graphify hook install
Enter fullscreen mode Exit fullscreen mode

This rebuilds the graph after every commit or checkout, keeping it always current.

Export to Other Formats

/graphify . --obsidian    # Generate Obsidian vault
/graphify . --wiki        # Create markdown wiki
/graphify . --graphml     # Export for Gephi/yEd
/graphify . --neo4j       # Generate Neo4j cypher
Enter fullscreen mode Exit fullscreen mode

Watch Mode

Auto-sync the graph as files change:

/graphify . --watch
Enter fullscreen mode Exit fullscreen mode

Ignoring Files

Create a .graphifyignore file (uses .gitignore syntax):

# .graphifyignore
node_modules/
dist/
*.generated.py
*.test.js

# Only index src/
*
!src/
!src/**
Enter fullscreen mode Exit fullscreen mode

Team Collaboration Best Practices

Commit the Graph to Git

The graphify-out/ directory is designed to be version-controlled:

git add graphify-out/
git commit -m "Add Graphify knowledge graph"
Enter fullscreen mode Exit fullscreen mode

Recommended .gitignore

graphify-out/manifest.json   # Breaks after cloning
graphify-out/cost.json       # Local only
# graphify-out/cache/        # Optional: commit for speed
Enter fullscreen mode Exit fullscreen mode

Team Workflow

  1. One developer runs /graphify . and commits the output
  2. Team pulls — Everyone's AI assistant immediately understands the codebase
  3. Install hooksgraphify hook install keeps the graph current
  4. Update as needed — Run /graphify --update when docs change

Real-World Use Cases

Onboarding New Developers

New team members can ask their AI assistant:

"Explain how authentication flows through the system"
"What's the relationship between the API and database layers?"
"Show me all components that depend on the ConfigService"
Enter fullscreen mode Exit fullscreen mode

The AI answers instantly using the graph instead of guessing.

Debugging Complex Issues

graphify query "what modules touch the payment processor?"
graphify path "ErrorHandler" "LoggingService"
Enter fullscreen mode Exit fullscreen mode

Find connection points that would take hours to trace manually.

Refactoring with Confidence

Before changing a core component:

graphify query "what depends on UserAuthenticator?"
Enter fullscreen mode Exit fullscreen mode

Your AI assistant can now predict the impact of your changes.

Documentation Generation

/graphify . --wiki
Enter fullscreen mode Exit fullscreen mode

Creates a markdown wiki of your entire codebase with automatically discovered relationships.


Understanding the Graph Report

After running /graphify ., open GRAPH_REPORT.md to see:

1. God Nodes

The most connected concepts — usually your core services or data models. Everything flows through these.

2. Surprising Connections

Unexpected relationships between distant parts of your code. Often reveals:

  • Hidden dependencies
  • Opportunities for refactoring
  • Architectural insights you missed

3. Design Rationale

Extracted from comments like:

  • # NOTE:
  • # WHY:
  • # HACK:
  • Docstrings

These become separate nodes linked to the code they explain.

4. Suggested Questions

4-5 questions the AI is uniquely equipped to answer about your codebase.

5. Confidence Tags

Every relationship is marked:

  • EXTRACTED — Found directly in code
  • INFERRED — Logically deduced
  • AMBIGUOUS — Uncertain connection

This transparency helps you trust the graph's insights.


MCP Server Integration

For advanced users, expose the graph as a Model Context Protocol server:

pip install "graphifyy[mcp]"
python -m graphify.serve graphify-out/graph.json
Enter fullscreen mode Exit fullscreen mode

Your AI assistant gets structured access to:

  • query_graph — Natural language queries
  • get_node — Node details
  • get_neighbors — Related concepts
  • shortest_path — Connection discovery

Comparing Graphify to Alternatives

vs. Traditional RAG Systems

Traditional RAG: Chunks code into segments, embeds them, searches by similarity
Graphify: Understands relationships and structure, finds connections RAG would miss

vs. Code Search Tools

grep/ripgrep: Fast but text-based, no understanding of relationships
Graphify: Semantic understanding, tracks dependencies across files

vs. Manual Documentation

Manual docs: Quickly outdated, incomplete coverage
Graphify: Always current, automatically discovers relationships


Performance and Cost Analysis

Local Processing (Zero Cost)

  • Code parsing with tree-sitter
  • Video transcription with faster-whisper
  • Relationship extraction

API Usage (Minimal Cost)

  • Document and PDF text extraction
  • Image analysis
  • Summary generation

Typical cost for a medium project (10k lines): $0.50 - $2.00 for initial graph creation, then free updates for code changes.

Token savings per session: 70-90% reduction compared to context-free queries.


Troubleshooting Common Issues

"graphify: command not found"

Solution: Use uv tool install or pipx install which automatically add to PATH:

uv tool install graphifyy
# or
pipx install graphifyy
Enter fullscreen mode Exit fullscreen mode

With plain pip, manually add to PATH:

  • Linux: ~/.local/bin
  • Mac: ~/Library/Python/3.x/bin

Graph Not Updating

Solution: Clear the cache and rebuild:

rm -rf graphify-out/cache/
/graphify . --update
Enter fullscreen mode Exit fullscreen mode

Large Repositories Taking Too Long

Solution: Use .graphifyignore to exclude unnecessary files:

node_modules/
vendor/
*.min.js
build/
Enter fullscreen mode Exit fullscreen mode

The Future: Penpax

The team behind Graphify is building Penpax — an always-on layer that applies the graph approach to your entire working life:

  • Meetings and transcripts
  • Browser history
  • Emails and documents
  • Code repositories
  • Continuous background updates

Fully on-device with no cloud dependency. Join the waitlist →


Conclusion: Why Every AI-Assisted Developer Needs Graphify

In the age of AI coding assistants, Graphify is the difference between:

Without Graphify:

  • AI re-reads files constantly
  • High token costs
  • Slow response times
  • Hallucinations about code structure
  • Limited context awareness

With Graphify:

  • Instant understanding of your entire codebase
  • 70-90% token reduction
  • Fast, accurate responses
  • Relationship-aware suggestions
  • Persistent knowledge graph

Whether you use Claude Code, Cursor, Copilot, or any of the 15+ supported platforms, Graphify transforms your AI assistant from a helpful tool into an expert on your codebase.

Top comments (0)