graphify

A Go implementation of graphify — turn source code into a knowledge graph, cluster it into communities, and generate a visual report.
What it does
- Detect source files in a project directory
- Extract nodes (functions, classes, modules) and edges (calls, inherits, imports) using tree-sitter AST parsing
- Build a knowledge graph from the extracted entities
- Cluster the graph into communities using the Louvain algorithm
- Analyze the graph for god nodes and surprising connections
- Export an interactive HTML visualization, JSON graph, and Markdown report
Supported languages (24)
C, C++, C#, Dart, Elixir, Elm, Go, Haskell, Java, JavaScript/TypeScript (JSX/TSX), Julia, Kotlin, Lua, Objective-C, PHP, PowerShell, Python, R, Ruby, Rust, Scala, Svelte, Swift, Vue, Zig
Installation
go install github.com/sjhorn/graphify/cmd/graphify@latest
Usage
# Analyze a project directory
graphify /path/to/project
# Specify output directory
graphify -out results /path/to/project
# Verbose output
graphify -verbose /path/to/project
# Add graphify prompt to CLAUDE.md
graphify claude
graphify claude /path/to/project
# Add graphify prompt to AGENTS.md
graphify agents
graphify agents /path/to/project
Output
All output is written to the output directory (graphify-out/ by default):
- graph.json — full graph data with nodes, edges, and community assignments
- graph.html — interactive force-directed visualization
- GRAPH_REPORT.md — Markdown report with community summaries, god nodes, and surprising connections
- cache/ — per-file extraction cache (SHA256-keyed), automatically used on subsequent runs
Caching
Extraction results are cached per file based on content hash (SHA256). On subsequent runs, unchanged files are loaded from cache instead of being re-extracted. For Markdown files, only the body is hashed — frontmatter changes (e.g. reviewed dates) don't invalidate the cache.
Use -verbose to see cache hit/miss stats.
Each source file is parsed into a tree-sitter AST. Language-specific extractors walk the AST to identify:
- Nodes: files, classes, functions, methods, interfaces, enums, modules
- Edges with relation types:
contains — file contains a class, class contains a method
method — class has a method
calls — function calls another function
inherits — class extends or implements another
imports — file imports a module or symbol
case_of — enum variant belongs to an enum
Attribution
This is a Go rewrite of graphify by Safi Shamsi.
Key dependencies:
License
MIT