graffiti vs RAG vs Cursor:
which gives your AI the best code context?
There are three common ways to give an AI coding assistant context about your code — embedding-based RAG, an AI editor like Cursor, and graffiti's static code graph. Here is how they actually differ, and where graffiti fits.
graffiti gives your assistant exact structural context — the real calls, definitions and imports — fully offline and at $0, where embeddings/RAG retrieve approximate matches and editors like Cursor manage context inside the IDE. It complements both: point them at graffiti's graph over MCP.
graffiti vs embeddings / RAG
RAG embeds your code into vectors and retrieves chunks by semantic similarity. graffiti builds an exact graph of how the code actually connects.
| Dimension | Embeddings / RAG | graffiti |
|---|---|---|
| Retrieval method | approximate vector (semantic) similarity | exact directed graph of calls, definitions & imports |
| What it returns | nearest-neighbor text chunks | the real callers, callees & definitions — a scoped subgraph |
| Determinism | varies with model & index version | byte-deterministic — same repo yields an identical map.json |
| Cost & infrastructure | embedding model + vector database, usually paid or cloud | one static binary — $0, no model, no database |
| Privacy & offline | often sends code to an API to embed it | fully offline; nothing about your code leaves your machine |
| Setup & upkeep | chunk, embed, store, and re-embed on every change | run graffiti .; a per-file cache re-parses only what changed |
| Best at | fuzzy natural-language recall (“find code about X”) | structural questions: who calls what, change impact, dependencies |
graffiti vs Cursor
Cursor is an AI editor that indexes your codebase to feed its built-in assistant. graffiti is an editor-agnostic context layer you can use anywhere — including inside Cursor.
| Dimension | Cursor | graffiti |
|---|---|---|
| What it is | an AI code editor (a full IDE) with built-in codebase indexing | a CLI that builds a code-graph context layer — editor-agnostic |
| How it gives the AI context | indexes your codebase with embeddings inside the editor | a directed graph of calls/defs/imports your assistant queries |
| Where it runs | cloud-assisted indexing; a privacy mode is available | fully local & offline — nothing leaves your machine |
| Cost | paid subscription for full features | free to build & run on your own repos (Source-Available) |
| Portability | context lives inside the Cursor editor | one binary, usable from any tool via MCP or paste — Claude Code, ChatGPT, Cursor |
| Determinism | a managed index — not a file you can open or diff | byte-deterministic map.json you can commit & diff |
| Use them together | — | add graffiti as an MCP server so Cursor's AI can read the graph |
When to use which
Reach for embeddings/RAG when you want fuzzy, natural-language recall across code and docs. Reach for an AI editor like Cursor for inline authoring as you type. Reach for graffiti when you need exact structure — who calls what, what breaks if you change an endpoint, cross-service dependencies — fully offline, $0, and reproducible. They stack: graffiti feeds precise structure into whichever assistant you already use.
Comparison questions
How is graffiti different from RAG or embeddings for code?
Does graffiti work with Cursor, Copilot, and ChatGPT, or only Claude Code?
Is there a free, offline alternative to cloud code indexing, embeddings, or RAG?
Give your assistant the map.
One command builds the graph — free, offline, deterministic. Then query it, or wire it into Claude Code, Cursor, or ChatGPT.
curl -fsSL https://raw.githubusercontent.com/amazopic/graffiti/main/scripts/install.sh | sh graffiti . # build the code graph graffiti serve # expose it over MCP (Cursor, Claude Code, …)