Getting Started with Graphyti
Graphyti is a CLI coding agent that builds a deterministic code graph of your project and checks every AI-generated change against it before anything is written to disk.
Prerequisites
- Node.js 18 or later
- A Next.js project (App Router or Pages Router)
- Prisma as your ORM
- An OpenRouter API key for LLM access
Installation
Install Graphyti globally or run it directly with npx:
npx graphytiOr install globally:
npm install -g graphytiSetup
Initialize the code graph for your project:
graphyti init-graphThis scans your project and builds a deterministic graph of your models, fields, routes, components, and their relationships. The graph is stored in HydraDB for fast retrieval.
Usage
Make scoped, verified changes to your codebase:
graphyti "rename Post.title to headline"Preview changes without writing anything:
graphyti "add a priority field to Post" --dry-runRemove a field:
graphyti "remove the bio field from the User model"How It Works
Deterministic Extraction
A static parser (Prisma schema parser + TypeScript AST via ts-morph) builds a graph of your codebase. No LLM guessing. No embedding similarity.
Scoped, Structured Edits
The LLM never rewrites whole files. It proposes narrow operations like rename_field User.name -> username applied as deterministic edits.
Blast Radius
Before applying a breaking change, Graphyti walks the graph to show what depends on what you are changing.
Two-Layer Verification
Local re-parse + HydraDB graph cross-check. Both must agree before anything writes to disk.
Command Allowlist
Only approved shell commands execute: npm install, prisma generate, prisma migrate dev. Nothing else.
The Verification Flow
When you run a command like graphyti "remove the bio field from the User model":
- Context retrieval pulls graph context from HydraDB
- Classification determines this is a single-step operation
- Intent extraction produces
remove_field on User.bio - Code generation creates the schema edit + migration commands
- Blast radius identifies affected files: API routes, components
- Re-generation attempts to update affected files
- Structural verification checks if all blast-radius files were properly updated
- If verification passes, write proceeds and graph index updates
- If verification fails, one retry, then clean failure with nothing written
Safety Features
- Blast radius confirmation — breaking changes shown with reasons before you confirm
- Two-layer verification — nothing writes unless both checks agree
- One bounded retry — a verification miss gets one retry; second miss is a hard failure
- Command allowlist — only approved shell commands execute
- Clean exit codes — 0 success, 1 verification blocked, 2 unexpected error
Target Stack
Graphyti currently supports:
- Next.js (App Router + Pages Router)
- Prisma ORM
- TypeScript
LLM access is provided via OpenRouter, which supports model-agnostic access without hardcoded provider dependencies.
Open Source
Graphyti is open source under the MIT license.
https://github.com/mohakchakraborty2004/graphyti