Codegraph下载安装和使用教程
一、下载安装
命令行安装
# macOS / Linuxcurl-fsSLhttps://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh|sh# Windows (PowerShell)irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1|iex如果有node,node安装命令
npx @colbymchenry/codegraph# zero-install, or:npmi-g@colbymchenry/codegraph我是MacOS下用curl命令安装的,安装后出现如下情况,配置一下环境变量即可
(base)MacBook-Pro-140:codegraph XXXXX$curl-fsSLhttps://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh|shInstalling CodeGraph v0.9.8(darwin-x64)... Installed to /Users/XXXXX/.codegraph/versions/v0.9.8 Linked /Users/XXXXX/.local/bin/codegraph /Users/xueyunzhen/.local/bin is not on yourPATH.Add it:exportPATH="/Users/XXXXX/.local/bin:$PATH"Done. Run: codegraph--help配置环境变量,打开文件夹vi ~/.bash_profile,在文件最下面添加下面的环境变量,保存后source ~/.bash_profile执行。然后再运行codegraph --help测试是否安装成功
exportPATH="/Users/XXXXX/.local/bin:$PATH安装成功
(base)MacBook-Pro-140:.codegraph xxxxx$ codegraph--helpUsage: codegraph[options][command]Code intelligence and knowledge graphforany codebase Options: -V,--versionoutput the version number -h,--helpdisplayhelpforcommandCommands: init[options][path]Initialize CodeGraphina project directory and build the initial index uninit[options][path]Remove CodeGraph from a project(deletes .codegraph/ directory)index[options][path]Index all filesinthe projectsync[options][path]Sync changes since last index status[options][path]Show index status and statistics query[options]<search>Searchforsymbolsinthe codebase files[options]Show projectfilestructure from the index context[options]<task>Build contextfora task(outputs markdown)serve[options]Start CodeGraph as an MCP serverforAI assistants unlock[path]Remove a stale lockfilethat is blocking indexing callers[options]<symbol>Find all functions/methods that call a specific symbol callees[options]<symbol>Find all functions/methods that a specific symbol calls impact[options]<symbol>Analyze what code is affected by changing a symbol affected[options][files...]Findtestfiles affected by changedsourcefilesinstall[options]Install codegraph MCP server into one ormoreagents(Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)uninstall[options]Remove codegraph from your agents(Claude Code, Cursor, Codex CLI, opencode, Hermes Agent)help[command]displayhelpforcommand二、使用
cd到你要解析的项目目录下,运行codegraph init -i,会生成一个隐藏文件.codegraph。这里一定要注意这是个隐藏文件,你要用命令查看用ls -all,别直接ls肯定看不到。- 打开codex,在使用过程中直接可以说
基于codegraph生成的.codegraph文件来XXXXXX,这样智能体会先解读codegraph生成的文件。
