Reference
CLI Reference
Complete reference for the openpolicy CLI
The openpolicy CLI is provided by @openpolicy/cli. It exposes three subcommands: init, generate, and validate.
openpolicy init
Interactively create a policy.config.ts via a guided wizard.
openpolicy init [options]Options
| Flag | Type | Default | Description |
|---|---|---|---|
--out | string | ./policy.config.ts | Output path for the generated config |
--yes | boolean | false | Skip all prompts and use defaults (CI mode) |
Prompts
The wizard asks:
- Company name
- Legal entity name (defaults to company name)
- Company address
- Privacy contact email
- Jurisdiction:
gdpr,ccpa, orboth - Data categories:
name,email,ip_address,device_info,location,payment_info,usage_data - Whether the app uses cookies
Based on your answers, init sets the correct jurisdictions, userRights, and legalBasis automatically.
openpolicy generate
Compile a policy config to one or more output files.
openpolicy generate [config] [options]Arguments
| Argument | Default | Description |
|---|---|---|
config | ./policy.config.ts | Path to the policy config file |
Options
| Flag | Type | Default | Description |
|---|---|---|---|
--format | string | markdown | Comma-separated output formats: markdown, html |
--out | string | ./output | Output directory |
Output files
| Format | Filename |
|---|---|
markdown | privacy-policy.md |
html | privacy-policy.html |
Examples
# Generate markdown (default)
openpolicy generate
# Generate both formats into src/policies
openpolicy generate ./policy.config.ts --format markdown,html --out ./src/policies
# Custom config path
openpolicy generate ./config/privacy.ts --format html --out ./publicopenpolicy validate
Validate a policy config for required fields and compliance.
openpolicy validate [config] [options]Arguments
| Argument | Default | Description |
|---|---|---|
config | ./policy.config.ts | Path to the policy config file |
Options
| Flag | Type | Default | Description |
|---|---|---|---|
--jurisdiction | string | all | Validate against: gdpr, ccpa, or all |
Validation rules
Errors (non-zero exit code):
effectiveDatemust be presentcompany.name,company.legalName,company.address,company.contactmust be presentdataCollectedmust have at least one entry
Warnings (printed but do not fail):
userRightsshould not be empty- GDPR (
eujurisdiction): recommendsaccess,rectification,erasure,portability,restriction,objectionrights - GDPR:
legalBasismust be present - CCPA (
cajurisdiction): recommendsaccess,erasure,opt_out_sale,non_discriminationrights
Exit codes
| Code | Meaning |
|---|---|
0 | Valid (or valid with warnings only) |
1 | One or more validation errors |