Files

8.1 KiB

name, description
name description
iapl-audit Audits an IAPL (Payload 3 + Next 16) project against AGENT.md rules with a deterministic script — the mandatory feature set (SEO, JSON-LD, llms.txt, Markdown, MCP, R2, Turnstile, panel forms, consent, 2FA, health, env, security headers, X-Powered-By, CSP), forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written JSON-LD), hardcoded texts/links, forbidden field names, monolithic sections, middleware.ts, missing ISR/generateStaticParams, hex colors, server imports in client components, extra collections, then tsc and build. Use before saying a task is done, after any block/collection/layout change, after an Impeccable pass, and when asked to review or audit the project.

iapl-audit

The checks from AGENT.md §11 as a script — always the same, no interpretation.

Steps

  1. From the project root, run:
    bash .agents/skills/iapl-audit/scripts/audit.sh --quick   # while working
    bash .agents/skills/iapl-audit/scripts/audit.sh           # before "done" (+ tsc + build)
    
    Options: --help. Do not read the script source — the output is enough.
  2. Show the user the full output (summary + list of violations).
  3. Fix every [ERROR] or — if it is a deliberate exception — add a code comment with the reason and list it in your answer. Each violation names a section in node_modules/@intecion/ipal-kit/docs/agent/AGENT.md — read it before fixing.
  4. [WARNING] — assess it and tell the user what to do about it; do not fix it blindly (e.g. searchParams is OK in a paginated archive route).
  5. Run again until the output is 0 error(s).

"missing: …" — the mandatory set (AGENT.md §0b)

Every [ERROR] missing: X is an item of the set that the code lacks. Wire it following the hint (PROGRAMISTA §2) — do not ask whether it is needed. The only exception: a client decision recorded in AGENTS.md as iapl-audit-skip: <keys> — <reason> (keys in AGENT.md §0b). Never add that line yourself just to make the audit pass.

Polish text and panel labels (AGENT.md §2, §6.5a)

hardcoded Polish text in code covers public text. In a schema file (a .ts file under collections/, globals/, fields/ or blocks/, or one importing Payload's schema types) the panel's own labels are fine: adminText('Title', 'Tytuł'), { en, pl } as label, singular, plural, description, placeholder or group, a rowLabel() fallback, a const x: AdminText. Still an error: any .tsx file, a Polish-only label, other keys, anything under defaultValue.

Design tokens (AGENT.md §6.11)

The script checks: hex in classes and inline styles (error), dark: on colour utilities and var(--color-…) in classes (warnings), styles.css without @intecion/ipal-kit/tokens.css (warning — a site not yet migrated), next/font in --font-body with the preset (warning), and with src/design/tokens.ts: no DESIGN.md (warning) and iapl-tokens --check — a stale src/design/tokens.css or a WCAG AA contrast failure is an error.

Speed (AGENT.md §6.11b, docs/performance.md)

The full run (not --quick) lists the doctor's performance group as errors (since 1.18.0; a rule the project lowered in iapl-doctor.json shows as a warning): next.config without buildImagesConfig(), fonts from Google or with display: 'block', more than two families, a blocking <script src> or a remote stylesheet, an <iframe> that loads with the page, transitions of layout properties, transition-all, scroll listeners, animations with nothing for reduced motion. The iapl-performance skill measures the built site and adds the budget test.

iapl-audit and iapl-doctor

iapl-audit checks the code inside the edit loop (and tsc + build). pnpm exec iapl-doctor checks the site against the team standard: it runs this script (--quick) from the installed package, reports its findings under its own rule ids (i18n-literals, blocks-tokens, audit:<title>, one per file), and adds versions, Node, layout, database names, env, admin, AGENTS.md, skills, seeds and — with --url / --deep — the running site and the database (the iapl-doctor skill, docs/doctor.md). An approved exception for the doctor goes into iapl-doctor.json with a reason.

What the script does not check (do it by hand)

  • Closed doors and judged routes (security.md "Closed doors from outside", "Routes nobody has judged"): resources/closed-doors.spec.template.ts → tests/closed-doors.spec.ts (add the project's own doors; run on a production build as anonymous, customer and editor) and resources/routes.template.ts → tests/routes.ts (pnpm payload run tests/routes.ts update once, write a reason per route, commit the snapshot; then pnpm payload run tests/routes.ts fails on a route nobody has judged). A new custom endpoint, collection or route file of the project = a new snapshot entry with its reason, and a door in DOORS if it must stay closed.

  • Attack probes and static security rules (security.md "Security suites"): resources/attack-probes.spec.template.ts → tests/attack-probes.spec.ts, run on a production build or staging (BASE_URL=… PAGE=/pl pnpm exec playwright test tests/attack-probes.spec.ts): the plugin's ATTACK_PROBES, plus the project's own in EXTRA for every custom endpoint. On the live site: pnpm exec iapl-doctor --url https://<domain> --only live-probes. The code side: pnpm exec iapl-doctor --only security (code-patterns, config-dangerous); a correct place gets // iapl-security-ok: <why>. Dependencies: pnpm audit --prod (the doctor's deps-audit) — no high or critical. Every address field rendered into href (social profiles, a website) is buildUrlField() and rendered through safeHref() (security.md "Addresses rendered into href"); the static rules do not flag an href from data.

  • Editor test (AGENT.md §11): every text, image, button, section, menu, footer and SEO field can be changed in the panel, in every language.

  • Cookie consent: in Network, before accepting, there are no requests to google-analytics / googletagmanager (except Consent Mode), facebook.net, clarity.ms, licdn, tiktok.

  • Content: fallbacks contain no client data (|| 'Firma X').

  • Response headers (on a running build — pnpm build && pnpm start, or the deployed domain):

    U=http://localhost:3000
    for p in /pl /admin /api/health; do echo "== $p"; curl -sI "$U$p" | grep -iE 'x-powered-by|content-security-policy|critical-ch'; done
    

    x-powered-by anywhere → ERROR (withSecurityConfig, security.md → "X-Powered-By"). critical-ch on /pl or /api/health → INFO: Chrome repeats the first request of every visit; make withSecurityConfig the outer wrapper, withSecurityConfig(withPayload(nextConfig)) (security.md → "Client hints"); on /admin it belongs. No content-security-policy / content-security-policy-report-only on /pl and /admin → WARNING (CSP not rolled out). Report-only for more than a few weeks with clean reports → WARNING (switch to mode: 'enforce'). Then open /pl and /admin in the browser: CSP lines in the console = missing sources (flags / extra).

  • Drafts and locales over the API (a collection with versions: { drafts: true }): without a session, curl -s "$U/api/<slug>?draft=true&limit=100" | grep -c '"_status":"draft"' → 0, else ERROR: give it access: { read: readPublished(), readVersions: readPublishedVersions() } (access.md). curl -s -o /dev/null -w '%{http_code}' "$U/api/<slug>/versions?limit=10" → 200 (a 500 = a rule with the document's _status path on readVersions: ERROR). curl -sI "$U/md/xx" → 404 (no stand-in locale); a 404 page assigned in System pages must be published.

  • Secrets out of queries (as an admin, with versions on for Site integrations or a collection using writeOnlySecret): curl -s -H "Authorization: JWT $T" "$U/api/globals/site-integrations/versions?where[version.smtpPassword][exists]=true" answers an error with no totalDocs, else ERROR (the field lost secretReadAccess, e.g. an override replaced its access).

Do not say "done" until the full audit (without --quick) has no errors.