{"slug": "how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query", "title": "How Graphify Stopped My Team from Burning Thousands of Tokens Per Query", "summary": "A developer at a React Native shop adopted Graphify, an open-source tool that pre-processes codebases into knowledge graphs, to reduce token waste when using Cursor AI. Graphify runs locally via tree-sitter AST parsing, generating a graph.json, interactive visualization, and architecture report. After setup, the tool auto-updates on every commit, allowing Cursor to query only relevant code nodes instead of reading dozens of files per query.", "body_md": "Every time I asked Cursor about our auth flow, it would open 8-12 files, read through each one, and burn through tokens before even starting to answer. For a React Native codebase maintained by 6 developers, this adds up fast.\n\nI lead a front-end team building React Native apps. Cursor is our primary IDE. And while Cursor is great at understanding code, the way it retrieves context — by grepping and reading raw files sequentially — doesn't scale well on larger projects.\n\nThen I found [Graphify](https://github.com/safishamsi/graphify), and it fundamentally changed how our AI assistant interacts with our codebase.\n\nBefore I get to the setup, it's worth understanding the mechanism — because it's not just another Cursor plugin.\n\nGraphify pre-processes your entire project into a **knowledge graph**. Think of it as a map of your codebase where every function, class, module, and concept becomes a node, and every relationship between them becomes an edge. When Cursor needs to answer a question, instead of reading 47 files to understand a flow, it runs `graphify query \"auth flow\"`\n\n— a scoped subgraph lookup that returns only the relevant nodes and connections.\n\nThe important part: **code extraction happens entirely locally** via tree-sitter AST parsing. No API calls, no code leaving your machine. You only hit an LLM when processing docs, PDFs, or images. For a pure code project (which most React Native apps are), the extraction cost is basically zero.\n\nThe output is three files:\n\n`graph.json`\n\n— the full graph (the core artifact your assistant queries)`graph.html`\n\n— an interactive visualization you can explore in a browser`GRAPH_REPORT.md`\n\n— an architecture summary with god nodes, surprising connections, and suggested questionsThat report alone is worth the setup. It finds connections between modules you didn't realize existed and surfaces the most-connected concepts in your project — the things everything flows through.\n\nI'm on an M1 MacBook Pro. Here's the exact setup that worked for me.\n\n```\nbrew install uv  # if you don't have it already\nuv tool install graphifyy\n```\n\n**Important: use uv tool install, not pip install.** On M1 Macs, pip can break Python path resolution because Graphify resolves the Python binary at runtime from a cached path.\n\n`uv`\n\nisolates the environment and avoids this entirely. I learned this the hard way.\n\n```\ncd your-project\ngraphify extract .\n```\n\nFirst run takes a few minutes depending on codebase size. Since our projects are all code (no PDFs/docs), the entire extraction runs locally on tree-sitter — no API key needed for this step.\n\n```\ngraphify cursor install\n```\n\nThis writes a `.cursor/rules/graphify.mdc`\n\nfile with `alwaysApply: true`\n\n. If you've worked with Cursor's rule system, you know what this means — it gets injected into every conversation automatically, telling Cursor to prefer `graphify query`\n\nover reading raw source files.\n\nQuick note for anyone working with `.mdc`\n\nfiles: a rule with `alwaysApply: false`\n\nand no `globs`\n\nand no `description`\n\nwill never auto-apply — it becomes manual `@`\n\n-mention only. Graphify sets `alwaysApply: true`\n\n, which is the correct move for a global project context rule.\n\n```\ngraphify hook install\n```\n\nThis installs a `post-commit`\n\nhook. Every time anyone commits, it auto-rebuilds the graph using tree-sitter — fully local, takes seconds. It also sets up a git merge driver so if two devs commit graph updates in parallel, `graph.json`\n\ngets union-merged automatically instead of leaving conflict markers.\n\nAfter this, you basically forget Graphify is running. The graph stays current with every commit.\n\nThis is where I had the most questions before adopting it, so let me cover the practical stuff.\n\nAdd these to your repo:\n\n```\ngraphify-out/\n├── graph.json          # the core artifact\n├── graph.html          # interactive visualization\n├── GRAPH_REPORT.md     # architecture summary\n├── manifest.json       # tracks extracted files (uses relative paths — portable)\n└── cache/              # optional — commit for faster rebuilds\n\n.cursor/rules/graphify.mdc    # the Cursor integration rule\n.graphifyignore               # if you create one\n```\n\nAdd this to `.gitignore`\n\n:\n\n```\ngraphify-out/cost.json\n```\n\n`cost.json`\n\ntracks Graphify's own LLM API spend during extraction — not tokens saved in Cursor. It's local accounting, not a shared artifact.\n\n**Zero.** This matters — Graphify is purely additive.\n\nThe `graphify-out/`\n\nfolder is just inert data files. No build process depends on them, no CI breaks without them. The `.mdc`\n\nfile only affects Cursor users who have that rule active. If a dev without Graphify installed triggers the `post-commit`\n\nhook, it fails silently (binary not found) and the commit goes through normally.\n\nYou can adopt this incrementally. Install it yourself, commit `graphify-out/`\n\n, and other devs benefit from the graph whenever they install Graphify later. No coordination needed.\n\n`main`\n\n`graphify extract .`\n\non main and commit `graphify-out/`\n\n. This becomes the shared baseline everyone pulls.One edge case: if someone runs a long-lived feature branch without the hook installed, their `graph.json`\n\nwill drift. A manual `graphify extract . --update`\n\nbefore raising the MR resyncs it. I've considered adding this to our MR checklist, but honestly the hook handles 99% of cases.\n\nA few things I ran into or anticipated:\n\n**The M1 pip issue.** Already mentioned above — use `uv tool install`\n\n, not pip. Wasted about 20 minutes debugging path resolution before figuring this out.\n\n**Can you actually measure token savings?** Honestly, not directly. Cursor doesn't expose per-conversation token usage. What you *can* observe: response latency drops (graph queries are faster than multi-file reads), context window pressure reduces (fewer \"context limit reached\" moments), and Graphify logs every query at `~/.cache/graphify-queries.log`\n\nwith nodes returned and duration — so you get a sense of how targeted the retrieval is.\n\nThe rough mental model: without Graphify, Cursor answering \"how does auth connect to the API layer?\" reads 8-12 files. A typical React Native file is ~200-400 tokens. That's ~3000 tokens just for context loading, before the answer. With Graphify, it reads a scoped subgraph — a fraction of that.\n\n** cost.json is not \"tokens saved.\"** I initially confused this.\n\n`cost.json`\n\ntracks what Graphify itself spent on LLM calls during extraction. For a code-only project, this is near zero. It has nothing to do with what Cursor saves in conversation.**Graph drift on branch switches.** If you install the `post-commit`\n\nhook but not the `post-checkout`\n\nhook, switching branches won't rebuild the graph. The latest version of Graphify supports `post-checkout`\n\nhooks too — check if `graphify hook install`\n\nsets both up for you.\n\nIf I were setting this up again:\n\n`GRAPH_REPORT.md`\n\nbefore sharing with the team.`cache/`\n\ninitially.Graphify makes the most difference when:\n\nFor small projects with 5-6 files, the graph adds structural clarity but the token savings are minimal — the files already fit in a context window.\n\n```\nbrew install uv\nuv tool install graphifyy\ncd your-project\ngraphify extract .\ngraphify cursor install  # or the equivalent for your IDE\ngraphify hook install\n```\n\nThat's 5 commands to set up. The graph builds, your assistant starts using it, and the hook keeps it current. No config files to write, no services to run.\n\nCheck out the [Graphify repo](https://github.com/safishamsi/graphify) for the full docs. If you're on Cursor specifically, the `.mdc`\n\nintegration is the smoothest path — it just works.\n\nIf you've been feeling like Cursor \"forgets\" your codebase every conversation, or burns through context reading files it shouldn't need — Graphify is worth the 10 minutes to set up. It was for me.\n\n*I'm a React Native tech lead exploring AI-assisted development workflows. Find me on Twitter and GitHub.*", "url": "https://wpnews.pro/news/how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query", "canonical_source": "https://dev.to/vikrantnegi/how-graphify-stopped-my-team-from-burning-through-cursors-context-window-2d32", "published_at": "2026-06-21 11:26:47+00:00", "updated_at": "2026-06-21 11:36:56.240600+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "large-language-models", "ai-products"], "entities": ["Graphify", "Cursor", "React Native", "tree-sitter", "M1 MacBook Pro", "uv", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query", "markdown": "https://wpnews.pro/news/how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query.md", "text": "https://wpnews.pro/news/how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query.txt", "jsonld": "https://wpnews.pro/news/how-graphify-stopped-my-team-from-burning-thousands-of-tokens-per-query.jsonld"}}