Skip to content

Beta. consent-kit is at 0.x: expect breaking changes between releases, and treat everything it generates as a draft. Report a problem or share feedback.

Every consent-kit command and flag, the exit codes, the findings check reports and the shape of its --json report. The source is packages/cli/src/cli.ts.

consent-kit <command> [options]
Command What it does
check Validates the registry and classifies its changes since the last release.
diff Prints the changes since the last release.
build Runs the check, then writes the generated files.
docs Runs the check, then writes the privacy documents.
release Runs the check, then records the registry as released in privacy.lock.json.
script-tag <artefact-id> Prints the consent-gated <script> tag for a script artefact.
audit <url> Checks a running site against the registry in a real browser.

consent-kit --help, -h or help prints the usage; --version or -v prints the version. Running consent-kit with no command prints the usage to standard error and exits 2.

Every command reads the registry and looks for two more files in the registry’s directory.

File Read by Written by
privacy.registry.yaml every command you
privacy.lock.json every command release
privacy.review.json every command you; release empties its two lists
privacy.documents.json docs you

The formats are in project files.

Option Default Meaning
--registry <path> privacy.registry.yaml The registry file. Relative paths resolve against the current directory. The lock, review and documents files are looked for next to it.
-h, --help Show the usage.
-v, --version Show the version.

An unknown option, a missing option value or an unexpected argument is a usage error (exit 2).

Code Meaning
0 Success.
1 The check failed, the registry does not validate, or generated files or documents are stale (--check).
2 A bad command line, or an input file that cannot be read or parsed: a missing registry, a lock or review file that is not valid JSON, an unknown key in privacy.documents.json. Also audit when @consent-kit/audit is not installed.

Colour is used only when standard output is a terminal and NO_COLOR is not set.

Terminal window
consent-kit check [--registry <path>] [--json]

Validates the registry. With a lock file, compares the registry with the last release, classifies every change, checks purpose versions against the changes and checks privacy.review.json against what needs a sign-off. Prints the adopted presets, the deviations of the Content-Security-Policy from strict, and every finding.

Exits 0 when the check passes (warnings do not fail it), 1 otherwise.

Option Meaning
--json Print the check report as JSON instead of text.

Without a lock file:

No privacy.lock.json: nothing has been released yet.
The first release will be revision 1; every visitor is asked for the first time.
check passed

With changes that are not yet in order:

Changes since revision 1 (released 2026-11-28T11:55:29.895Z):
Material (purpose version bump required): 1
purpose.retention_longer@purposes.analytics.retention
"365d" -> "730d"
analytics (consent): re-consent
Needs confirmation (presumed not material): 2
csp.loosened@csp.allow.style-src.'unsafe-inline' [not acknowledged]
(none) -> "The legacy chat widget sets style attributes (WEB-123)."
essential (legitimate_interest): confirmation
security (legitimate_interest): confirmation
analytics (consent): confirmation
correction_reply (contract): confirmation
contributor_credit (consent): confirmation
processor.metadata_changed@processors.plausible.privacyUrl [not acknowledged]
"https://plausible.io/data-policy" -> "https://plausible.io/privacy"
analytics (consent): confirmation
Not material: 1
artefact.description_formatting_changed@artefacts.cc_cookie.description.en
"Stores your cookie choices." -> "Stores your cookie choices"
essential (legitimate_interest): changelog only
Visitors will be asked to consent again: revision 1 -> 2.
Content-Security-Policy: 1 deviation from strict
style-src also allows 'unsafe-inline': The legacy chat widget sets style attributes (WEB-123).
error version/missing_bump Purpose "analytics" changed materially but is still at version 1; bump it to 2.
error confirmation/unacknowledged "csp.loosened@csp.allow.style-src.'unsafe-inline'" is presumed not material but nobody confirmed it. Add its key to "acknowledged" in privacy.review.json, or escalate it under "overrides".
error confirmation/unacknowledged "processor.metadata_changed@processors.plausible.privacyUrl" is presumed not material but nobody confirmed it. Add its key to "acknowledged" in privacy.review.json, or escalate it under "overrides".
check failed: 3 errors

Everything that is not a validation error.

Code Severity Meaning
version/missing_bump error A purpose changed materially but its version did not go up.
version/version_decreased error A purpose version went down.
version/version_skipped error A purpose version went up by more than 1.
version/unnecessary_bump warning A purpose version went up without a material change.
version/initial_version_not_one warning A new purpose does not start at version 1.
review/unacknowledged error A needs_review change has no entry in acknowledged.
confirmation/unacknowledged error A needs_confirmation change has no entry in acknowledged.
override/downgrade warning An override would lower a classification. Ignored: overrides only escalate.
override/unknown_change warning An override names a change key that does not exist. Ignored.
override/invalid_classification warning An override value is not a classification. Ignored.
acknowledgement/unknown_change warning A key in acknowledged matches no change. Remove it.
lock/hash_mismatch warning The registry stored in the lock file does not match its policyHash. The lock was edited by hand.
receipts/opted-out warning The registry opts out of consent receipts. Printed with the reason on every run.
preset/basis-mismatch, preset/redundant-override, preset/missing-locale warning See preset warnings.
Terminal window
consent-kit diff [--registry <path>] [--json]

Prints the same classified changes as check, without the findings and without the verdict. It exits 0 for any valid registry, whatever the changes; it exits 1 only when the registry does not validate. Use it to look, and check to gate.

--json prints the same report as check --json.

Terminal window
consent-kit build [--registry <path>] [--out <dir>] [--guard-mode <mode>] [--report-url <url>] [--check]

Runs the check. If it fails, prints the check output and build refused: the check failed, and exits 1. Otherwise writes the generated files and prints one line per file with created, updated or unchanged. Files whose contents would not change are not rewritten.

Option Default Meaning
--out <dir> src/consent.gen The output directory. Created if missing.
--guard-mode <mode> enforce The mode compiled into the inline guard: throw, record, report or enforce. See the runtime API reference. Any other value is a usage error.
--report-url <url> none Where the inline guard sends violation reports.
--check Write nothing. Exit 1 if any generated file is missing or stale, listing each one. For CI.
created src/consent.gen/_headers
created src/consent.gen/cookieconsent.config.gen.ts
created src/consent.gen/csp.json
created src/consent.gen/guard-manifest.json
created src/consent.gen/guard.inline.js
created src/consent.gen/policy.json
created src/consent.gen/receipts.manifest.gen.json
created src/consent.gen/registry.gen.ts
created src/consent.gen/storage.gen.ts
Built revision 1 with guard mode "enforce": 9 written, 0 unchanged.
Revision 1: every visitor is asked for the first time.

The files are described in generated files. The build uses the pending revision: the revision the next release will carry. Warnings of the check are printed before the file list.

Terminal window
consent-kit docs [--registry <path>] [--out <dir>] [--check] [--require-reviewed] [--json]

Runs the check; refuses like build when it fails. Then writes the privacy documents for every locale the phrase library supports, and prints the documents report: unreviewed phrase texts, phrase overrides in effect, and gaps.

Option Default Meaning
--out <dir> privacy-docs The output directory.
--check Write nothing. Exit 1 if any document is missing or stale.
--require-reviewed Exit 1, and write nothing, if any phrase text in use has no legal review on record.
--json Print the documents report as JSON instead of text. The files are still written unless --check is given.

With imprint in the registry, docs also writes the imprint (imprint.<locale>.md), and --check checks it like the others.

While the registry has unreleased changes, docs also writes the changelog entry (changelog-entry.<locale>.md and .json). After release there is no diff, so no changelog entry is generated; run docs before release to get one.

The documents and the report are described in the documents reference.

Terminal window
consent-kit release [--registry <path>]

Runs the check; refuses when it fails. If the registry is identical to the last release, prints Nothing to release and exits 0. Otherwise:

  1. writes privacy.lock.json with the registry in canonical form, the new revision, the policy hash, the time, and one new entry appended to history;
  2. empties overrides and acknowledged in privacy.review.json, because every entry referred to a change that is now released (other keys in the file are kept);
  3. prints the release: revision, policy hash and the classified changes.
Released revision 2 on 2026-11-28T11:56:01.913Z
Policy hash: 72ab647de338d015f31ab5fa449d7ae21c584f278cf085a6a123aca5924bbd32
Changes since revision 1 (released 2026-11-28T11:55:29.895Z):
…
Visitors will be asked to consent again: revision 1 -> 2.
Wrote privacy.lock.json. Cleared the overrides and acknowledgements in privacy.review.json.

release has no options of its own. It does not build, deploy, tag or commit anything.

Terminal window
consent-kit script-tag <artefact-id> [--registry <path>]

Prints the <script> tag for one script artefact. A script bound to a consent purpose is printed in the blocked form that CookieConsent activates on consent; a script that needs no consent is printed as an ordinary tag.

$ consent-kit script-tag plausible_script
<script type="text/plain" data-category="analytics" data-service="plausible" data-src="https://plausible.io/js/script.js"></script>
$ consent-kit script-tag turnstile_script
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js"></script>

It takes exactly one artefact id. An unknown id, or an artefact that is not a script, is a usage error (exit 2). The registry only has to validate; the change check is not run. A build script can call the same function, consentScriptTag, from the @consent-kit/cli package.

Terminal window
consent-kit audit <url> [--registry <path>] [--page <path>] [--check <id>] [--exercise <file>] [--json] [--strict] [--headed]

Everything after audit is passed to the CLI of the optional package @consent-kit/audit, which is loaded only for this command. Its exit codes are returned unchanged. If the package is not installed, the command prints how to install it and exits 2:

Terminal window
npm install --save-dev @consent-kit/audit
npx playwright install chromium

The flags, the checks and the report are in the audit reference.

check --json and diff --json print one object. Within one reportVersion, fields are only ever added.

Field Type Meaning
reportVersion 1
ok boolean false when there is a validation error or any entry in errors.
registry string The registry path as given.
lock { path, exists, revision, policyHash, releasedAt } The last release. The last three are null without a lock file.
firstRelease boolean No lock file: everything is new.
policyHash string or null The hash of the current registry. null when it does not validate.
unreleasedChanges boolean The registry differs from the lock, or there is no lock.
revision { released, pending } pending is the revision the next release will carry.
reconsentRequired boolean A consent purpose was added or materially changed.
validationErrors array { rule, path, message, line?, column? }.
changes array Each change: key, kind, path, classification, defaultClassification, escalated, affectedPurposes (id, basis, consent, classification, consequence), before, after, an optional note, and acknowledgement (not_required, acknowledged or missing).
purposesNeedingBump string[] Purposes with at least one material change.
missingVersionBumps string[] Those whose version did not go up.
unnecessaryBumps string[] Purposes whose version went up without a material change.
versionIssues array { purposeId, code, severity, previousVersion?, nextVersion, message }.
rejectedOverrides array { key, requested, current?, reason }.
errors, warnings array The findings: { code, message, key?, purposeId? }.
presets { applied, overrides } The adopted presets and every local override of a preset default.
csp { level, deviations } or null level is strict or loosened. Each deviation: directive, kind (sources-added, report-only, directive-omitted), sources?, reason, origin (registry or automatic).
receipts object or null The registry’s receipts section.
consentPurposes string[] Ids of the purposes whose lawful basis is consent. Empty: the site needs no banner and nobody is asked.

The @consent-kit/cli package exports run(argv, options), which runs the CLI in-process and returns the exit code (a promise of one for audit). It never calls process.exit. examples/static-site/src/build.ts uses it to run build from a build script.

The package also re-exports what a site’s build script needs: parseRegistry (bound to the built-in preset catalogue), consentScriptTag, consentEmbed, guardManifest, contentSecurityPolicy, describeCspDeviations and renderInlineGuard, plus analyse, makeLock, buildOutputs, headersFile and planWrites for tools that want the CLI’s logic without its I/O.

consent-kit

Generate your cookie banner and privacy-policy drafts from one registry, and audit what your site really does against it.

© 2026 consent-kit · Released under the MIT licence.