Skip to content

Agent & Contributor Guidelines (AGENTS.md) ​

This guide defines the local bootstrap, architecture boundaries, TypeScript configuration split, end-to-end authentication conventions, verification commands, and continuous integration guardrails for coding agents and contributors working in this repository.

1. Environment Bootstrap ​

  • Node.js & npm: Node.js v22.x LTS (>=22.22.1 <23.0.0, pinned in .nvmrc) and npm@10.9.x (^10.9.0, pinned via packageManager for Corepack and enforced via .npmrc and devEngines in package.json and docker/prisma-cli/package.json; run nvm use if nvm is available and corepack enable or corepack npm so Corepack selects npm@10.9.x automatically).
  • Install dependencies:
    bash
    CI=true npm ci
    (Setting CI=true skips .githooks reconfiguration inside non-interactive sandboxes while still running next typegen unless SKIP_NEXT_TYPEGEN=true or STATIC_EXPORT=true — as in the unit-test, build, and static-export-build CI jobs — Prisma Client generation, non-wasm32 optional WASM pruning, and node_modules/.package-lock-hash recording via postinstall; npm run typecheck and npm run type-check reuse next-env.d.ts, .next/types/validator.ts, and .next/types/.route-manifest.json via scripts/quality/run-typecheck.mjs when the SHA-256 route digest matches, and lockfile-only runs via npm install --package-lock-only skip binary/hash hooks safely.)
  • Regenerate Prisma Client (after schema edits):
    bash
    npm run prisma:generate

2. Architecture & Module Boundaries ​

  • App Router (src/app/): Next.js pages, layouts, metadata builders, and HTTP route handlers (src/app/api/**/route.ts).
  • Core Infrastructure (src/core/): Authentication (src/core/auth/), session helpers, and framework-level services.
  • Feature Modules (src/features/<domain>/): Domain logic, schemas, services, and repositories (broadcast, content, logistics, media, registry, seating, sub-events, weather). Cross-domain imports must strictly go through each feature's public index.ts barrel (@/features/<domain>) rather than deep internal paths (@/features/<domain>/*), enforced by ESLint (no-restricted-imports in eslint.config.mjs).
  • Shared Components & Utilities (src/components/, src/lib/, src/utils/, src/hooks/): Domain-agnostic UI primitives, stateless helpers, base-path helpers (resolveShowcasePath in src/lib/basePath.ts), and API route middleware (src/utils/withApiMiddleware.ts). Keep runtime code portable and free of personal domains or tenant identifiers (npm run check:identifiers).
  • Interactive Static Showcase Runtime (STATIC_EXPORT / npm run build:export): Compiles a database-free interactive browser showcase (out/) with deterministic sample archetypes, client-side /api/* interception, and simulated registry checkout; see docs/developer-setup.md and docs/runtime-contract.md for the canonical demo storage and module architecture.
  • Test Fixtures & Mocks (src/testing/factories/, src/mocks/): Typed Zod-aligned test fixture builders (src/testing/factories/mediaFactory.ts and src/testing/factories/registryFactory.ts) and MSW handlers/server used in Jest tests and Storybook.
  • End-to-End Suite (e2e/): Playwright browser, crawler, metadata, and accessibility specs (e2e/*.spec.ts), standalone static showcase and Storybook runtime/a11y audits (e2e/static/*.audit.ts, e2e/storybook/*.audit.ts), plus shared E2E helpers (e2e/helpers/).
  • Repository Scripts (scripts/): CLI verification, OpenAPI/architecture sync, VitePress portal staging, and database seeding scripts.

3. TypeScript Configuration Split ​

TypeScript verification is split across five incremental project files verified together in a single Node.js process via scripts/quality/run-typecheck.mjs (ts.createIncrementalProgram keyed on SHA-256 file content hashes rather than filesystem mtime timestamps, after validating next-env.d.ts, .next/types/validator.ts, and .next/types/.route-manifest.json) so each scope is checked without duplicate .d.ts loads while production builds never absorb test, Storybook, VitePress, or runner globals:

  1. tsconfig.json — Root workspace, Storybook, and VitePress config (compilerOptions.types: ["node", "jest", "@testing-library/jest-dom", "jest-axe"], incremental: true, tsBuildInfoFile defaulting to ./tsconfig.tsbuildinfo). Includes next-env.d.ts, root configs (*.ts, *.mts, jest.config.mjs), src/**/*.d.ts, .storybook/**/*, src/**/*.stories.{ts,tsx}, docs-portal/**/*.{ts,mts}, docs-portal/.vitepress/**/*, and .next/types/**/*.ts, while excluding node_modules, jest.setup.js, out, .next-export, .next/export-stage, storybook-static, coverage, playwright-report, test-results, docs-portal/.vitepress/cache, docs-portal/.vitepress/dist, docs-portal/.vitepress/.temp, next.config.ts, playwright.config.ts, playwright.static.config.ts, playwright.storybook.config.ts, e2e, scripts, src/mocks, src/testing, **/__tests__/**/*, **/*.test.ts, **/*.test.tsx, **/*.spec.ts, and **/*.spec.tsx so scopes covered by the four specialized projects below are not redundantly re-checked.
  2. tsconfig.build.json — Isolated non-composite production Next.js build config referenced by typescript.tsconfigPath in next.config.ts (compilerOptions.types: ["node"], incremental: true, tsBuildInfoFile: "./tsconfig.build.tsbuildinfo"). Excludes node_modules, out, storybook-static, jest.setup.js, scripts, e2e, .storybook, docs-portal, playwright.config.ts, playwright.static.config.ts, playwright.storybook.config.ts, prisma.config.ts, src/mocks, src/testing, **/*.stories.ts, **/*.stories.tsx, **/__tests__/**/*, **/*.test.ts, **/*.test.tsx, **/*.spec.ts, and **/*.spec.tsx so npm run build (next build) validates only production runtime code.
  3. tsconfig.test.json — Extends tsconfig.json with incremental: true (tsBuildInfoFile: "./tsconfig.test.tsbuildinfo") and types: ["node", "jest", "@testing-library/jest-dom", "jest-axe"], and includes src/**/__tests__/**/*, src/**/*.test.{ts,tsx}, scripts/**/*.test.ts, src/mocks/**/*.ts, and src/testing/**/*.ts.
  4. tsconfig.e2e.json — Extends tsconfig.json with incremental: true (tsBuildInfoFile: "./tsconfig.e2e.tsbuildinfo") and types: ["node"], and checks playwright.config.ts, playwright.static.config.ts, playwright.storybook.config.ts, and e2e/**/*.ts.
  5. tsconfig.scripts.json — Extends tsconfig.json with incremental: true (tsBuildInfoFile: "./tsconfig.scripts.tsbuildinfo") and types: ["node"], and checks scripts/**/*.ts (excluding scripts/**/*.test.ts, without .ts import extensions as allowImportingTsExtensions is not enabled).

Run all five TypeScript projects in a single content-hashed scripts/quality/run-typecheck.mjs pass locally with:

bash
npm run typecheck
# or
npm run type-check

To check a single project during targeted edits:

bash
npx tsc --noEmit -p tsconfig.json
npx tsc --noEmit -p tsconfig.build.json
npx tsc --noEmit -p tsconfig.test.json
npx tsc --noEmit -p tsconfig.e2e.json
npx tsc --noEmit -p tsconfig.scripts.json

4. Verification & Quality Gates ​

Invoke the unified quality workflow in scripts/check-quality.ts instead of running copied step lists manually — npm run check:static, npm run check:pre-push, npm run quality, and .github/workflows/ci.yml all share step definitions from scripts/check-quality.ts:

bash
# Fast static, contract, doc-sync, and container digest checks:
npm run check:static

# Shared local pre-push profile (static checks with check:standalone --static-only, typecheck, lint, Knip, and check:audit):
npm run check:pre-push

# Full verification (static checks, typecheck, lint, Knip, check:audit, docs:build, build-storybook, build:export, and Jest coverage):
npm run quality
  • Split Local Git Hooks: .githooks/pre-commit materializes the staged Git index (git write-tree) into an ephemeral snapshot directory (hydrating node_modules and path-rewritten .eslintcache via scripts/quality/worktree-cache.mjs), runs npx lint-staged (--no-stash --no-revert --no-hide-partially-staged --diff=--staged --diff-filter=ACMRD: eslint --cache --cache-location .eslintcache --cache-strategy content --no-warn-ignored --no-error-on-unmatched-pattern --fix --max-warnings=0 via a single unified {*.{js,jsx,ts,tsx,mjs,cjs,mts,cts},**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts},.githooks/*} glob, plus check:action-pins, lint:migrations, check:prisma -- --skip-generate, check:standalone -- --static-only, check:links, check:setup-guides, and check:runbooks on staged workflows, migrations, prisma/schema.prisma and src/lib/readinessManifest.ts, container files, package.json and package-lock.json manifests, added/modified/deleted Markdown docs and docs-portal/.vitepress/config.mts, .nvmrc and .npmrc, and next.config.ts), writes eslint --fix blobs back to the active Git index, and applies non-conflicting fix hunks to the working tree without stashing or resetting workspace edits, while .githooks/pre-push parses stdin refs, verifies dirty or untracked (git status --porcelain --untracked-files=normal) pushes inside an ephemeral detached git worktree (hydrating *.tsbuildinfo, path-rewritten .eslintcache, route-digest-matched .next/types via .next/types/.route-manifest.json, and schema-isolated node_modules/.prisma via scripts/quality/worktree-cache.mjs), prepares Prisma Client once (ensurePrismaClientReady) before parallel workers start, and runs the checks aligned with npm run check:pre-push (scripts/check-quality.ts --pre-push, including type-check, lint, lint:unused, check:prisma -- --skip-generate, conditional check:audit when pushed commits modify package.json manifests or lockfiles, and lightweight static checks with check:standalone -- --static-only including package.json lockfile specifier sync; see .github/CONTRIBUTING.md).
  • Targeted Iteration: Run npm test -- <path/to/file.test.ts> (or npm run test:watch) for fast cached unit/integration feedback without coverage overhead, npm run test:cov to enforce global 80% line and 68% branch coverage thresholds, npm run typecheck && npm run lint && npm run lint:unused for static code health, NEXT_PUBLIC_BASE_PATH="/wedding_website/storybook" npm run build-storybook && NEXT_PUBLIC_BASE_PATH="/wedding_website/storybook" npm run test:a11y:storybook (or npm run test:e2e:storybook via playwright.storybook.config.ts) whenever modifying UI stories, .storybook/*, or src/mocks/handlers.ts (storybook-build in CI passes needs.verify.outputs.storybook_base_path and caller_holds_lock: true to reusable .github/workflows/storybook.yml, auditing all stories in light and dark themes with outputDir: 'test-results/playwright-storybook' and trace: 'retain-on-failure'), NEXT_PUBLIC_BASE_PATH="/wedding_website/demo" npm run build:export && NEXT_PUBLIC_BASE_PATH="/wedding_website/demo" npm run test:e2e:static whenever modifying App Router pages, layouts, dynamic segments, demo handlers, or theme contrast tokens (scripts/build-export.mjs stages sources inside .next/export-stage without src/app/api, caches under .next-export/cache with trailingSlash: true and optional NEXT_PUBLIC_BASE_PATH, and playwright.static.config.ts audits all exported subpath routes in light and dark themes with outputDir: 'test-results/playwright-static' and trace: 'retain-on-failure' inside the static-export-build job in .github/workflows/ci.yml, uploading playwright-static-traces on if: failure()), and PAGES_BASE_PATH=/wedding_website/ npm run pages:build && PAGES_BASE_PATH=/wedding_website/ npm run pages:verify (or PAGES_BASE_PATH=/ for root custom-domain / <owner>.github.io topologies) when modifying cross-app showcase links or e2e/pages-showcase.spec.ts (verify in CI resolves portal_base_path, demo_base_path, and storybook_base_path via scripts/build-pages-bundle.mjs, propagating them to storybook-build, static-export-build, pages-verify, and prepare-docs, where pages-verify merges docs-portal-static, demo-static, and storybook-static, runs npm run pages:verify with zero skips, and uploads pages-bundle gating prepare-docs and deploy-docs).
  • CI & Release Provenance Gates: ci.yml executes full verification (persisting content-hashed .eslintcache via --cache-strategy content and all five *.tsbuildinfo files in verify with 2000-01-01T00:00:00Z partial-hit backdating, node_modules/.cache/jest in unit-test after SKIP_NEXT_TYPEGEN=true npm ci, and CRITICAL, HIGH, and MEDIUM Trivy container scans on amd64 and arm64) on pull requests and merge_group merge queue events (cancelling superseded runs on CI-<ref>), manual workflow_dispatch, and main + release/** pushes in isolated run-scoped CI-<ref>-<run_id>-<run_attempt> concurrency groups (omitting top-level queue: max while passing caller_holds_lock: true from storybook-build to storybook.yml so caller-storybook-<ref>-<run_id>-<run_attempt> runs never contend with standalone storybook-<ref> queue: max manual dispatches) without duplicating runs on v* tags, retaining Playwright failure traces (trace: 'retain-on-failure' uploading playwright-traces from test-results/playwright/ in e2e-test, playwright-static-traces from test-results/playwright-static/ in static-export-build, and playwright-storybook-traces from test-results/playwright-storybook/ in storybook.yml on if: failure() with 7-day retention), enforcing complete accessibility reports via node scripts/a11y-report.mjs --include-static --include-storybook --require-complete in a11y-report (if: always() && !cancelled(), while omitting --require-complete preserves exit 0 for partial local runs), generating and verifying strict SHA256SUMS manifests via scripts/release-integrity.sh for storybook-static and pages-bundle across storybook-build (storybook.yml), pages-verify, and prepare-docs, attesting bundle checksums on main pushes via checkout-free attest-bundles (ci.yml) and on manual dispatches via checkout-free attest-storybook (storybook.yml), aggregating all 9 verification jobs (verify, unit-test, build, container-arm64, storybook-build, static-export-build, e2e-test, a11y-report, and pages-verify) into a single read-only ci-complete gate (if: always() && !cancelled(), timeout-minutes: 5, active across release/** and workflow_dispatch), and splitting GitHub Pages releases strictly on main pushes into read-only prepare-docs (after verify, ci-complete, static-export-build, storybook-build, and pages-verify, skipping commits behind origin/main HEAD and reusing pages-bundle whenever actions/configure-pages matches verify outputs) and checkout-free deploy-docs (pages: write, id-token: write, github-pages FIFO queue); publish-artifact.yml splits read-only preflight + build from checkout-free upload-sarif (security-events: write) and publish (packages: write, attestations: write, id-token: write), validates non-empty SPDX .packages arrays and sha256-${arch}.sums handoff checksums before zstd decompression or OIDC signing, and promotes verified, OIDC-attested ghcr.io/<owner>/<repo>:<sha> digests directly on v* tag pushes and manual dispatches (falling back to native matrix builds if absent) while skipping per-architecture provenance and GHCR per-architecture SBOM re-signing when promote_existing == 'true' (attesting the v* multi-platform index digest on all runs), deploy-provider.yml splits read-only preflight from checkout-free deploy (verifying Record Migrated Commit (<target_sha>) from db-migrate.yml in standalone-gate without head_sha filters and mirroring paginated trusted ci.yml checks in inline-rollback) while reusable workflows pass minimal explicit secret maps (never secrets: inherit, isolating DATABASE_URL to db-migrate.yml after its read-only preflight gate and resolving active environment deployment BASE_SHA diffs via deployments: read in deploy.yml schema-compatibility without npm ci or DATABASE_URL) and scope registry logins to temporary DOCKER_CONFIG directories enforced by npm run check:action-pins (run npm run check:static locally to verify check:action-pins and check:runbooks), release.yml splits v* GitHub Release publication into read-only prepare-release and checkout-free publish-release to publish OIDC-attested SHA256SUMS, SPDX SBOMs, Track C archives, and CHANGELOG.md notes, and publish-artifact.yml, release.yml, db-migrate.yml, deploy-provider.yml, and deploy.yml centralize release commit/tag eligibility and paginated trusted ci.yml verification (--ci-only, --poll-ci, exclude_pull_requests=true, push/workflow_dispatch events, non-null head_repository, latest updated_at success) via scripts/verify-release-target.sh (origin/main ancestry or OIDC-attested refs/tags/v* maintenance provenance for N-1 origin/release/* tags resolved via scripts/resolve-oci-provenance.sh), updating :latest / make_latest only for the highest stable origin/main vMAJOR.MINOR.PATCH release tag.
  • Authoritative Testing & Setup Runbooks: Refer to .github/TESTING.md for scripts/pretest.mjs wedding_test database isolation and preflight hash caching, Playwright E2E execution (npm run test:e2e), WCAG 2.2 AA accessibility audits (npm run test:a11y, npm run test:a11y:static, npm run test:a11y:storybook), PostgreSQL migration drift and readiness manifest parity checks (npm run check:prisma), and standalone/container smoke tests (npm run test:standalone, npm run test:container sharing unauthenticated /guest/login redaction and authenticated SIGTERM exit-143 lock draining via scripts/smoke-runner.mjs), to docs/versioning.md for zero-downtime SQL migration rules enforced by npm run lint:migrations (scripts/verify-migration-compatibility.ts, requiring dedicated single-statement CREATE INDEX CONCURRENTLY / DROP INDEX CONCURRENTLY files without BEGIN to avoid PostgreSQL error 25001 and requiring NOT VALID + VALIDATE CONSTRAINT for CHECK / FOREIGN KEY constraints and UNIQUE USING INDEX on pre-existing tables), and to docs/developer-setup.md for local .env and SetupWizard bootstrap.

5. Repository Conventions & Guardrails ​

  • Strict Compiler & Linter Rules: Preserve strict, noUnusedLocals, and noUnusedParameters in tsconfig.json, and keep ESLint (--max-warnings 0 in npm run lint, --max-warnings=0 in lint-staged, and the shrink-only LEGACY_EXPLICIT_ANY_BASELINE_FILES ratchet in eslint.config.mjs) and Axe (src/a11y-config.ts) error-clean. Fix types and lint errors at the source instead of disabling rules or adding @ts-ignore / @ts-expect-error directives.
  • API Route Middleware: Wrap Next.js route handlers with withApiMiddleware (src/utils/withApiMiddleware.ts). Zero-argument handlers (e.g. withApiMiddleware(async () => ...)) and optional context in direct unit test calls (await GET(req)) are supported.
  • Playwright Auth Helpers: Import E2E cookie generators and context seeders strictly from e2e/helpers/auth.ts rather than duplicating HMAC token signing inside e2e/*.spec.ts files (see .github/TESTING.md for secret alignment rules).
  • Typed Test Fixtures & Knip: Build test data with createMockMedia (src/testing/factories/mediaFactory.ts) and createMockRegistryItem, createMockContributor, createMockCreateRegistryItemInput, or createMockInvitationCode (src/testing/factories/registryFactory.ts) whenever schemas in src/features/media/schemas.ts or src/features/registry/schemas.ts evolve. Register any new test-only helper entrypoints in knip.json so npm run lint:unused reports zero unused files or exports.
  • Feature Module Boundaries & Scaffolding: Scaffold new domains with npm run scaffold -- <feature-name> and import cross-feature code strictly through public barrel files (@/features/<feature>) rather than deep internal paths (@/features/<feature>/*), as documented in .github/CONTRIBUTING.md.
  • Action Pinning: Always pin third-party GitHub Actions to 40-character commit SHAs with a trailing version comment (e.g., # v7.0.1).
  • Further Reading: See Developer Setup Guide, Testing Strategy, Contribution Guidelines, and Application Runtime Contract.

Released under the AGPL-3.0 License.