Disable Safety System Completely
This recipe shows how to completely disable the safety system that protects against dangerous output paths.
danger
Only disable safety checks if you fully understand the risks. The safety system prevents accidental deletion of your source code. Use this configuration with extreme caution.
When to Use
- You're an experienced user who fully understands the implications
- You have robust backup and version control practices
- You're using the generator in automated environments with careful path management
- You need to temporarily bypass safety for migration purposes
Configuration
Method 1: Config File
zod-generator.config.json
{
"safety": {
"enabled": false
}
}
Method 2: Prisma Generator Block
schema.prisma
generator zod {
provider = "prisma-zod-generator"
output = "./src" // Now allowed (dangerous!)
safetyEnabled = false
}
Method 3: Environment Variable
.env
PRISMA_ZOD_SAFETY_ENABLED=false
Command line
PRISMA_ZOD_SAFETY_ENABLED=false npx prisma generate
What This Does
With safety disabled:
- ✅ All output paths are allowed, including dangerous ones
- ✅ No warnings or errors about path safety
- ✅ No manifest tracking or cleanup protection
- ❌ Your files can be deleted without warning
Example Output
# Before (with safety enabled)
❌ ERROR: Unsafe output path detected: Output directory contains project file "package.json"
# After (with safety disabled)
✅ Generation completed successfully
Alternative: Use Permissive Mode
Instead of completely disabling safety, consider using permissive mode which still provides some protection:
zod-generator.config.json
{
"safety": {
"level": "permissive" // Warns but doesn't block
}
}
Safety Recommendations
If you disable safety:
- Always use version control - Commit your changes before running the generator
- Use specific paths - Point to dedicated directories, not source roots
- Test carefully - Run on a copy of your project first
- Re-enable when possible - Turn safety back on once you've restructured
Re-enabling Safety
To re-enable safety later:
zod-generator.config.json
{
"safety": {
"enabled": true,
"level": "standard" // or "strict" for maximum protection
}
}
Or remove the configuration entirely to use defaults.
tip
Consider using force dangerous paths or custom safety configuration instead of completely disabling safety.