Payload Agent Rules

A TypeScript CMS and application backend integrated with Next.js.

Overview

Payload's detailed instructions live in CLAUDE.md; AGENTS.md only points there. The guide covers CMS architecture and test fixtures, with examples for access control, React memoization, CSS, and server/client imports.

Documents

├── 
├── 
└── packages
    ├── codemod
    │   └── 
    └── create-payload-app
        └── 

Techniques in this file

01 / Hard prohibitions

Make an unsafe default visible at the call site

Server functions and endpoints must supply both overrideAccess: false and the user to Payload operations. The guide contrasts a bare find call with the access-controlled form and explains the security consequence.

Source excerpt starting at line 342.
**Building server functions, views, or endpoints:** Always use `overrideAccess: false` and pass the `user` to payload operations. Without these, the operation runs with access control disabled, which is a security vulnerability.

02 / Behavioral framing

Put database lifecycle in the shared fixture

Integration tests use the shared wrapper rather than initializing Payload or seeding data themselves. The fixture owns setup, per-test reset, and cleanup, except in existing shared-state suites.

Source excerpt starting at line 173.
- Do not initialize Payload manually or add database reset/seed hooks; the fixture initializes  Payload once per file, resets and seeds before each test that uses it, and destroys it afterward

03 / Verification by change type

Make visual baselines reproducible across machines

Screenshot baselines must be generated inside the pinned Playwright Docker image. The reason is the effect of operating-system font rendering on comparisons, even when the UI has not changed.

Source excerpt starting at line 250.
- **Baselines must be generated/updated inside the pinned Playwright Docker image**, never on a  bare host — font rendering differs enough between operating systems to fail the comparison on  CI even when nothing visually changed. Use `pnpm test:visual:update`.

04 / Verification by change type

Verify bundling in the mode where it can fail

The server/client import rules explain why relative imports and barrel exports can cause production-only problems. The required verification builds and serves production output rather than relying on the dev server.

Source excerpt starting at line 466.
**Testing bundling changes:** Always test with `pnpm prepare-run-test-against-prod` followed by `pnpm dev:prod <suite>`. Dev mode (`pnpm dev`) doesn't catch these issues.

05 / Good and bad pairs

Show physical and logical CSS properties side by side

A bad/good pair replaces left and right properties with inline-direction equivalents. The example makes the RTL requirement concrete across spacing, borders, and positioning.

Source excerpt starting at line 390.
/* BAD - physical properties don't flip for RTL */padding-left: var(--spacer-3);margin-right: var(--spacer-2);border-left: 1px solid var(--color-border);left: 0; /* GOOD - logical properties adapt automatically */padding-inline-start: var(--spacer-3);margin-inline-end: var(--spacer-2);border-inline-start: var(--stroke-width-small) solid var(--color-border);inset-inline-start: 0;

Ideas for your repo

  1. Identify security-sensitive defaults and the parameters that override them.
  2. Give shared test fixtures clear ownership of setup and cleanup.
  3. Pin the environment used to generate visual baselines.
  4. Map production-only failure modes to production-mode checks.
Sponsored byModem

Give your agents the whole story.

These instructions explain how to work in Payload. Modem shows your agents what customers said, who is affected, and what changed.

See how Modem works