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) andnpm@10.9.x(^10.9.0, pinned viapackageManagerfor Corepack and enforced via.npmrcanddevEnginesinpackage.jsonanddocker/prisma-cli/package.json; runnvm useifnvmis available andcorepack enableorcorepack npmso Corepack selectsnpm@10.9.xautomatically). - Install dependencies:bash(Setting
CI=true npm ciCI=trueskips.githooksreconfiguration inside non-interactive sandboxes while still runningnext typegenunlessSKIP_NEXT_TYPEGEN=trueorSTATIC_EXPORT=true— as in theunit-test,build, andstatic-export-buildCI jobs — Prisma Client generation, non-wasm32optional WASM pruning, andnode_modules/.package-lock-hashrecording viapostinstall;npm run typecheckandnpm run type-checkreusenext-env.d.ts,.next/types/validator.ts, and.next/types/.route-manifest.jsonviascripts/quality/run-typecheck.mjswhen the SHA-256 route digest matches, and lockfile-only runs vianpm install --package-lock-onlyskip 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 publicindex.tsbarrel (@/features/<domain>) rather than deep internal paths (@/features/<domain>/*), enforced by ESLint (no-restricted-importsineslint.config.mjs). - Shared Components & Utilities (
src/components/,src/lib/,src/utils/,src/hooks/): Domain-agnostic UI primitives, stateless helpers, base-path helpers (resolveShowcasePathinsrc/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; seedocs/developer-setup.mdanddocs/runtime-contract.mdfor 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.tsandsrc/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:
tsconfig.json— Root workspace, Storybook, and VitePress config (compilerOptions.types: ["node", "jest", "@testing-library/jest-dom", "jest-axe"],incremental: true,tsBuildInfoFiledefaulting to./tsconfig.tsbuildinfo). Includesnext-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 excludingnode_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.tsxso scopes covered by the four specialized projects below are not redundantly re-checked.tsconfig.build.json— Isolated non-composite production Next.js build config referenced bytypescript.tsconfigPathinnext.config.ts(compilerOptions.types: ["node"],incremental: true,tsBuildInfoFile: "./tsconfig.build.tsbuildinfo"). Excludesnode_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.tsxsonpm run build(next build) validates only production runtime code.tsconfig.test.json— Extendstsconfig.jsonwithincremental: true(tsBuildInfoFile: "./tsconfig.test.tsbuildinfo") andtypes: ["node", "jest", "@testing-library/jest-dom", "jest-axe"], and includessrc/**/__tests__/**/*,src/**/*.test.{ts,tsx},scripts/**/*.test.ts,src/mocks/**/*.ts, andsrc/testing/**/*.ts.tsconfig.e2e.json— Extendstsconfig.jsonwithincremental: true(tsBuildInfoFile: "./tsconfig.e2e.tsbuildinfo") andtypes: ["node"], and checksplaywright.config.ts,playwright.static.config.ts,playwright.storybook.config.ts, ande2e/**/*.ts.tsconfig.scripts.json— Extendstsconfig.jsonwithincremental: true(tsBuildInfoFile: "./tsconfig.scripts.tsbuildinfo") andtypes: ["node"], and checksscripts/**/*.ts(excludingscripts/**/*.test.ts, without.tsimport extensions asallowImportingTsExtensionsis not enabled).
Run all five TypeScript projects in a single content-hashed scripts/quality/run-typecheck.mjs pass locally with:
npm run typecheck
# or
npm run type-checkTo check a single project during targeted edits:
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.json4. 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:
# 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-commitmaterializes the staged Git index (git write-tree) into an ephemeral snapshot directory (hydratingnode_modulesand path-rewritten.eslintcacheviascripts/quality/worktree-cache.mjs), runsnpx 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=0via a single unified{*.{js,jsx,ts,tsx,mjs,cjs,mts,cts},**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts},.githooks/*}glob, pluscheck:action-pins,lint:migrations,check:prisma -- --skip-generate,check:standalone -- --static-only,check:links,check:setup-guides, andcheck:runbookson staged workflows, migrations,prisma/schema.prismaandsrc/lib/readinessManifest.ts, container files,package.jsonandpackage-lock.jsonmanifests, added/modified/deleted Markdown docs anddocs-portal/.vitepress/config.mts,.nvmrcand.npmrc, andnext.config.ts), writeseslint --fixblobs 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-pushparsesstdinrefs, verifies dirty or untracked (git status --porcelain --untracked-files=normal) pushes inside an ephemeral detachedgit worktree(hydrating*.tsbuildinfo, path-rewritten.eslintcache, route-digest-matched.next/typesvia.next/types/.route-manifest.json, and schema-isolatednode_modules/.prismaviascripts/quality/worktree-cache.mjs), prepares Prisma Client once (ensurePrismaClientReady) before parallel workers start, and runs the checks aligned withnpm run check:pre-push(scripts/check-quality.ts --pre-push, includingtype-check,lint,lint:unused,check:prisma -- --skip-generate, conditionalcheck:auditwhen pushed commits modifypackage.jsonmanifests or lockfiles, and lightweight static checks withcheck:standalone -- --static-onlyincludingpackage.jsonlockfile specifier sync; see.github/CONTRIBUTING.md). - Targeted Iteration: Run
npm test -- <path/to/file.test.ts>(ornpm run test:watch) for fast cached unit/integration feedback without coverage overhead,npm run test:covto enforce global80%line and68%branch coverage thresholds,npm run typecheck && npm run lint && npm run lint:unusedfor 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(ornpm run test:e2e:storybookviaplaywright.storybook.config.ts) whenever modifying UI stories,.storybook/*, orsrc/mocks/handlers.ts(storybook-buildin CI passesneeds.verify.outputs.storybook_base_pathandcaller_holds_lock: trueto reusable.github/workflows/storybook.yml, auditing all stories in light and dark themes withoutputDir: 'test-results/playwright-storybook'andtrace: '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:staticwhenever modifying App Router pages, layouts, dynamic segments, demo handlers, or theme contrast tokens (scripts/build-export.mjsstages sources inside.next/export-stagewithoutsrc/app/api, caches under.next-export/cachewithtrailingSlash: trueand optionalNEXT_PUBLIC_BASE_PATH, andplaywright.static.config.tsaudits all exported subpath routes in light and dark themes withoutputDir: 'test-results/playwright-static'andtrace: 'retain-on-failure'inside thestatic-export-buildjob in.github/workflows/ci.yml, uploadingplaywright-static-tracesonif: failure()), andPAGES_BASE_PATH=/wedding_website/ npm run pages:build && PAGES_BASE_PATH=/wedding_website/ npm run pages:verify(orPAGES_BASE_PATH=/for root custom-domain /<owner>.github.iotopologies) when modifying cross-app showcase links ore2e/pages-showcase.spec.ts(verifyin CI resolvesportal_base_path,demo_base_path, andstorybook_base_pathviascripts/build-pages-bundle.mjs, propagating them tostorybook-build,static-export-build,pages-verify, andprepare-docs, wherepages-verifymergesdocs-portal-static,demo-static, andstorybook-static, runsnpm run pages:verifywith zero skips, and uploadspages-bundlegatingprepare-docsanddeploy-docs). - CI & Release Provenance Gates:
ci.ymlexecutes full verification (persisting content-hashed.eslintcachevia--cache-strategy contentand all five*.tsbuildinfofiles inverifywith2000-01-01T00:00:00Zpartial-hit backdating,node_modules/.cache/jestinunit-testafterSKIP_NEXT_TYPEGEN=true npm ci, andCRITICAL,HIGH, andMEDIUMTrivy container scans onamd64andarm64) on pull requests andmerge_groupmerge queue events (cancelling superseded runs onCI-<ref>), manualworkflow_dispatch, andmain+release/**pushes in isolated run-scopedCI-<ref>-<run_id>-<run_attempt>concurrency groups (omitting top-levelqueue: maxwhile passingcaller_holds_lock: truefromstorybook-buildtostorybook.ymlsocaller-storybook-<ref>-<run_id>-<run_attempt>runs never contend with standalonestorybook-<ref>queue: maxmanual dispatches) without duplicating runs onv*tags, retaining Playwright failure traces (trace: 'retain-on-failure'uploadingplaywright-tracesfromtest-results/playwright/ine2e-test,playwright-static-tracesfromtest-results/playwright-static/instatic-export-build, andplaywright-storybook-tracesfromtest-results/playwright-storybook/instorybook.ymlonif: failure()with 7-day retention), enforcing complete accessibility reports vianode scripts/a11y-report.mjs --include-static --include-storybook --require-completeina11y-report(if: always() && !cancelled(), while omitting--require-completepreserves exit0for partial local runs), generating and verifying strictSHA256SUMSmanifests viascripts/release-integrity.shforstorybook-staticandpages-bundleacrossstorybook-build(storybook.yml),pages-verify, andprepare-docs, attesting bundle checksums onmainpushes via checkout-freeattest-bundles(ci.yml) and on manual dispatches via checkout-freeattest-storybook(storybook.yml), aggregating all 9 verification jobs (verify,unit-test,build,container-arm64,storybook-build,static-export-build,e2e-test,a11y-report, andpages-verify) into a single read-onlyci-completegate (if: always() && !cancelled(),timeout-minutes: 5, active acrossrelease/**andworkflow_dispatch), and splitting GitHub Pages releases strictly onmainpushes into read-onlyprepare-docs(afterverify,ci-complete,static-export-build,storybook-build, andpages-verify, skipping commits behindorigin/mainHEADand reusingpages-bundlewheneveractions/configure-pagesmatchesverifyoutputs) and checkout-freedeploy-docs(pages: write,id-token: write,github-pagesFIFO queue);publish-artifact.ymlsplits read-onlypreflight+buildfrom checkout-freeupload-sarif(security-events: write) andpublish(packages: write,attestations: write,id-token: write), validates non-empty SPDX.packagesarrays andsha256-${arch}.sumshandoff checksums beforezstddecompression or OIDC signing, and promotes verified, OIDC-attestedghcr.io/<owner>/<repo>:<sha>digests directly onv*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 whenpromote_existing == 'true'(attesting thev*multi-platform index digest on all runs),deploy-provider.ymlsplits read-onlypreflightfrom checkout-freedeploy(verifyingRecord Migrated Commit (<target_sha>)fromdb-migrate.ymlinstandalone-gatewithouthead_shafilters and mirroring paginated trustedci.ymlchecks ininline-rollback) while reusable workflows pass minimal explicit secret maps (neversecrets: inherit, isolatingDATABASE_URLtodb-migrate.ymlafter its read-onlypreflightgate and resolving active environment deploymentBASE_SHAdiffs viadeployments: readindeploy.ymlschema-compatibilitywithoutnpm ciorDATABASE_URL) and scope registry logins to temporaryDOCKER_CONFIGdirectories enforced bynpm run check:action-pins(runnpm run check:staticlocally to verifycheck:action-pinsandcheck:runbooks),release.ymlsplitsv*GitHub Release publication into read-onlyprepare-releaseand checkout-freepublish-releaseto publish OIDC-attestedSHA256SUMS, SPDX SBOMs, Track C archives, andCHANGELOG.mdnotes, andpublish-artifact.yml,release.yml,db-migrate.yml,deploy-provider.yml, anddeploy.ymlcentralize release commit/tag eligibility and paginated trustedci.ymlverification (--ci-only,--poll-ci,exclude_pull_requests=true,push/workflow_dispatchevents, non-nullhead_repository, latestupdated_atsuccess) viascripts/verify-release-target.sh(origin/mainancestry or OIDC-attestedrefs/tags/v*maintenance provenance forN-1origin/release/*tags resolved viascripts/resolve-oci-provenance.sh), updating:latest/make_latestonly for the highest stableorigin/mainvMAJOR.MINOR.PATCHrelease tag. - Authoritative Testing & Setup Runbooks: Refer to
.github/TESTING.mdforscripts/pretest.mjswedding_testdatabase 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:containersharing unauthenticated/guest/loginredaction and authenticatedSIGTERMexit-143lock draining viascripts/smoke-runner.mjs), todocs/versioning.mdfor zero-downtime SQL migration rules enforced bynpm run lint:migrations(scripts/verify-migration-compatibility.ts, requiring dedicated single-statementCREATE INDEX CONCURRENTLY/DROP INDEX CONCURRENTLYfiles withoutBEGINto avoid PostgreSQL error25001and requiringNOT VALID+VALIDATE CONSTRAINTforCHECK/FOREIGN KEYconstraints andUNIQUE USING INDEXon pre-existing tables), and todocs/developer-setup.mdfor local.envandSetupWizardbootstrap.
5. Repository Conventions & Guardrails
- Strict Compiler & Linter Rules: Preserve
strict,noUnusedLocals, andnoUnusedParametersintsconfig.json, and keep ESLint (--max-warnings 0innpm run lint,--max-warnings=0inlint-staged, and the shrink-onlyLEGACY_EXPLICIT_ANY_BASELINE_FILESratchet ineslint.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-errordirectives. - API Route Middleware: Wrap Next.js route handlers with
withApiMiddleware(src/utils/withApiMiddleware.ts). Zero-argument handlers (e.g.withApiMiddleware(async () => ...)) and optionalcontextin direct unit test calls (await GET(req)) are supported. - Playwright Auth Helpers: Import E2E cookie generators and context seeders strictly from
e2e/helpers/auth.tsrather than duplicating HMAC token signing insidee2e/*.spec.tsfiles (see.github/TESTING.mdfor secret alignment rules). - Typed Test Fixtures & Knip: Build test data with
createMockMedia(src/testing/factories/mediaFactory.ts) andcreateMockRegistryItem,createMockContributor,createMockCreateRegistryItemInput, orcreateMockInvitationCode(src/testing/factories/registryFactory.ts) whenever schemas insrc/features/media/schemas.tsorsrc/features/registry/schemas.tsevolve. Register any new test-only helper entrypoints inknip.jsonsonpm run lint:unusedreports 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.