Skip to main content

Developer Experience

Prisma Guard is built to maximize local developer velocity, featuring native multi-file structure preservation, a fast watcher, and VS Code IDE autocompletion snippets.


Smart Multi-File Grouping

Prisma Guard respects your project structure. If you partition your Prisma schemas across multiple schema files (e.g. using Prisma's prismaSchemaFolder preview feature), Prisma Guard will automatically replicate that layout in your target output directory.

For example, a multi-file schema directory:

  • prisma/user.prismagenerated/zod/user.ts
  • prisma/product.prismagenerated/zod/product.ts

This keeps generated files small, prevents namespace collision, and simplifies code importing.


Watch Mode

Avoid having to manually re-run generation commands whenever you modify model boundaries. Prisma Guard includes a built-in file watcher:

npx prisma-guard --watch
# Or
npx prisma-guard -w

The watcher tracks changes inside your configured schemaDir and automatically rebuilds the generated Zod files on file save.

Debounced Generation

The watcher is optimized with a built-in debounce. If your IDE performs multiple rapid saves, the compiler will merge the events and trigger execution exactly once, keeping CPU utilization low.


IDE Integration (VS Code Snippets)

Get full autocompletion for @zod decorators inside your .prisma files. By generating metadata snippets, you can write validations with instant IDE suggestions:

npx prisma-guard metadata --vscode

What this command does:

  1. Generates Snippets: Compiles a prisma.code-snippets file containing autocomplete definitions for all Zod validators (.email(), .min(), .regex(), etc.).
  2. Installs Snippets: Copies the compiled snippets file into your project's .vscode/ directory.
  3. Repository Protection: Automatically adds the .vscode/ directory and your generated output folders to your .gitignore file.

[!TIP] Activating Snippets: If autocompletions do not show up immediately after running the command, reload your VS Code window to refresh the local cache:

Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and execute:
Developer: Reload Window