# AGENT.md — rules for AI (Payload 3 + Next 16 + IAPL, package `@intecion/ipal-kit`) > **Who this is for:** an AI agent (Antigravity, Claude Code, Cursor) working in a client > project built on IAPL (called ipal-kit before 1.17.0; names: "Names: IAPL and ipal-kit" below). **Read all of it before your first change.** The rules are > hard, with no workarounds. API details for each module: `docs/.md` (map in > §12). Installation, deployment, migration and Gitea are covered in the document for humans: > [the developer guide (PROGRAMISTA.md)](../dev/PROGRAMISTA.md). > > **In the project:** > - a short `AGENTS.md` in the root (template in §13) that points to this file in > `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` — do not copy the rules, a copy goes stale; > (`pnpm exec iapl-skills` adds/refreshes the `iapl:start…end` block with this pointer); > - skills in `.agents/skills/` (§14) — copied from the package with one command, refreshed > after every IAPL update; > - **the full plugin map** — every option, env variable, route, layout component, import > map entry, hook, collection, global and every export: the **`iapl-reference`** skill > (`.agents/skills/iapl-reference/SKILL.md` + `resources/api.md`). Before you write > anything "from scratch", check there. --- ## Names: IAPL and ipal-kit The plugin is called **IAPL** (Intecion Advanced Payload Library) since 1.17.0. Before that it was called ipal-kit. The **package is still `@intecion/ipal-kit`**: install lines and import paths did not change. **Rule for an existing project: do not rename anything on your own.** Every old name works through 1.x. A project moves to the new names only when its owner asks: the `iapl-upgrade` skill, "→ 1.17.0". In new code use the name in the middle column. `pnpm exec iapl-doctor` lists what is still old (`legacy-names`, info). | Before 1.17.0 | Now | In 1.x | |---|---|---| | `ipalKit()`, `IpalOptions` | `iapl()`, `IaplOptions` | both work, same function and type | | `ipalEnvRules`, `IpalEnvFeatures` | `iaplEnvRules`, `IaplEnvFeatures` | both work. Not the same list: `ipalEnvRules()` names the plugin's variables `IPAL_…` (alias `IAPL_…`), `iaplEnvRules()` names them `IAPL_…` (alias `IPAL_…`) — code that filters or maps the rules by `rule.name` keeps working. Constants `COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` keep the `IPAL_` values; the new ones are `IAPL_COOKIE_SCAN_URL_ENV` / `IAPL_COOKIE_SCAN_TOKEN_ENV` | | `ipalT`, `ipalVar`, `IPAL_TOKENS`, `IPAL_BREAKPOINTS`, `IpalTokenName`, `IpalGlobalSlug` | `iaplT`, `iaplVar`, `IAPL_TOKENS`, `IAPL_BREAKPOINTS`, `IaplTokenName`, `IaplGlobalSlug` | both work | | commands `ipal-kit`, `ipal-doctor`, `ipal-skills`, `ipal-tokens`, `ipal-blocks` | `iapl`, `iapl-doctor`, `iapl-skills`, `iapl-tokens`, `iapl-blocks` | both installed, same programs | | env `IPAL_IP_HEADER`, `IPAL_NOINDEX`, `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN`, `IPAL_SEED_ALLOW_FULL`, `IPAL_SEED_ALLOW_PROD_UPDATE`, `IPAL_DOCTOR_TOKEN`, `IPAL_DOCTOR_IMPORT_MAP` (crawler service: `IPAL_CRAWLER_SITES`) | the same with `IAPL_` | `IAPL_…` is read first, `IPAL_…` when it is missing or empty; set one, not both | | `ipal-doctor.json` | `iapl-doctor.json` | whichever exists is read and written; never keep both | | `ipal-audit-skip:` lines in `AGENTS.md` | `iapl-audit-skip:` | both read | | pointer block `` … `` | `` … `` | both recognised; `iapl-skills` rewrites the old one in place | | skills `ipal-` (16) | `iapl-` | `iapl-skills` installs the new folders and removes the 16 old ones by name; a project's own `ipal-…` skill is left alone. A text that still names an `ipal-` skill — the vendored `ext-*` skills say "the `ipal-reference` skill" — means `iapl-` (`iapl-reference`) | | files `node_modules/@intecion/ipal-kit/bin/ipal-*.mjs` | `bin/iapl*.mjs` | the old files are still there and run the new ones (older skills and CI call them by path) | | log prefix `[ipal]` | `[iapl]` | changed (a log filter on `[ipal]` needs the new prefix) | **Not renamed — write them exactly like this, in every project:** | Name | Why | |---|---| | package `@intecion/ipal-kit` and every import path (`@intecion/ipal-kit/client`, `…/tokens.css`), import-map paths `@intecion/ipal-kit/admin#…`, `node_modules/@intecion/ipal-kit/docs/…` | the package name changes in 2.0 | | routes `/api/ipal/…` | proxies, cached pages and the crawler call them (the mail service's four routes, new in 1.17.0, are `/api/iapl/mail-relay/…`) | | CSS tokens `--ipal-*`, hooks `data-ipal="…"` | projects' own CSS uses them | | `config.custom.ipal`, `custom.ipalAccounts`, `req.context` flags (`ipalSeed`, `ipalSkipIndexNow`, `ipalSkipAutoFill`, …), `ipalTotpView` server props, translation namespace `ipal` | projects' hooks and overrides read them | | header `X-Ipal-Cookie-Crawler` | WAF rules | **Two stored names have a second spelling, chosen once per site** (`iapl({ storageNames })`, docs/stats.md, docs/security.md): | | Site made before 1.17.0 (default, `storageNames: 'ipal'`) | Site made since (`storageNames: 'iapl'`, set by `iapl create`) | |---|---|---| | visitor cookie of the built-in statistics | `ipal_vid` | `iapl_vid` — and the layout passes `visitorCookie={IAPL_VISITOR_COOKIE}` to `` / `` | | 2FA attempt counter in `payload-kv` | `ipal:2fa-verify::` | `iapl:2fa-verify::` | Never switch `storageNames` on a live site: visitors' histories and running 2FA counts start again, and the cookie list must be approved again. `iapl-doctor` (`storage-names`) reports a layout and a config that disagree. ## Main rule — the plugin helps, never limits IAPL is a plugin: it helps the project and never limits it. Every module can be turned off on its own; every default (access rules, fields, hooks, labels, routes, collections, globals) can be overridden and **the project config wins**; safe defaults have an option to loosen/extend them; the plugin exports building blocks (helpers, builders, hooks), not just finished features; it does not force dependencies, routes, UI or data shape where an option or an exported building block is enough. **In practice:** before you write something from scratch or start fighting the plugin — find the option or the exported builder (module docs §12, types in `dist/**/*.d.ts`). It is missing → **plugin gap**: report it to the owner and wait for their decision (see "IAPL first" below), never patch `node_modules` or fork the package. **Docs language:** all IAPL docs, this guide and the skills are written in English. Write new rules, AGENTS.md entries and plugin-gap reports in English. > **VERY IMPORTANT — seeding after launch.** Once a site is live, **never run a full seed again**: the owner's > edits on the live site must survive. Every later change targets **named records only** — specific pages, > globals, forms or fields — listed in the seed (`only: [...]` / `SEED_ONLY="pages:kontakt,global:header"`). > Never re-seed everything, not even in create-only mode, without the owner's explicit OK. `createSeeder` > refuses a run with no record list against a production or non-local database unless `IAPL_SEED_ALLOW_FULL=1` > (set it only after that OK). **Database names** (MongoDB and Postgres): the site's domain **with the dots removed**, plus `_prod` or `_dev` — `intecion.com` → `intecioncom_prod` / `intecioncom_dev`, `architektimprez.pl` → `architektimprezpl_prod` / `architektimprezpl_dev`. The name is the path of `DATABASE_URI`: `mongodb://…@mongo:27017/intecioncom_prod?authSource=admin`, `postgres://…@db:5432/intecioncom_prod`. You derive the names from the domain and confirm them with the owner (iapl-setup stage 0). `iaplEnvRules({ databaseName: true })` warns when they do not match (deployment.md §4.2a). **`PAYLOAD_SECRET`:** at least 32 random characters, different per environment (`iapl create` writes 64). In production `iaplEnvRules` refuses a shorter one (`secretMinLength`, default 32, `0` = off). Never change it on a live site without the owner's OK: every login session and every stored API key depends on it (deployment.md §1). **Seeding on production** (details: `node_modules/@intecion/ipal-kit/docs/seeding.md`). Write seeds with `createSeeder` from `@intecion/ipal-kit/seed` (the templates do) — it enforces every rule below: - Call `guardSeedExit()` first in every seed script (before `getPayload`): a run that ends early exits 1 with the reason instead of a silent 0 that looks like success in Coolify's Terminal. - Seeds are create-only and idempotent: match by the default-locale slug / form title / the global, skip what exists. - Never delete; never seed users, passwords or secrets; globals: fill only empty fields; no media uploads. - Every locale written separately with `fallbackLocale: false`; `context: { disableRevalidate: true, ipalSkipIndexNow: true }`. - On production: dry run first (`SEED_DRY_RUN=1`), back up the database (Coolify **Backup now**), then the real run. - `SEED_UPDATE=1` on production / a non-local database only with `IAPL_SEED_ALLOW_PROD_UPDATE=1`, after a backup; records an editor changed are always skipped and reported (`skip (edited)`) — never use `SEED_FORCE=1` there. - After launch: named records only (`only` / `SEED_ONLY`); a full run of a live database is refused without `IAPL_SEED_ALLOW_FULL=1`. - Schema and one-off data fixes → Payload migrations; field renames with content → **iapl-migrate-fields**; content → seeds. ## Ask before you build — architecture questions Before you set up a site (or a new part of one), **ask the owner these questions and wait for the answers**. They decide the architecture; a wrong guess means rework. Ask them as **one list**, once, at the start — the ready-to-send list is in **iapl-setup** stage 0 (iapl-site phase 0 uses the same list). | Topic | What you need to know | |---|---| | Languages | which locales, the default locale, URL structure (`/pl/…` for every language, or the default without a prefix) | | Styling | a design system / `DESIGN.md` or plain Tailwind tokens, brand colours, fonts, light/dark theme | | Content | the pages, the collections (blog, case studies, products…), archive pages | | Forms | which forms, who receives them; e-mail: the Intecion mail service (IWSN in the panel) by default — ask only whether the client wants its **own SMTP server and sender address** (never offer Microsoft Graph: deprecated) | | Analytics and consent | GA4 / GTM / pixels, Consent Mode basic or advanced, cookie banner mode, cookie scan | | SEO / GEO | market and local business data, AI crawler policy (llms.txt, Markdown, MCP, AI bots) | | Data and media | database (Postgres or MongoDB) and its names (`_prod` / `_dev` — derive, then confirm), media storage (R2 or local disk) | | Admin | 2FA, white-label (client brand in the panel), agency credit | | Hosting | Coolify, the production domain(s), who adds the DNS records (deployment.md §6) | - **A new site starts with `iapl create`** (docs/project-starter.md): `pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@ create ` asks exactly these questions (or reads them from `--answers file.json`), generates the site from the reference site, writes the answers into `AGENTS.md` and makes the first commit. Ask the owner first, then pass the answers — the command never fills a gap. The manual path (`iapl-setup` stages 1–11) is for an existing project or what the command does not cover yet: **single-language sites, a default language other than `pl`**, sites without `en`, URLs without a prefix, Postgres — the command stops with a message pointing here. - Write every answer into the project's `AGENTS.md` → **"Project decisions"** (one line per topic). - **Do not guess a missing answer.** No answer to an architecture question → do not build that part; ask again. (Only *content* gaps — company data, texts, IDs — may wait: use `[TO FILL: …]` in the panel, §0a.) - An answer that conflicts with these rules → say so straight away and propose a compliant option. ## IAPL first — hard rule - **Anything the plugin covers, you build with the plugin's feature.** Always. Look it up first: the **iapl-reference** skill, the module docs (§12), the types in `dist/**/*.d.ts`. - The only exceptions: the plugin's feature **does not work**, or it **is not enough** for this project. - Even then: **report the gap to the owner first** with the **iapl-plugin-gap** skill and **do nothing on your own** for that part until the owner decides (wait for a plugin fix / an approved option / an approved, marked workaround). Work on unrelated parts may go on. - **No hand-built replacements and no silent workarounds.** A workaround exists only after the owner approved it, is marked `// WORKAROUND IAPL : docs/plugin-requests/` and is recorded in "Project decisions". ## Reference site — copy the pattern, not from memory Every convention in this file is implemented in the **reference site**: one complete client site on IAPL ("Example Studio", made up), kept current with each release and built, seeded and smoke-tested in the plugin's CI. Before you write a file the plugin expects you to wire (payload.config, layout, catch-all page, `lib/content.ts`, proxy, SEO/GEO routes, forms, seeds, `AGENTS.md`, `DESIGN.md`, deploy notes), open `node_modules/@intecion/ipal-kit/docs/agent/reference-site/INDEX.md`, find the matching file and copy its pattern — short wiring files are in the index in full, longer ones are linked at the tag of your plugin version. Change only the project's content (names, texts, blocks the site map needs), never the pattern. The index and this file disagree → report it with **iapl-plugin-gap**: it is a plugin bug. ## Code rules Short version of §8 — every skill follows it. - **Single responsibility:** one job per file, per component, per function. - **Small files, clear names, no dead code** (no commented-out code, unused exports or props). - **No duplicated logic** — extract it once; reuse the plugin's exports instead of rewriting them. - **Typed, no `any`** (no `@ts-ignore`; unknown shape → `unknown` + a type guard). - **Texts in i18n, never literals** — every visible text comes from the panel / localized fields (§2). - **Tests or checks for new behaviour** — a unit test, an `iapl-audit` / `iapl-seo-check` result, or a documented manual check (§8a). ```tsx // BAD — one component fetches, formats and renders; hardcoded text; any export function Offer({ data }: { data: any }) { const p = fetch(…); return

Nasza oferta

} // GOOD — data comes in typed props (enhanceProps / lib/content), text from the panel, one job export function Offer({ header, items }: OfferBlockProps) { return
} ``` --- ## 0. COMPASS (if you remember only this) 0. **Ask first.** Architecture questions before you build ("Ask before you build" above) — never guess. 1. **IAPL is mandatory.** A feature the plugin has goes through the plugin. Missing or broken → report it (plugin gap, §1.3) and wait for the owner's decision — no silent patch. 2. **Nothing hardcoded.** Text, image, link, file, company data → admin panel. Domains, keys → `.env`. Also in an `||` fallback and in `catch`. 3. **Next 16 = `proxy.ts`.** NEVER `middleware.ts`. 4. **No explicit ``, with ISR and `generateStaticParams`** — otherwise metadata lands in `` and SEO breaks. 5. **Minimum collections.** iapl adds Users, company data/navigation are globals, FAQ/hero are blocks. 6. **A section = a composition of UI primitives.** `buildLinksField()` + ``, upload + ``, `
` + ``. No `ctaLabel`/`pdfUrl` fields. **A clear panel** (§6.5a): repeated items = an "+ Add …" array with `rowLabel`, never `cta1`/`cta2`; labels short and in the panel's languages (`{ en, pl }`, guide `docs/dev/admin-ux.md`); no empty "just in case" fields. 7. **Renderers from the plugin:** `RenderBlocks` (not a `switch`), `RenderRichText` (not your own Lexical parser), `useForm` (not hand-made form plumbing). **Sections from the block library first:** `libraryBlocks` + `createBlockRegistry` (15 ready blocks, docs/block-library.md); an own block only when no library block, variant or option fits. 8. **No `any` and no `@ts-ignore`.** Types from `@/payload-types`, `unknown` + guard. 9. **One source of truth** — `i18n.config.ts`, `lib/content.ts`, never copies. 10. **"Done" only after** a local `pnpm build` + the checks from §11. 11. **Every site has the MANDATORY SET from §0b** — SEO, GEO (llms.txt, Markdown, MCP), R2, Turnstile, forms from the builder. `iapl-audit` checks that it is wired, `iapl-seo-check` — that it works. There is no "I'll do it later". **How to add…** (details in the skill from §14) | What | How | |---|---| | a page | in the panel: Pages + blocks, no code (§5.1) | | a section (block) | a library block first: `blockOptions` → `libraryBlocks` in `src/blocks/configs.ts`, `createBlockRegistry(content, { Image, Link, sendForm })` in `blocks/registry.ts` (docs/block-library.md). None fits → `src/blocks//config.ts` + `Component.tsx`, `extra` in the registry, `pageBlocks` → `pnpm generate:types` (+ `pnpm payload generate:importmap` with `rowLabel`) — **iapl-block** | | a standard page (home, about, services, contact, legal, 404…) | `pageTemplates` from `@intecion/ipal-kit/templates` in the content seed (after launch only with `SEED_ONLY`) — **iapl-site** phase 6 | | a form | the Forms panel (builder) from the seed `scripts/seed-form-*.ts`, a block with ``, sending via `sendForm` — **iapl-form** | | a language | `i18n.config.ts` (the only place) + a Postgres migration + content in the new language — **iapl-locale-add** | | a collection with URLs | `content: { collections: [...] }` in `iapl` and `createContentHelpers` (§5.4) — **iapl-collection** | --- ## 0b. MANDATORY SET — every site, no exceptions These are not options. Every project has **all** the items below, wired through the plugin. Data is missing (domain, keys, bucket)? Wire the code anyway — it works once the values are entered in `.env` / the panel, and you list what is missing in the report. You skip an item **only** on a client decision recorded in `AGENTS.md` (the `iapl-audit-skip:` line, below). The "Check" column: **A** = `iapl-audit` (code), **S** = `iapl-seo-check` (running site), **P** = a test in the panel. Full code: PROGRAMISTA.md §2. | # | Area | What must exist (file) | Plugin API | Check | |---|---|---|---|---| | 1 | i18n + routing | `src/proxy.ts`, `[locale]/[[...slug]]/page.tsx` = `createPageRoute(content, {…})` + a literal `revalidate`, `not-found.tsx` = `createNotFoundPage(content, { load })` + `notFoundView.ts` (`renderNotFoundView`) | `createProxy`, `createContentHelpers`, `createPageRoute`, `createNotFoundPage` (`/rsc`) | A, S | | 2 | **SEO** — meta | `generateMetadata` in every page route; favicon and OG from Site settings; `htmlLimitedBots` in `next.config.ts`; SEO tab + `buildNoindexField` in Pages | `generatePageMetadata`, `buildIconsMetadata`, `buildNoindexField` | A, S | | 3 | **SEO** — maps | `src/app/sitemap.xml/route.ts` (`export { sitemapRoute as GET }` + `force-dynamic`), `src/app/robots.ts` (`export { getRobots as default }` + `force-dynamic` — AI bots from the panel), `src/app/manifest.ts` — re-exports from `lib/content` | `sitemapRoute`, `getRobots` (or `robots` without the panel), `manifest` | A, S | | 3a | **Search Console / Bing** | recommended: **domain verification via DNS** (TXT record, deployment.md §6) — the plugin does nothing, the verification fields stay empty; only for URL-prefix verification: code in **Site settings → Search engines** (Google, Bing, Yandex), `generatePageMetadata` adds the `` itself; sitemap `https:///sitemap.xml` submitted in GSC and Bing | panel (optional), `verificationFrom` | P | | 4 | **SEO** — structured data | layout: `` gives `WebSite` + `Organization` (`sameAs`) from Site settings; local business → `createContentHelpers({ siteJsonLd })` with `buildLocalBusinessJsonLd` (`type`, hours → `formatOpeningHours`); navigation: ``; page: `createPageRoute` adds `getPageJsonLd` (WebPage/BlogPosting, breadcrumbs, FAQ — `pageJsonLd: { faq }`) | `getSiteShell`, `SiteProviders`, `build*JsonLd`, `getPageJsonLd` | A, S | | 5 | **GEO** — llms | `src/app/llms.txt/route.ts` (`llmsRoute`) and `src/app/llms-full.txt/route.ts` (`llmsFullRoute`) from `lib/content`; the `buildSummaryField()` field in Pages, `summaryField: 'aiSummary'` in `createContentHelpers` | `llmsRoute`, `llmsFullRoute`, `buildSummaryField` | A, S | | 6 | **GEO** — Markdown | `src/app/md/[locale]/[[...slug]]/route.ts` (single-language: `src/app/md/[[...slug]]/route.ts`) = `export { markdownRoute as GET } from '@/lib/content'`; `createContentHelpers({ markdownAlternate: true })` (link in ``); `createProxy(…, { NextResponse, markdown: true })` (without it `/md/…` gets redirected to a language) | `markdownRoute`, `markdownAlternate`, `createProxy({ markdown })` | A, S | | 7 | **GEO** — MCP | `src/app/api/mcp/route.ts` = `export { mcpGET as GET, mcpPOST as POST } from '@/lib/content'` (public — AI browses the site: `get_site_info`, `list_pages`, `search_content`, `get_page`); name: `createContentHelpers({ mcp: { serverName } })` | `mcpGET`, `mcpPOST` | A, S | | 8 | **GEO** — AI bots + IndexNow | robots **lets in** AI bots (default `aiBots: 'allow'`; block only on a client decision); AI bot policy and per-bot exceptions — Site settings → Search engines → AI assistants (works only with `getRobots`); `iapl({ indexNow: true })` + `src/app/indexnow-key.txt/route.ts` (`indexNowKeyRoute`; publishing → Bing/ChatGPT Search within minutes; IndexNow sends nothing with `IAPL_NOINDEX=1`) | `buildRobots`, `getRobots`, `indexNowKeyRoute` | A, S | | 9 | **Media / R2 / speed** | `Media` with `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + field; **always** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` in `.env.example`; ``; `images: buildImagesConfig()` and `buildUploadSecurityHeaders()` in `next.config.ts`; the project's `` via `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S | | 10 | **Forms** | every form from a **seed** (`scripts/seed-form-*.ts`: fields, confirmation, mail to the company **and** confirmation to the customer, every language); a block with `` + `formClasses.ts` (look, once); `actions.ts` = `createSubmitAction({ getCachedPayload, headers })`; `forms: {…}` in `iapl`; `email: mailAdapter()` | `RenderForm` (`/rsc`), `createSubmitAction`, `mailAdapter` | A, P | | 11 | **Turnstile** | `` in `[locale]/layout.tsx` (wires `TurnstileProvider` with the key from the panel); `RenderForm` renders the widget; keys in Site integrations | `SiteProviders`, `getTurnstileConfig`, `TurnstileProvider` | A, P | | 12 | Consent + analytics | Consent Mode: `'advanced'` (default — the Google tag loads at once with every signal `denied`) or `'basic'` (`` — no request to Google before consent; a client who wants zero requests), the choice goes to "Project decisions"; the consent log is on by default since 1.17.0 (`consentLog: false` turns it off; **Postgres / SQLite: `pnpm payload migrate:create consent-log` and apply it in the same deploy**, doctor `consent-log-migration`) + `}>` (posts every decision to the log by itself; "Reject" is as prominent as "Accept all" by default — `equalChoice`; Global Privacy Control honoured by default — `gpc`, consent.md → "Global Privacy Control"; ConsentProvider, banner, CookieButton, Analytics in the right order; the banner is in the server HTML and painted with the page — pages stay static, an inline script decides before the first paint; with a nonce CSP pass `nonce` to `SiteProviders`; never wrap the banner in a "mounted" guard or `dynamic(…, { ssr: false })`, never read the consent cookie in the layout unless the site is dynamic anyway: `consentCookie`, consent.md → "First paint"); settings window mode (`settings`: `inline` / `modal` / `detailed`) per the design, brief is silent → `detailed`, the decision goes to "Project decisions"; tool IDs in the panel; the cookie list from a scan (`cookieScanner: true` → *Cookie review* → **Scan cookies** → *Approve cookies* → **Approve and add**; or cookie-scan → import) — feeds `` on the policy page **and** the lists in the `detailed` window; Cookies → Settings window → Cookie list headings in every language | consent.md, analytics.md | A, `iapl-consent-check` | | 13 | Security | `buildSecurityHeaders` in `next.config.ts`; `withSecurityConfig(withPayload(nextConfig))` — this order (no `X-Powered-By`; Payload's colour-scheme client hints for `/admin` only, check: `curl -sI localhost:3000/pl \| grep -i critical-ch` → nothing); CSP: `buildSecurityHeaders({ csp: { mode: 'report-only', reportUri: '/api/csp-report', … } })` + `buildAdminCspHeaders` on `/admin/:path*` + `src/app/api/csp-report/route.ts` (`createCspReportRoute`) → read the reports → `mode: 'enforce'`; `twoFactor: { issuer, plugin: payloadTotp }` + `generate:importmap` (`TotpRedirectProvider`, `SafeTotpView`; check: a new admin lands on `/admin/setup-totp?back=%2Fadmin` with the QR, no reloading; a login with the password only gets `403` from `/api/globals/site-integrations` and `/api/form-submissions` — security.md "What the second factor covers"); own endpoints: `secondFactorPassed(req)` / `userMeetsRole(req, role)`; **an account without 2FA can only set it up** (`twoFactor.requireSetup`, default: nothing else answers, 72 h from creation or an admin's reset, then blocked until an admin chooses "Reopen setup" on the account) — so set 2FA up right after creating an account; `iapl-doctor --url` must report 0 accounts without 2FA; Postgres/SQLite: migration for `totpSetupFrom`; `IAPL_IP_HEADER` in production | security.md, forms.md | A | | 14 | Operations | `src/app/api/health/route.ts` (`healthRoute`); `src/instrumentation.ts` with `assertEnv(iaplEnvRules({ storage: true, ipHeader: true }))`; staging with `IAPL_NOINDEX=1`; smoke tests (§8a) | `healthRoute`, `assertEnv`, `iaplEnvRules` | A | | 15 | System pages | Site settings → System pages: homepage, 404, privacy policy, cookies; legal links in the footer by role (`getSystemLinks(locale)`) | `getSystemLinks`, `getSystemPagePath`, `getNotFoundPage` | P | | 16 | **Nothing hardcoded** | every text, link, image, file, company data from the panel; domains and keys from `.env` (§2) | — | A, P | | 17 | **Content** | one h1, the answer at the start of each section, facts, internal links, FAQ from real questions, `aiSummary`, sameAs, consistent company data (§0c) | — | S, P | | 18 | **Scaling** | `fluid.css` / `fluid-wide.css`, hero on `--ipal-hero-min-h`, the screen list in §6.11a (including 1366×768) | — | A, browser | | 19 | **Design tokens** | `DESIGN.md` + `src/design/tokens.ts` → `pnpm exec iapl-tokens` → `src/design/tokens.css`; `styles.css` imports `fluid-wide.css`, `tokens.css`, `tailwind.css`, the brand file (§6.11); fonts in `--font-family-body` / `--font-family-heading` | `defineTokens`, `iapl-tokens` | A (`iapl-tokens --check`), browser (both themes) | **Turnstile works by itself:** both keys in the panel (or env) → the widget shows, and `submitForm` **requires** a token; no keys → no widget, the form works. Do not make the provider or the widget conditional in code — always wire them. **R2 works by itself:** the full `R2_*` set in env → media in the bucket; missing → local disk (dev). Always wire the code, so production does not save media to the container disk (they disappear on redeploy). ### Forbidden substitutes (ERROR in `iapl-audit`) | Instead of the plugin | Why not | Use | |---|---|---| | your own form with fields in JSX, `react-hook-form`, `formik`, your own form renderer | the client cannot change the fields; no Turnstile, rate limit, GDPR consent; a copy of the engine passes addresses from the Emails tab into HTML | the builder in the panel + `` (look: `formClasses`, unusual cases: `useBuilderForm`) | | a file input wired by hand, your own upload route, form files saved to Media / R2 / disk | candidate and customer documents end up public or kept forever; no type, size or macro checks; the gates are skipped | `forms: { attachments: true }` + the **File** field — the file is e-mailed to the company and never stored (forms.md "Files") | | your own `api/contact` / `api/send` / `api/form` route, `nodemailer` / `resend` / `@sendgrid` in the project | bypasses the `submitForm` validation and gates, a second mail transport | the `sendForm` server action → `submitForm`, mails from Forms → Emails via `mailAdapter()` | | reCAPTCHA, hCaptcha, your own captcha | a second mechanism, no status in the panel | Turnstile from the plugin | | a hand-written `