arupbiswas09/claude_skills/payload-cms

Claude Code and agent skill by arupbiswas09/claude_skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Payload CMS (v3, Next.js-native) expert guidance — collections, fields, access control, hooks, the Local API, migrations, and admin-panel customization. Use when working in a Payload project: defining or editing collections/globals, writing field configs, access-control functions, collection/field hooks, Local API queries, custom admin views/components, or database migrations. Encodes hard-won project rules: hand-author migrations (never trust `migrate:create`'s destructive diffs from stale sna…

Install

npx vskill@latest install arupbiswas09/claude_skills/payload-cms

SKILL.md

The same SKILL.md was published earlier as arupbiswas09/claude_skills/payload-cms.

Payload CMS

Payload v3 is a Next.js-native headless CMS: it runs inside your App Router app (app/(payload)/), ships a React admin panel, and exposes REST, GraphQL, and a first-class Local API (direct DB access, no HTTP). Config is TypeScript.

Project hard rules (learned the hard way)

  1. Hand-author migrations. Do NOT trust `payload migrate:create`.

It diffs against a snapshot that goes stale, so it emits destructive diffs (drops/re-creates columns, loses data). Instead: write the migration file by hand — up() and down() with explicit, additive SQL/adapter calls. Review every generated diff before committing; if it drops anything you didn't intend, throw it away and write it manually.

  1. Admin views are often SSO/Entra-gated → you can't just open `/admin`.

Verify custom admin components (analytics views, charts) with offline renders (render the component to static HTML/PNG, or headless-Chrome the built output) rather than relying on a live authenticated session.

  1. Keep the admin on-brand: custom chart components use the project palette,

not Payload defaults.

Core concepts

  • Collections = repeatable docs (Users, Posts, Media). Globals = single

docs (site settings, nav). Both live in payload.config.ts under collections / globals and each is a typed config object.

  • Fields are the unit of schema. Common: text, textarea, richText,

number, select, relationship, array, blocks, group, upload, json, date, checkbox. Every field can carry access, hooks, admin, validate, defaultValue, required, unique, index, localized.

  • Auth is a collection flag: { auth: true } on Users turns on login,

JWT/cookies, me, refresh, reset-password, etc.

Access control (the security surface)

Access functions run on every request and return boolean or a query constraint (a Where) that filters what the user can see:

ts
// collections/Posts.ts
export const Posts: CollectionConfig = {
slug: 'posts',
access: {
read: ({ req: { user } }) => {
if (user?.role === 'admin') return true // full access
return { status: { equals: 'published' } } // row-level filter
},
create: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => user?.role === 'admin',
delete: ({ req: { user } }) => user?.role === 'admin',
},
}

Returning a Where (not just true/false) is the idiom for row-level security. Field-level access ({ read, update }) hides/locks individual fields.

Hooks

  • Collection hooks: beforeChange, afterChange, beforeRead, afterRead,

beforeDelete, afterDelete, beforeValidate.

  • Field hooks: beforeChange, afterRead, etc. — scoped to one field.
  • Keep side effects (emails, cache invalidation, external syncs) in

afterChange/afterDelete, not beforeChange. Guard against infinite loops: a hook that calls payload.update on its own collection re-triggers itself — use context flags or req to break the cycle.

ts
hooks: {
afterChange: [async ({ doc, operation, req }) => {
if (operation === 'create') await notify(req.payload, doc)
return doc
}],
}

Local API (prefer it server-side)

Inside Server Components, Route Handlers, hooks, and scripts, use the Local API — it skips HTTP and access control (runs as admin) unless you pass overrideAccess: false + user.

ts
import { getPayload } from 'payload'
import config from '@payload-config'
const payload = await getPayload({ config })
const { docs } = await payload.find({
collection: 'posts',
where: { status: { equals: 'published' } },
depth: 1, // how many relationship levels to populate
limit: 10,
sort: '-createdAt',
})
  • depth controls relationship population — keep it low to avoid over-fetching.
  • select / populate trim the payload; use them on hot paths.
  • To enforce a user's permissions in the Local API, pass { overrideAccess: false, user }.

Admin customization

  • Swap components via admin.components (custom views, fields, Nav,

beforeDashboard, Logo). Custom views are React Server Components by default; mark 'use client' only where you need interactivity (charts).

  • Register a custom view with a path + component; it renders inside the admin

shell (so it inherits auth/nav). For analytics dashboards, fetch via Local API in the server component, pass data to a client chart component.

  • Verify without a live login: render the component in a standalone route or

a test harness and screenshot with headless Chrome — the admin's Entra gate otherwise blocks automated checks.

Migrations workflow

bash
payload migrate:status # what's applied
payload migrate # apply pending
payload migrate:down # roll back the last
  • Author up()/down() by hand (see rule #1). Make up() additive and

reversible; make down() actually undo it.

  • For Postgres, use the adapter's db.execute(sql\...\) for explicit DDL when

the generated diff is wrong.

  • Run migrations in CI/deploy, not implicitly at boot in production.

Common gotchas

  • `depth` runaway: default depth: 2 on nested relationships explodes query

cost. Set it explicitly.

  • Type generation: run payload generate:types after schema changes; import

from payload-types.ts for end-to-end types.

  • Rich text: v3 defaults to Lexical. Store as JSON; render with the provided

serializer, don't hand-parse.

  • Uploads: upload: true collections need a storage adapter (local disk,

S3/Azure Blob) — configure it, don't rely on local disk in serverless/Azure.

  • `req.payload` is available inside hooks — reuse it, don't call getPayload

again per hook.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/arupbiswas09/claude_skills/payload-cms/badge)](https://verified-skill.com/skills/arupbiswas09/claude_skills/payload-cms)

Something wrong with this skill or its page? Tell us.