| name | project-payload-collection |
| description | Use when creating or modifying Payload CMS collections, fields, access control, admin config, hooks, or generated Payload types. |
Payload Collection Workflow
Use existing collection patterns in src/payload/collections/ before adding new
schema shape.
Steps
- Read related collections and the collection index before editing.
- Choose the minimal field set needed for the request.
- Define access control deliberately. Do not make write access public.
- Add admin columns and
useAsTitle where useful for operators.
- Keep hooks small and deterministic. Avoid hidden side effects.
- Register new collections in the existing collection export path.
- Run
pnpm payload generate after schema changes.
Template
import type { CollectionConfig } from 'payload'
export const CollectionName: CollectionConfig = {
slug: 'collection-name',
admin: {
useAsTitle: 'name',
defaultColumns: ['name', 'createdAt'],
},
access: {
read: () => true,
create: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => Boolean(user),
delete: ({ req: { user } }) => Boolean(user),
},
fields: [
{
name: 'name',
type: 'text',
required: true,
},
],
}
Verification
- Run
pnpm payload generate.
- Run
pnpm validate.
- Add tests or seed updates when the collection participates in a user flow.