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
| Command | Description |
|---|---|
npx prisma-guard init | Generates a default prisma-guard.config.js file in your project root. |
npx prisma-guard | Runs both client protection metadata generation and Zod schema compilation. |
npx prisma-guard zod | Generates strictly the Zod validation schemas, bypassing extension mappings. |
npx prisma-guard metadata --vscode | Installs VS Code autocomplete snippets and registers git-ignore rules. |
npx prisma-guard --watch or -w | Starts 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.
| Flag | Description |
|---|---|
--dry-run | Performs a test run of the compiler, logging files to console without writing to disk. |
--vscode | Installs 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-ids | Forces omission of primary key @id fields from generated public schemas. |
--omit-dates | Forces omission of timestamps (e.g. createdAt, updatedAt) from public schemas. |
--zod | Forces Zod schema compilation. If your config file does not contain generateZod: true, you can force Zod validation generation via this flag. |
--no-zod | Skips Zod schema compilation even if active in configuration settings. Useful to compile strictly client protection metadata. |
--skip-gitignore | Stops the compiler from automatically writing ignore rules to your .gitignore. |
--no-prettier | Disables running Prettier formatting on the generated files. |
--prettier | Forces Prettier formatting even if disabled in configuration settings. |
--help or -h | Prints out details about commands, parameters, and flags. |
--watch or -w | Watches the schema folder and recompiles automatically when schema files change. |