graphify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

graphify — Code Navigation Layer

graphify — 代码导航层

Structural index of the codebase. Know what exists, where, and how it connects — before you grep.
Requires CLI:
npm i -g graphify-ts
(uses Bun runtime).
Auto-update recommended: Run
graphify hook install
once. After that, the graph updates automatically at the end of every Claude Code session via a Stop hook — the agent never needs to remember.
代码库的结构化索引。在你使用grep搜索前,就能了解存在什么代码、位置在哪里、代码之间如何关联。
需要安装CLI:
npm i -g graphify-ts
(使用Bun运行时)。
推荐开启自动更新: 只需运行一次
graphify hook install
,之后每次Claude Code会话结束时,Stop钩子会自动更新图结构,Agent无需手动执行更新操作。

First-time setup (one-time per machine)

首次设置(每台机器仅需一次)

bash
npm i -g graphify-ts    # install CLI
graphify hook install   # install Stop hook for auto-update
Then, once per project:
bash
graphify build .
After that, the graph stays in sync automatically. The agent just needs to query it.
bash
npm i -g graphify-ts    # 安装CLI
graphify hook install   # 安装Stop钩子实现自动更新
之后每个项目首次执行:
bash
graphify build .
执行完成后,图结构会自动保持同步,Agent只需查询即可。

Commands

命令

/graphify build
— Build index (first time only)

/graphify build
— 构建索引(仅首次使用)

bash
graphify build .
Scans all source files, extracts AST structure, saves to
graphify-out/graph.json
.
Report: "Indexed {files} files, {nodes} symbols, {edges} relationships"
bash
graphify build .
扫描所有源文件,提取AST结构,保存到
graphify-out/graph.json
报告信息:"已索引 {files} 个文件,{nodes} 个符号,{edges} 个关联关系"

/graphify query <name>
— Search for symbols

/graphify query <name>
— 搜索符号

bash
graphify query graphify-out/graph.json <name>
Case-insensitive search. Returns matching symbols with file locations.
bash
graphify query graphify-out/graph.json <name>
不区分大小写的搜索,返回匹配的符号及其文件位置。

/graphify update <files...>
— Manual incremental update

/graphify update <files...>
— 手动增量更新

bash
graphify update graphify-out/graph.json <file1> [file2...]
Re-extract only the specified files. You usually don't need this — the Stop hook handles updates automatically. Use this only when the hook isn't installed or you want to force a sync mid-session.
bash
graphify update graphify-out/graph.json <file1> [file2...]
仅重新提取指定文件的结构。通常不需要使用此命令 — Stop钩子会自动处理更新。仅当未安装钩子或需要在会话中途强制同步时使用。

/graphify auto-update
— Auto-update (hook internal)

/graphify auto-update
— 自动更新(钩子内部调用)

bash
graphify auto-update [dir]
Computes changed code files via
git diff
+ untracked files, then calls
updateIndex
. Silent when there's nothing to do. This is what the Stop hook runs — you don't call it directly.
bash
graphify auto-update [dir]
通过
git diff
计算变更的代码文件+未跟踪文件,然后调用
updateIndex
,无变更时静默执行。这是Stop钩子运行的命令,无需直接调用。

/graphify hook install | uninstall | status
— Manage the Stop hook

/graphify hook install | uninstall | status
— 管理Stop钩子

bash
graphify hook install    # enable auto-update at session end
graphify hook uninstall  # disable
graphify hook status     # check current state
The hook writes to
~/.claude/settings.json
, preserving all existing config.
bash
graphify hook install    # 开启会话结束时自动更新
graphify hook uninstall  # 关闭自动更新
graphify hook status     # 查看当前钩子状态
钩子会写入
~/.claude/settings.json
,保留所有现有配置。

When to Use

使用场景

Before searching code: If
graphify-out/graph.json
exists, query it before Glob or Grep. The graph tells you which files contain which symbols. This is the main value — replace blind keyword search with structured lookup.
You do NOT need to manually update after editing. The Stop hook handles it. Just do your work — the graph will be current next time you query it.
Exploring unfamiliar code: Run
/graphify query <concept>
to find entry points without guessing filenames.
搜索代码前: 如果存在
graphify-out/graph.json
,先查询该文件再使用Glob或Grep。图结构会告知你哪些文件包含哪些符号,核心价值是用结构化查找替代盲目的关键词搜索。
编辑文件后无需手动更新: Stop钩子会处理更新,正常工作即可,下次查询时图结构已是最新版本。
探索不熟悉的代码库: 运行
/graphify query <概念>
即可找到入口点,无需猜测文件名。

Supported Languages

支持的语言

Python, JavaScript, TypeScript (JSX/TSX), Go, Rust, Java, C, C++, Ruby, C#, Kotlin, Scala, PHP
Python, JavaScript, TypeScript (JSX/TSX), Go, Rust, Java, C, C++, Ruby, C#, Kotlin, Scala, PHP

Graph Output

图输出结果

Saved as
graphify-out/graph.json
:
json
{
  "nodes": [{ "id": "main::app", "label": "App", "sourceFile": "main.py", "sourceLocation": "main.py:5" }],
  "edges": [{ "source": "file::main", "target": "main::app", "relation": "contains", "confidence": "EXTRACTED" }],
  "metadata": { "files": 10, "nodes": 45, "edges": 62 }
}
Edge relations:
contains
,
method
,
imports
,
imports_from
,
calls
(INFERRED),
inherits
保存为
graphify-out/graph.json
json
{
  "nodes": [{ "id": "main::app", "label": "App", "sourceFile": "main.py", "sourceLocation": "main.py:5" }],
  "edges": [{ "source": "file::main", "target": "main::app", "relation": "contains", "confidence": "EXTRACTED" }],
  "metadata": { "files": 10, "nodes": 45, "edges": 62 }
}
边关联类型:
contains
,
method
,
imports
,
imports_from
,
calls
(INFERRED),
inherits