← Back to Blog

Graphify vs Codegraph

Tokens consumption are all the rage these days. When companies start to increase prices and altering billing methods, plebs like me scramble to find different strategies and methods to solve this problem. One of those neat ways is to use a Knowledge Graph to let LLMs traverse nodes instead of the default find and grep operations, loading unnecessary content into the context before streamling what it needs.

Tools like Graphify, GitNexus, and codegraph all attempt to solve this problem by building a graph from your target directory. So which one is the best at saving tokens and which one to use?

At this point in time, I still don’t know and am still finding a way to scientifically test and compare the exact difference in cost savings. What I presume would be a good test, is to set up 3 environments with the same codebase and prompts, then use something like this cost tracking plugin to compare purely only on cost savings and perhaps factor in qualitatively the usability and accuracy of the output. I have not yet looked into that, so I can’t say for sure which one is better.

Applicable Use Cases

  • Querying the current directory or codebase, asking questions about how things works
  • Drawing diagrams (sequence, class diagrams etc.)
  • Writing documentation
  • Generation of code or docs based on existing references

For the last use case, if the generation of the code requires reading or referencing part of the existing codebase, the cost savings will be related to how much it needs to find the required files. Granular fixes or large generation of code itself would not get much cost savings.

Graphify

Graphify has a more generic use case. It is not just for coding and could be used by other business units in a team. Building of the knowledge graph is elaborate and scans through everything from images to docs to pdfs. The generated graph in .json can be reused and shared with the entire team. However, the downsides is that the build might be expensive depending on how big ur directory is. It also requires a prompt to an agent to build the graph for you and that could cost quite a bit of tokens initially. It also takes quite a long time to do it if your directory is big, and for projects that have large updates constantly, this could be quite costly.

Codegraph

Codegraph is more specific to coding. It is lightweight, has a fast build process that does not require an agent to build it. During coding sessions, the MCP server also acts as a watcher to sync updates to the graph and does not require an extensive re-build. As I work with code more often, I personally prefer Codegraph.

Cost Savings

I dont have exact numbers because I didn’t run an experiment. I work in very small teams (2 people) or by myself usually so there is no need for a common shared graph. Furthermore, I am developing new features and the codebase changes constantly. The codebase is a traditional web application with frontend, backend, background workers etc… In terms of cost savings, I am only comparing based on a 1 person usage, setup vs setup, prompt vs prompt.

Setup vs Setup

As I’ve mentioned above, Graphify requires token costs to build the intitial graph and the cost savings only comes in after. Codegraph does not require that.

Prompt vs Prompt

I only ran a comparison for 3 different prompts but the same prompt for both. In aggregate, Graphify has slightly more savings (~5-10 copilot credits) compared to codegraph. The difference is quite small, almost indifferent to me.

MCP Servers

For both, the MCP setup took a while to figure out. Graphify has graphify install but that is for copilot CLI. I am currently restricted to use only VsCode Copilot chat window and have to figure out a way to get the MCP to work. Similarly, codegraph does not support easy installs with VsCode.

Graphify

Following show the snippet to include in mcp.json:

"graphify": {
    "command": "python3",
    "args": [
    "-m",
    "graphify.serve",
    "repo/project/graphify-out/graph.json"
    ]
},

Specifying the graphify-out/graph.json is necessary so that the tool call will use that as a reference.

Codegraph

As I use codegraph a lot more, I have written the full set up over in GitHub Gists.

Conclusion

I dont have a perfect understanding of how everything works, just sharing some learnings and snippets I discovered along the way.