OpenPolicy
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

FlagTypeDefaultDescription
--outstring./policy.config.tsOutput path for the generated config
--yesbooleanfalseSkip all prompts and use defaults (CI mode)

Prompts

The wizard asks:

  1. Company name
  2. Legal entity name (defaults to company name)
  3. Company address
  4. Privacy contact email
  5. Jurisdiction: gdpr, ccpa, or both
  6. Data categories: name, email, ip_address, device_info, location, payment_info, usage_data
  7. 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

ArgumentDefaultDescription
config./policy.config.tsPath to the policy config file

Options

FlagTypeDefaultDescription
--formatstringmarkdownComma-separated output formats: markdown, html
--outstring./outputOutput directory

Output files

FormatFilename
markdownprivacy-policy.md
htmlprivacy-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 ./public

openpolicy validate

Validate a policy config for required fields and compliance.

openpolicy validate [config] [options]

Arguments

ArgumentDefaultDescription
config./policy.config.tsPath to the policy config file

Options

FlagTypeDefaultDescription
--jurisdictionstringallValidate against: gdpr, ccpa, or all

Validation rules

Errors (non-zero exit code):

  • effectiveDate must be present
  • company.name, company.legalName, company.address, company.contact must be present
  • dataCollected must have at least one entry

Warnings (printed but do not fail):

  • userRights should not be empty
  • GDPR (eu jurisdiction): recommends access, rectification, erasure, portability, restriction, objection rights
  • GDPR: legalBasis must be present
  • CCPA (ca jurisdiction): recommends access, erasure, opt_out_sale, non_discrimination rights

Exit codes

CodeMeaning
0Valid (or valid with warnings only)
1One or more validation errors

On this page