# Generated files

> Every file consent-kit build and consent-kit docs write, what each is for, and who consumes it.

Every file `consent-kit build` and `consent-kit docs` write, what each is for, and who consumes it.

Generated files are a function of the registry, the lock file and the command's options. Do not edit them: change the registry and build again. `build --check` and `docs --check` fail in CI when a file on disk no longer matches.

## From `consent-kit build`

Written to `src/consent.gen/` unless `--out` says otherwise.

| File | What it is | Who uses it |
| --- | --- | --- |
| `cookieconsent.config.gen.ts` | The CookieConsent v3 configuration, and the receipt sender when `receipts.endpoint` is declared. | Your browser code: pass `cookieConsentConfig` to `CookieConsent.run`. |
| `guard.inline.js` | The runtime guard with its manifest and mode compiled in, as one self-contained script. | Your HTML build: inline it verbatim as the first script in `<head>`. |
| `guard-manifest.json` | What the guard may let through: declared cookies, storage keys, scripts, iframes and endpoints, each with the consent it needs. | The audit, and setups that call `installGuard` from bundled code. |
| `csp.json` | The Content-Security-Policy in structured form. | Your server or adapter, when it cannot read `_headers`. |
| `_headers` | The policy as a response header for every path, in Netlify / Cloudflare Pages format. | Your static host. |
| `storage.gen.ts` | The typed storage facade for this registry. | Your browser code: `createProjectStorage`. |
| `registry.gen.ts` | The registry's ids as TypeScript types and constants. | Your code, for type-safe references to purposes, processors and artefacts. |
| `policy.json` | The registry in canonical form with its hash. | Tools that need the policy hash or the canonical registry. |
| `receipts.manifest.gen.json` | The policies a receipt endpoint accepts receipts for. Only written when the registry declares `receipts.endpoint`. | The receipt endpoint (`@consent-kit/server`). |
| `subject-request-form.<locale>.html` | The request form as an HTML fragment: a plain same-origin POST, labelled fields, a honeypot, no script, no inline style. Only with `subjectRequests`. | Your HTML build: embed it in a page linked from every page. |
| `subject-request-page.<locale>.html` | The form as a complete page. Only with `subjectRequests`. | A site without a page of its own for it. |
| `subject-requests.manifest.gen.json` | Endpoint, types, mailbox, retention, policy hash, pages, email texts and fulfilment checklists. Only with `subjectRequests`. | The request handler (`@consent-kit/server`). |

Commit the generated files or generate them in the build; either works, as long as CI runs `build --check` or the build itself.

### cookieconsent.config.gen.ts

Exports `cookieConsentConfig` (also the default export), typed as `CookieConsentConfig` from `vanilla-cookieconsent`. What it always contains:

| Setting | Value | Why |
| --- | --- | --- |
| `mode` | `"opt-in"` | Nothing optional runs before a choice. |
| `revision` | The pending revision | CookieConsent asks again when a visitor's stored revision does not match. |
| `respectGpc` | `true` | A visitor who sends the Global Privacy Control signal is treated as having refused. |
| `autoClearCookies` | `true` | Cookies of a category are erased when it is withdrawn. |
| `manageScriptTags` | `true` | CookieConsent activates the blocked `<script type="text/plain">` tags. |
| `guiOptions` | `equalWeightButtons: true` for both modals | "Accept all" and "Reject all" look the same. |
| `categories` | `necessary` (enabled, read-only), then one per consent purpose (disabled) | Each consent category has one service per processor with an artefact in it, keyed by processor id. |
| `language` | One translation per registry locale, `default` from `defaultLocale` | Titles and descriptions come from the purposes; the cookie tables list the declared cookies and storage keys. Button labels and headings are built in, in English and German; any other locale gets the English ones. |

With `receipts.endpoint`, the module also exports `consentReceipts` (`endpoint`, `policyHash`, `revision`, and the consent purposes with their versions) and calls `installConsentReceipts(consentReceipts)` from `@consent-kit/storage` when it is imported. The site therefore needs `@consent-kit/storage` as a dependency.

```ts
import { cookieConsentConfig } from './consent.gen/cookieconsent.config.gen.ts';

void CookieConsent.run({ ...cookieConsentConfig });
```

### guard.inline.js

The minified guard, wrapped so that it installs itself with the registry's guard manifest, the mode given by `--guard-mode` and, if set, the `--report-url`.

> [!WARNING]
> Inline the file byte for byte, including its trailing newline. The Content-Security-Policy allows the script by the SHA-256 hash of exactly this text. A browser silently refuses an inline script whose text differs, and the site then runs without the guard.

### guard-manifest.json

Seven lists: `cookies`, `localStorage`, `sessionStorage`, `indexedDB`, `scripts`, `iframes` and `endpoints`. Each entry has the artefact `id`, a `name` (exact) or `pattern` (a RegExp source), the `categories` that must all be accepted (the consent purposes of the artefact; empty means always allowed), and, when the artefact has a processor and needs consent, the `service` that must also be accepted within each category.

```json
{
  "id": "plausible_script",
  "name": "https://plausible.io/js/script.js",
  "categories": ["analytics"],
  "service": "plausible"
}
```

Pixels, stylesheets, fonts and media files are in `endpoints`. The guard uses that list only to label observed requests as declared or undeclared; it never blocks them.

### csp.json and _headers

`_headers` sets the policy on every path:

```
/*
  Content-Security-Policy: default-src 'none'; script-src 'self' 'sha256-…' https://challenges.cloudflare.com https://plausible.io; …
```

The header is `Content-Security-Policy-Report-Only` when the registry sets `csp.reportOnly`, and a `Reporting-Endpoints` line is added when both `csp.reportUri` and `csp.reportTo` are set.

`csp.json` carries the same policy as data: `level`, `deviations`, `directives`, `headerName`, `header`, `meta` and, when applicable, `reportingEndpoints`. The fields are described in the [Content-Security-Policy reference](/docs/manual/reference/content-security-policy/#cspjson).

### storage.gen.ts

Exports `declarations` (every declared cookie and storage key, by area), the types `Declarations` and `ProjectStorage`, and `createProjectStorage(isAccepted, options?)`, which returns the facade. Keys are checked against the registry at compile time and consent is checked at every call. It imports `@consent-kit/storage`. See the [runtime API reference](/docs/manual/reference/runtime-api/).

### registry.gen.ts

Union types and frozen maps of the registry's ids: `PurposeId` / `purposeIds`, `ConsentPurposeId` / `consentPurposeIds`, `ProcessorId` / `processorIds`, `ArtefactId` / `artefactIds`, and one pair per artefact kind in use, such as `ScriptId` / `scriptIds` and `CookieId` / `cookieIds`.

### policy.json

`{ "hash": "<sha-256>", "policy": { … } }`. `policy` is the registry in canonical form: lists keyed by id are sorted by id, set-like lists are sorted, object keys are sorted. `hash` is the lowercase hex SHA-256 of that form. It is the policy hash printed on every generated document, sent in every consent receipt and stored in the lock file.

The hash does not depend on the order of purposes, processors, artefacts, collection points, fields within a collection point, locales, or the items of a purpose's or artefact's id lists. Any other change, including a typo fix in a text, changes it.

### receipts.manifest.gen.json

```json
{
  "manifestVersion": 1,
  "endpoint": "/api/consent-receipts",
  "policies": [
    {
      "policyHash": "72ab647de338d015f31ab5fa449d7ae21c584f278cf085a6a123aca5924bbd32",
      "revision": 2,
      "consentPurposes": { "analytics": 2, "contributor_credit": 1 },
      "otherPurposes": ["correction_reply", "essential", "security"],
      "supersededAt": null
    },
    {
      "policyHash": "e7e18e016f448601a3370d1886bf37058b00c93bd2587917610aa51e3065b060",
      "revision": 1,
      "consentPurposes": { "analytics": 1, "contributor_credit": 1 },
      "otherPurposes": ["correction_reply", "essential", "security"],
      "supersededAt": "2026-11-28T11:56:01.913Z"
    }
  ]
}
```

The first policy is the one this build sends. After it come the released policies from the lock's `history`, newest first, leaving out releases that sent no receipts. See [receipts and server reference](/docs/manual/reference/receipts-and-server/#the-receipt-manifest).

### subject-requests.manifest.gen.json

See [subject requests reference](/docs/manual/reference/subject-requests/#subject-requestsmanifestgenjson). The form, the pages, the emails and the checklists use the phrase overrides of `privacy.documents.json`; the manifest lists the phrases in it that are still unreviewed.

## From `consent-kit docs`

Written to `privacy-docs/` unless `--out` says otherwise. One set per registry locale that the phrase library has a language for (English and German; `de-AT` uses the German texts). A locale without a language is skipped and reported.

| File | What it is |
| --- | --- |
| `privacy-policy.<locale>.md` | The privacy policy. |
| `cookies.<locale>.md`, `cookies.<locale>.json` | The table of cookies, storage entries, scripts, embeds, pixels, endpoints and third-party stylesheets, fonts and media files. |
| `ropa.<locale>.md`, `ropa.<locale>.csv` | The record of processing activities (Art. 30 GDPR), one row per purpose. |
| `processors.<locale>.md`, `processors.<locale>.json` | The list of processors and other recipients. |
| `field-notices.<locale>.json` | The notice or consent-checkbox label for every field of every collection point. |
| `imprint.<locale>.md` | The imprint ("Impressum", § 5 DDG). Only with `imprint`. |
| `changelog-entry.<locale>.md`, `changelog-entry.<locale>.json` | "What changed", written only while the registry has unreleased changes. |

Every Markdown document starts with a comment that names the document, locale, policy hash, revision, the hash of the phrase library, and hashes of the overrides and slots in use. While any phrase in it is unreviewed, the document carries a visible "Unreviewed draft" banner. Every document ends with the policy hash and revision. See the [documents reference](/docs/manual/reference/documents/).

## From `consent-kit release`

`release` writes no generated files. It writes `privacy.lock.json` and may empty the lists in `privacy.review.json`; see [project files](/docs/manual/reference/project-files/).
