This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pnpm build- Build all packages using Turbopnpm watch- Watch mode for all packagespnpm lint- Run ESLint across all packagespnpm test- Run tests for all packages
- Uses
pnpmwith workspaces - Package manager is pinned to
pnpm@10.12.1 - Packages are located in
packages/,samples/, andtests/
- E2E tests are in
tests/e2e/directory - Regression tests for GitHub issues go in
tests/regression/test/asissue-{number}.test.ts
npx zenstack init- Initialize ZenStack in a projectnpx zenstack generate- Compile ZModel schema to TypeScriptnpx zenstack db push- Sync schema to database (uses Prisma)npx zenstack migrate dev- Create and apply migrationsnpx zenstack migrate deploy- Deploy migrations to production
- @zenstackhq/orm - ORM engine built above Kysely
- @zenstackhq/cli - Command line interface and project management
- @zenstackhq/language - ZModel language specification and parser (uses Langium)
- @zenstackhq/sdk - Code generation utilities and schema processing
- Monorepo Structure: Uses pnpm workspaces with Turbo for build orchestration
- Language-First Design: ZModel DSL compiles to TypeScript, not runtime code generation
- Kysely-Based ORM: V3 uses Kysely as query builder instead of Prisma runtime dependency
- Plugin Architecture: Runtime plugins for query interception and entity mutation hooks
- ZModel schema (
schema.zmodel) defines database structure and policies zenstack generatecompiles ZModel to TypeScript schema (schema.ts)- Schema is used to instantiate
ZenStackClientwith type-safe CRUD operations - Client provides both high-level ORM API and low-level Kysely query builder
- ORM: Depends on Kysely, Zod, and various utility libraries
- CLI: Depends on language package, Commander.js, and Prisma (for migrations)
- Language: Uses Langium for grammar parsing and AST generation
- Database Support: SQLite (better-sqlite3) and PostgreSQL (pg) only
- ORM package has comprehensive client API tests and policy tests
- CLI has action-specific tests for commands
- E2E tests validate real-world schema compatibility (cal.com, formbricks, trigger.dev)
- Type coverage tests ensure TypeScript inference works correctly
- No runtime dependency on @prisma/client
- Pure TypeScript implementation without Rust/WASM
- Built-in access control and validation (coming soon)
- Kysely query builder as escape hatch instead of raw SQL
- Schema-first approach with ZModel DSL extension of Prisma schema language
- Always target the
devbranch (notmain) when creating PRs
- Always run
zenstack generateafter modifying ZModel schemas - Database migrations still use Prisma CLI under the hood
- Plugin system allows interception at ORM, Kysely, and entity mutation levels
- Computed fields are evaluated at database level for performance
- The "ide/vscode" package by-design has a different version from the rest of the packages as VSCode doesn't allow pre-release versions in its marketplace.