This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PalJS is a comprehensive toolkit for building NodeJS, Prisma, GraphQL, and React applications. It's organized as a monorepo using bun workspaces, providing code generation, admin interfaces, and query optimization tools.
Current version: v9 (beta) — Prisma 7 compatible, native Prisma generator.
# Install dependencies (using bun)
bun install
# Add new packages
bun add [package-name]
bun add -D [dev-package-name]
# Add packages to specific workspace
bun add [package-name] --filter @paljs/[workspace-name]
# Build all v9 packages in dependency order
bun run build
# Run tests (excludes Playwright E2E specs)
bun run test
# Lint and format code with biome
bun run check # Check for issues
bun run check:fix # Auto-fix issues
bun run lint # Lint only
bun run format # Format code
bun run format:ci # Check formatting (CI)
# Generate documentation
bun run docs:genIndividual packages can be built using:
bun run --filter @paljs/[package-name] build- Run all tests:
bun run test - Tests use bun's built-in test runner (
bun:test) - Admin package uses Vitest
- Test files follow the pattern
*.test.ts - Playwright E2E specs (
*.spec.ts) inexamples/admin-test/e2e/are excluded frombun run test— run them withnpx playwright testfromexamples/admin-test/ - Snapshots are used extensively for generator output validation
- E2E generator tests create temp projects with symlinked
node_modulesfrom the monorepo root
- Uses Changesets for versioning only, and bun publish for publishing
- Currently in pre-release mode (
betatag) — see.changeset/pre.json - Publishing workflow:
- Add changeset:
bunx changeset(select packages and bump type) - Version bump:
bunx changeset version - Build packages:
bun run build - Publish each package in order (plugins → nexus → generator → admin):
cd packages/plugins && bun publish --otp <otp> cd packages/nexus && bun publish --otp <otp> cd packages/generator && bun publish --otp <otp> cd packages/admin && bun publish --otp <otp>
- Add changeset:
- Why bun publish?
bunx changeset publishdoes NOT resolveworkspace:*refs with bun. Onlybun publishproperly resolves workspace protocol to actual versions during publish. - Important: The
@paljs/adminpackage haspublishConfig.directory: "./dist"— it publishes fromdist/package.json. You MUST runbun run buildafter version bump to update the version indist/package.json. - Workspace protocol: During development,
workspace:*links to local folders (changes reflect immediately). Duringbun publish, it resolves to actual version numbers. - To exit pre-release mode for stable release:
bunx changeset pre exit
The project uses bun workspaces with packages in /packages directory:
-
Code Generation (
packages/generator)- Prisma 7 native generator using
@prisma/generator-helper - Binary:
paljs-generator(viabin/cli.js) - Generates Nexus GraphQL types, queries, and mutations
- Generates client-side
.graphqlfiles with fragments - Generates Admin UI pages and schema
- Configured via
paljs.config.tswithdefineConfig() - Writers: DMMF (
writers/dmmf.ts), types (writers/types.ts), Nexus (writers/nexus/), GraphQL (writers/graphql/), Admin (writers/admin/) - Config system:
config/define.ts(defineConfig),config/loader.ts(resolution),config/types.ts(types)
- Prisma 7 native generator using
-
GraphQL Runtime
nexus- Nexus plugin for Prisma integration (PrismaSelect)plugins- GraphQL plugins for query optimization (typed PrismaSelect)
-
UI Components
admin- React 19 admin UI components with Tailwind CSS 4, @tanstack/react-table v8, @dnd-kit/sortable- Use
bunx shadcn add [component-name]to add shadcn components
-
Generator Architecture (
packages/generator)- Native Prisma generator with
generatorHandler({ onManifest, onGenerate }) - Config normalization:
generateGraphQL: trueresolves to{ nexus: true, nexusOutput: './nexus', client: false, clientOutput: './graphql' } generateAdmin: trueresolves to{ enabled: true, output: 'admin', routerType: 'app' }- Admin schema writer: relation fields (
kind === 'object') getcreate: falseandupdate: false - Per-model configuration for exclusions and customization
- Native Prisma generator with
-
Plugin System (
packages/plugins)- Field selection optimization for GraphQL queries
- Extensible plugin architecture
-
Admin UI (
packages/admin)- React 19 components with TypeScript
- Tailwind CSS 4 for styling
- GraphQL integration for CRUD operations
- Form generation based on Prisma schema
- Prisma 7 removes
urlfromdatasourceblock inschema.prisma— connection config goes inprisma.config.ts - Generator gets DMMF directly from
@prisma/generator-helper, not from@paljs/schema @paljs/utilsdist must be rebuilt if it still references deleted packages (e.g.,@paljs/display)
-
TypeScript configurations:
tsconfig.json- Base configurationtsconfig.build.bundle.json- Bundle buildstsconfig.build.regular.json- Regular builds- Individual
tsconfig.build.jsonin each package
-
Each package has its own build process defined in
package.json -
Build order is managed through bun workspace dependencies
-
bunfig.tomlconfigures test exclusions
- Biome for linting and formatting (
biome.json) - Lefthook for pre-commit hooks (
lefthook.yml) - Single-quote strings, trailing commas, 120 char line width
- Unit tests for generators with snapshot testing
- E2E tests in
tests/e2e/create temp projects, symlink rootnode_modules, and runprisma generate - E2E tests in
examples/generator-test/test the full workspace generation flow - Playwright E2E tests in
examples/admin-test/e2e/test the admin UI (run separately) - Test utilities in
tests/helpers - Mock Prisma schemas in test directories
- Create feature branch from main
- Make changes in appropriate package(s)
- Run tests:
bun run test - Check code:
bun run check:fix - Add changeset if needed:
bunx changeset - Create pull request to main branch
- Never push directly to main branch
- Fix all lint errors before committing
- Use snapshot testing for generator output validation
- Follow existing code patterns and conventions
- Docs site is at
../prisma-tools-docs/(Next.js 16, auto-deploys to Hetzner via GitHub Actions on push to main) - Release plan:
docs/V9-RELEASE-PLAN.md - Migration guide:
docs/MIGRATION-v9.md - Prisma 7 notes:
docs/prisma-7-compatibility.md