Skip to content
payload logo

Payload CMS Skill

payload

Expert guidance for building with Payload CMS - collections, fields, hooks, access control, Local API, authentication, uploads, and admin theming

SKILL.md

Full skill instructions

Payload CMS Skill

Comprehensive reference for Payload CMS development including data modeling, API usage, and admin customization.

Overview

Payload is a headless CMS and application framework built on Next.js. This skill covers collections, fields, hooks, access control, Local API operations, authentication, uploads, globals, plugins, and admin panel styling.

Quick Reference: Which File Do I Need?

TaskReference File
Create/​configure a collectioncollections.md
Add fields to a collectionfields.md
Run code before/​after operationshooks.md
Control who can read/​write dataaccess-control.md
Query or mutate data server-sidelocal-api.md
Use REST API externallyrest-api.md
Use GraphQL APIgraphql.md
Set up user login/​authauthentication.md
Handle file/​image uploadsuploads.md
Organize uploads in foldersfolders.md
Create site-wide settingsglobals.md
Add official plugins (SEO, forms)plugins.md
Theme the admin paneladmin-styling.md
Build custom admin componentscustom-components.md
Configure rich text editorrich-text.md
Set up live previewlive-preview.md
Enable drafts/​versionsversions.md
Configure database/​migrationsdatabase.md
Customize payload.config.tsconfiguration.md
Set up email/​notificationsemail.md
Background jobs/​schedulingjobs-queue.md
Saved list view filtersquery-presets.md
Soft delete/​trashtrash.md
TypeScript type generationtypescript.md
Deploy to productionproduction.md

Reference Files Summary

Core Data & API

FileLinesDescription
collections.md~200Collection config, slugs, admin options
fields.md~220All field types, validation, conditional logic
globals.md~50Single-document data (settings, nav)
hooks.md~170Lifecycle hooks for collections, fields, globals
access-control.md~200Permissions, RBAC, query constraints
local-api.md~190Server-side find, create, update, delete
rest-api.md~240REST endpoints, query params, auth headers
graphql.md~245GraphQL queries, mutations, schema

Authentication & Users

FileLinesDescription
authentication.md~200Auth config, strategies, password reset
email.md~180Email adapters (Nodemailer, Resend), templates

Content & Media

FileLinesDescription
uploads.md~60Media uploads, image sizes, storage adapters
folders.md~120Organize uploads in folder hierarchies
rich-text.md~270Lexical editor, features, serialization
versions.md~265Drafts, publishing, autosave, version history
trash.md~115Soft delete, restore, permanent delete

Admin Panel

FileLinesDescription
admin-styling.md~180CSS variables, BEM classes, theming
custom-components.md~300Field/​Cell/​View components, React hooks
live-preview.md~215Real-time content preview in admin
query-presets.md~125Saved filters for list views

Configuration & Infrastructure

FileLinesDescription
configuration.md~240payload.config.ts structure, all options
database.md~200MongoDB/​Postgres adapters, migrations
plugins.md~60Official plugins and installation
typescript.md~220Type generation, payload-types.ts
jobs-queue.md~215Background tasks, workers, scheduling
production.md~190Deployment (Vercel, Docker), env vars

Common Workflows

Creating a New Collection

  1. Read collections.md for config structure
  2. Read fields.md to add your data fields
  3. Read access-control.md to set permissions
  4. Optionally read hooks.md for lifecycle logic

Building a Custom API Endpoint

  1. Read local-api.md for query syntax
  2. Read authentication.md if auth context needed
  3. Read access-control.md to understand permissions

Enabling File Uploads

  1. Read uploads.md for upload config
  2. Read fields.md for upload/​relationship field linking
  3. Read plugins.md if using cloud storage (S3, etc.)

Theming the Admin Panel

  1. Read admin-styling.md for CSS variables and classes
  2. Focus on elevation variables for dark/​light mode
  3. Use @layer payload for overrides

Quick Lookup Patterns

# Find hook types
grep -n "beforeChange\|afterChange" references/​hooks.md

# Find field types
grep -n "type:" references/​fields.md

# Find access control patterns
grep -n "role\|RBAC" references/​access-control.md

# Find query operators
grep -n "equals\|contains\|greater" references/​local-api.md

# Find CSS variables
grep -n "elevation\|gutter" references/​admin-styling.md

Key Patterns

Getting Payload Instance (Server-Side)

import { getPayload } from 'payload'
import config from '@payload-config'

const payload = await getPayload({ config })

Basic Query

const posts = await payload.find({
  collection: 'posts',
  where: { status: { equals: 'published' } },
  limit: 10,
})

Access Control Function

access: {
  read: () => true, // Public
  create: ({ req }) => !!req.user, // Authenticated
  update: ({ req, id }) => req.user?.id === id, // Owner only
}

Official Documentation