@@ -5,22 +5,26 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
55## Development Commands
66
77### Build System
8+
89- ` pnpm build ` - Build all packages using Turbo
910- ` pnpm watch ` - Watch mode for all packages
1011- ` pnpm lint ` - Run ESLint across all packages
1112- ` pnpm test ` - Run tests for all packages
1213
1314### Package Management
15+
1416- Uses ` pnpm ` with workspaces
1517- Package manager is pinned to
` [email protected] ` 1618- Packages are located in ` packages/ ` , ` samples/ ` , and ` tests/ `
1719
1820### Testing
21+
1922- Runtime package tests: ` pnpm test ` (includes vitest, typing generation, and typecheck)
20- - CLI tests: ` pnpm test `
23+ - CLI tests: ` pnpm test `
2124- E2E tests are in ` tests/e2e/ ` directory
2225
2326### ZenStack CLI Commands
27+
2428- ` npx zenstack init ` - Initialize ZenStack in a project
2529- ` npx zenstack generate ` - Compile ZModel schema to TypeScript
2630- ` npx zenstack db push ` - Sync schema to database (uses Prisma)
@@ -30,44 +34,51 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
3034## Architecture Overview
3135
3236### Core Components
37+
3338- ** @zenstackhq/runtime ** - Main database client and ORM engine built on Kysely
3439- ** @zenstackhq/cli ** - Command line interface and project management
3540- ** @zenstackhq/language ** - ZModel language specification and parser (uses Langium)
3641- ** @zenstackhq/sdk ** - Code generation utilities and schema processing
3742
3843### Key Architecture Patterns
44+
3945- ** Monorepo Structure** : Uses pnpm workspaces with Turbo for build orchestration
4046- ** Language-First Design** : ZModel DSL compiles to TypeScript, not runtime code generation
4147- ** Kysely-Based ORM** : V3 uses Kysely as query builder instead of Prisma runtime dependency
4248- ** Plugin Architecture** : Runtime plugins for query interception and entity mutation hooks
4349
4450### ZModel to TypeScript Flow
51+
45521 . ZModel schema (` schema.zmodel ` ) defines database structure and policies
46532 . ` zenstack generate ` compiles ZModel to TypeScript schema (` schema.ts ` )
47543 . Schema is used to instantiate ` ZenStackClient ` with type-safe CRUD operations
48554 . Client provides both high-level ORM API and low-level Kysely query builder
4956
5057### Package Dependencies
58+
5159- ** Runtime** : Depends on Kysely, Zod, and various utility libraries
5260- ** CLI** : Depends on language package, Commander.js, and Prisma (for migrations)
5361- ** Language** : Uses Langium for grammar parsing and AST generation
5462- ** Database Support** : SQLite (better-sqlite3) and PostgreSQL (pg) only
5563
5664### Testing Strategy
65+
5766- Runtime package has comprehensive client API tests and policy tests
5867- CLI has action-specific tests for commands
5968- E2E tests validate real-world schema compatibility (cal.com, formbricks, trigger.dev)
6069- Type coverage tests ensure TypeScript inference works correctly
6170
6271## Key Differences from Prisma
72+
6373- No runtime dependency on @prisma/client
6474- Pure TypeScript implementation without Rust/WASM
6575- Built-in access control and validation (coming soon)
6676- Kysely query builder as escape hatch instead of raw SQL
6777- Schema-first approach with ZModel DSL extension of Prisma schema language
6878
6979## Development Notes
80+
7081- Always run ` zenstack generate ` after modifying ZModel schemas
7182- Database migrations still use Prisma CLI under the hood
7283- Plugin system allows interception at ORM, Kysely, and entity mutation levels
73- - Computed fields are evaluated at database level for performance
84+ - Computed fields are evaluated at database level for performance
0 commit comments