Skip to main content

CLI Command Reference

Prisma Guard features a comprehensive command-line interface (CLI) to initialize configurations, run code generation, configure VS Code snippets, and watch schemas for changes.


Commands

CommandDescription
npx prisma-guard initGenerates a default prisma-guard.config.js file in your project root.
npx prisma-guardRuns both client protection metadata generation and Zod schema compilation.
npx prisma-guard zodGenerates strictly the Zod validation schemas, bypassing extension mappings.
npx prisma-guard metadata --vscodeInstalls VS Code autocomplete snippets and registers git-ignore rules.
npx prisma-guard --watch or -wStarts the file watcher to auto-generate models on save.

Flags

You can customize compilation rules on the fly by appending CLI flags. Flags override properties defined inside prisma-guard.config.js.

FlagDescription
--dry-runPerforms a test run of the compiler, logging files to console without writing to disk.
--vscodeInstalls autocomplete definitions inside .vscode/ (used with metadata).
--schema-dir <path>Overrides the source directory containing your .prisma files.
--output-dir <path>Overrides the target output directory for Zod schemas.
--omit-idsForces omission of primary key @id fields from generated public schemas.
--omit-datesForces omission of timestamps (e.g. createdAt, updatedAt) from public schemas.
--zodForces Zod schema compilation. If your config file does not contain generateZod: true, you can force Zod validation generation via this flag.
--no-zodSkips Zod schema compilation even if active in configuration settings. Useful to compile strictly client protection metadata.
--skip-gitignoreStops the compiler from automatically writing ignore rules to your .gitignore.
--no-prettierDisables running Prettier formatting on the generated files.
--prettierForces Prettier formatting even if disabled in configuration settings.
--help or -hPrints out details about commands, parameters, and flags.
--watch or -wWatches the schema folder and recompiles automatically when schema files change.