Graphify:用持久知识图谱减少编程智能体反复 grep 代码库
开源项目 Graphify 把代码库解析成可查询知识图谱,供 Claude Code、Cursor、Codex 等编程智能体先查图再搜文件;代码侧用 tree-sitter 本地抽取,并可经 MCP 暴露。
当编程智能体在大型仓库里反复「搜认证、打开十几个文件、跟着导入关系跑丢」时,成本主要耗在重复发现架构,而不是真正改代码。开源项目 Graphify(GitHub:Graphify-Labs/graphify)把整仓变成持久、可查询的知识图谱,让智能体先问关系与路径,再决定读哪些文件。
对源代码,Graphify 用 tree-sitter 在本地解析约 40 种语言,抽取函数、类、导入、调用、继承与跨文件关系;构建代码图不需要嵌入、向量库或大模型调用。PDF、图片等非代码内容可走可选的语义抽取。每条关系带置信度标签:EXTRACTED(源码显式存在)、INFERRED(分析推导)、AMBIGUOUS(不确定并标出)。它还会做社区发现,标出高度连接的子系统与节点。
图建好之后才是对接智能体的关键一步:项目宣称可与 Claude Code、Codex、Cursor、Gemini CLI、GitHub Copilot 等二十余种助手集成,通过 hooks 或持久指令推动智能体先查已有图再反复检索。图可提交到 Git、随文件变更增量更新,并经 MCP 暴露;也支持对照图谱审视拉取请求,识别触达相关社区、可能需要更仔细审查的变更。本地还会产出交互 HTML 图、Markdown 架构报告与可复用的 graph.json。
长上下文让模型能多读一些代码;持久图谱则提供「已经分析过什么」的导航层。对在巨型单体或复杂微服务仓里长时间工作的编码智能体,减少同一架构的重复发现,往往比再堆窗口更划算。
Graphify Builds a Persistent Code Knowledge Graph so Coding Agents Stop Grepping Forever
A 135K-star GitHub repo is built around one painfully obvious idea:
Your coding agent should map the codebase once, not grep it forever.
Graphify turns an entire project into a persistent, queryable knowledge graph that AI coding agents can use to understand how different parts of the system connect.
Functions, classes, files, SQL schemas, infrastructure configurations, documentation, PDFs, images and videos can become connected nodes instead of isolated pieces of context the agent has to rediscover.
So instead of: → Search for authentication → Open twelve files → Follow imports and function calls → Lose the trail as the context fills up
The agent can ask:
What connects authentication to the database? Trace the path from UserService to DatabasePool. Explain RateLimiter. Which components are central to this architecture?
Graphify returns relevant graph relationships and paths, rather than another collection of keyword matches.
For source code, the implementation is particularly interesting.
It uses tree-sitter to parse approximately 40 programming languages locally, extracting functions, classes, imports, calls, inheritance and cross-file relationships.
No embeddings, vector database or LLM calls are needed to construct the code graph.
Document and media processing works differently. PDFs, images and other non-code content can go through an optional semantic extraction step using a configured model.
Every relationship carries a confidence label: → EXTRACTED: Explicitly present in the source → INFERRED: Derived through analysis or resolution → AMBIGUOUS: Uncertain and flagged for review
Graphify also uses community detection to identify related subsystems and highlights highly connected nodes that may be important to the overall architecture.
But the part that makes this useful for coding agents is what happens after the graph is built.
Graphify integrates with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot and more than 20 other assistants.
Depending on the platform, it installs hooks or persistent instructions that encourage the agent to query the existing graph before repeatedly searching and reading source files.
The graph can be committed to Git, updated incrementally as files change, and exposed through MCP.
There's also support for examining pull requests against the graph, including identifying PRs that touch related graph communities and may need closer review.
The local tool produces three useful artifacts: an interactive HTML graph, a Markdown architecture report and a reusable graph.json.
Long context windows help coding agents read more code.
A persistent knowledge graph gives them a way to navigate what they've already analyzed.
And as coding agents spend more time working inside large repositories, avoiding repeated discovery of the same architecture becomes increasingly useful.
Here's the GitHub Repo: https://t.co/4ify3X7WBR