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 graphyti

Or install globally:

npm install -g graphyti

Setup

Initialize the code graph for your project:

graphyti init-graph

This 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-run

Remove a field:

graphyti "remove the bio field from the User model"

How It Works

1

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.

2

Scoped, Structured Edits

The LLM never rewrites whole files. It proposes narrow operations like rename_field User.name -> username applied as deterministic edits.

3

Blast Radius

Before applying a breaking change, Graphyti walks the graph to show what depends on what you are changing.

4

Two-Layer Verification

Local re-parse + HydraDB graph cross-check. Both must agree before anything writes to disk.

5

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":

  1. Context retrieval pulls graph context from HydraDB
  2. Classification determines this is a single-step operation
  3. Intent extraction produces remove_field on User.bio
  4. Code generation creates the schema edit + migration commands
  5. Blast radius identifies affected files: API routes, components
  6. Re-generation attempts to update affected files
  7. Structural verification checks if all blast-radius files were properly updated
  8. If verification passes, write proceeds and graph index updates
  9. 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