Skip to main content
KavachOS ships a Drizzle-based database layer by default. If your project already uses Prisma, the @kavachos/prisma adapter lets you query every KavachOS table through your existing PrismaClient, no Drizzle installation required.
The Prisma adapter is a standalone query layer. It does not replace or wrap the core KavachOS instance. Use it to read and write KavachOS data from the parts of your codebase that already work with Prisma.

When to use it

  • You have an existing Prisma project and want to avoid running two ORM clients.
  • You need to query KavachOS tables inside Prisma transactions that span your own models.
  • You prefer generated Prisma types over Drizzle’s schema for editor autocomplete.
  • Your team finds Prisma’s DSL easier to maintain than raw SQL DDL.
The adapter covers agents, users, sessions, audit logs, permissions, delegation chains, OAuth, API keys, organizations, trust scores, approval requests, and every other KavachOS table.

Installation

The adapter has no runtime dependency on kavachos itself, @prisma/client is the only peer dep.

Setup

1

Add the KavachOS models to your Prisma schema

Copy the models from node_modules/@kavachos/prisma/src/schema.prisma into your prisma/schema.prisma, or use it as a reference to add only the tables you need.The schema targets Postgres by default. Switch the datasource provider to sqlite or mysql as appropriate.
2

Run migrations

Or push to an existing database without a migration file:
3

Create the adapter

Usage

Agent operations

User operations

Session management

Audit log queries

Permissions

Transactions

The adapter wraps Prisma’s $transaction to let you compose KavachOS operations with your own Prisma queries:

Trust scores

Approval requests

Migration from Drizzle

If you started with the built-in Drizzle backend and want to switch to Prisma:
  1. Keep the same table names, all KavachOS tables use the kavach_ prefix and the same column names in both Drizzle and Prisma.
  2. Run npx prisma introspect against your existing database to generate a Prisma schema from the Drizzle-created tables.
  3. Replace calls to the Drizzle db directly with createPrismaAdapter(prisma).
  4. Set database.skipMigrations: true in createKavach(...) if the core KavachOS instance is still used for other features (agents, MCP, etc.), so Drizzle does not conflict with Prisma.
The core KavachOS instance (createKavach) still uses Drizzle internally for agent creation, authorization, MCP flows, and other built-in features. @kavachos/prisma gives you a Prisma-native way to read and write the same tables, it does not replace createKavach.

Reference schema

The full reference schema is in node_modules/@kavachos/prisma/src/schema.prisma. It includes all 30+ KavachOS models with correct column mappings, indexes, and default values. Every model name follows KavachPascalCase and maps to a kavach_snake_case table, keeping your Prisma namespace clean and your SQL tables clearly scoped.
Last modified on April 29, 2026