payload

Guides Payload CMS development with collections, fields, hooks, access control, and query patterns.

Updated Sep 1, 2021
One-click install
npx skills add https://github.com/WP-Coaching/pellegrims.coach --skill payload-wp-coaching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: payload
Source: https://github.com/WP-Coaching/pellegrims.coach/tree/main/.agents/skills/payload
Command: npx skills add https://github.com/WP-Coaching/pellegrims.coach --skill payload-wp-coaching

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Developers working with Payload CMS often struggle with correct configuration of collections, fields, hooks, and access control, and commonly hit security pitfalls like bypassed access control in the Local API or broken transactions in hooks. This Skill provides structured, production-tested guidance for Payload development tasks. ## Core Features & Use Cases - Collection & Field Configuration: Covers auth collections, uploads, drafts, live preview, all field types including relationships, arrays, blocks, joins, and virtual fields. - Access Control & Security: Documents RBAC patterns, row-level security with query constraints, multi-tenant access, and critical pitfalls like the overrideAccess: false requirement in Local API operations. - Hooks, Queries & Transactions: Explains beforeChange/afterChange hooks, preventing infinite hook loops with context flags, threading req through nested operations for transaction atomicity, and Local/REST/GraphQL query patterns. - Use Case: When building a Next.js app with Payload and you need to restrict posts so users only see their own content, the Skill provides the exact row-level access control pattern with type-safe user checks. ## Quick Start Ask the agent how to implement a Payload feature such as row-level access control or a slug auto-generation hook in your payload.config.ts project.

Frequently Asked Questions about payload

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement row-level access control in Payload CMS?

Return a Where query constraint from a collection access function instead of a boolean, such as { author: { equals: user.id } }. Admins can return true to bypass the constraint, while other users get filtered results at the database level.

How do I auto-generate slugs in Payload collections?

Use the slugField() helper or a beforeChange hook that sets data.slug from the title during the create operation. The hook receives the operation type so you only slugify on creation.

Why is Payload Local API ignoring my access control rules?

Local API operations bypass access control by default because overrideAccess defaults to true, even when you pass a user. Set overrideAccess: false alongside the user parameter to enforce that user's permissions.

Which database adapters does Payload CMS support?

Payload supports MongoDB via @payloadcms/db-mongodb, Postgres via @payloadcms/db-postgres, and SQLite via @payloadcms/db-sqlite. MongoDB requires a replica set for transactions, and SQLite needs transactionOptions enabled.

How do I prevent infinite loops in Payload hooks?

Check a flag in req.context at the start of the hook and return early if set, then pass that flag in the context of the nested operation. This stops an afterChange hook from retriggering itself when it updates the same document.

Does Payload support draft and publish workflows?

Yes, set versions: { drafts: true } on a collection to enable a _status field with draft, published, and changed states. It also supports autosave, scheduled publishing, and draft-aware access control queries.