Zero to insight in 5 minutes. Grafema builds a queryable graph of your codebase, answering questions like "who calls this function?" or "where does this data flow?" without reading thousands of lines of code.
- Node.js 18+ (check with
node --version) - A JavaScript or TypeScript project with a
package.json - macOS (ARM or Intel) or Linux x64
npm install -g grafemaIn your project directory:
grafema analyze --quickstart--quickstart auto-detects your project languages, generates .grafema/config.yaml, and builds the code graph in one step.
Expected output:
Analyzing project: /path/to/your-project
Analysis complete
Nodes: 2,847
Edges: 5,123
Two-step alternative — if you want to review the config before indexing:
grafema init # generates .grafema/config.yaml
grafema analyze # builds the graphgrafema tldr src/server.tsReturns a compact DSL overview — 10-20x smaller than the source file:
server.ts {
o- imports express, cors, helmet
> calls app.listen, setupRoutes
< reads config.port
=> writes app
}
grafema who handleRequestgrafema wtf req.userTraces backward through assignments, function parameters, and imports to show where the value originates.
grafema overviewShows node/edge counts by type — modules, functions, classes, call sites.
Add to .mcp.json in your project root:
{
"mcpServers": {
"grafema": {
"command": "npx",
"args": ["grafema-mcp", "--project", "."]
}
}
}Now Claude Code (or any MCP client) can query your codebase graph instead of reading files. Available tools include find_nodes, find_calls, trace_dataflow, get_file_overview, describe, and 30+ more.
grafema doctorChecks binary availability, RFDB server status, and common issues.
The generated .grafema/config.yaml uses minimal defaults:
version: "0.3.29"
root: ".."
include:
- "src/**/*.{ts,tsx,js,jsx}"
exclude:
- "**/*.test.*"
- "**/__tests__/**"
- "**/node_modules/**"
- "**/dist/**"Edit include/exclude patterns to match your project layout. Paths resolve relative to the .grafema/ directory, so root: ".." points to the project root.
See Configuration Reference for all options.
- Configuration Reference - Customize file patterns and services
- Datalog Cheat Sheet - Advanced graph queries
- Known Limitations - What works and what doesn't
"No graph database found"
Run grafema analyze first to build the graph.
Analysis shows 0 files
Check .grafema/config.yaml — make sure include patterns match your source files and root points to the project root (usually "..").
"package.json not found"
Grafema currently requires a package.json. Run npm init -y to create one.
Binaries not found
Run grafema doctor to check which binaries are available and where they're expected.
Run grafema upgrade to clean stale artifacts and download fresh binaries.
"error while loading shared libraries: libyaml-0.so.2" (Linux slim containers)
On minimal Linux images (e.g. node:22-slim, Alpine-based containers), the libyaml C library may not be present, causing resolution to fail:
grafema-resolve: error while loading shared libraries: libyaml-0.so.2: cannot open shared object file
build-index request failed: Broken pipe
Workaround until a statically-linked binary is available:
apt-get install -y libyaml-0-2On Alpine: apk add libyaml. On standard Ubuntu/Debian developer machines, libyaml-0-2 is installed by default — this affects slim/minimal images only.
Upgrading from an older version
Run grafema upgrade to remove stale binaries from ~/.grafema/bin/ and download the current versions. Use grafema upgrade --lang js,python to install only specific language analyzers.