Files
agentic-dev/packages/cms-core/AGENTS.md

41 lines
1.3 KiB
Markdown

# @repo/cms-core — Payload CMS Definition
All Payload configuration lives here: payload.config.ts, collections, globals, hooks, access control. The `apps/cms` app is a thin shell that imports this config.
## Hook Rules
| Category | Location | Examples |
|---|---|---|
| CMS-operational | Stay in hook | Slugify, image resize, default values |
| Business logic | Delegate to use case | Notifications, validation, cross-domain updates |
### DO
- Keep hooks thin (max 5-10 lines)
- Import use cases from `@repo/core/application`
- Map Payload hook args to use case input types
### DON'T
- Import from `@repo/core/infrastructure`
- Put business validation in hooks
- Call external services directly from hooks
- Duplicate logic that exists in a use case
## Adding a New Collection
1. Create folder: `src/collections/{name}/`
2. Create: `index.ts` (CollectionConfig), `fields.ts`
3. Optionally: `hooks/`, `access/`
4. Import in `src/payload.config.ts` collections array
5. Export from `src/index.ts`
## Adding a Hook That Calls a Use Case
1. Create `src/collections/{name}/hooks/{hook-name}.ts`
2. Import use case from `@repo/core` (application layer only)
3. Map Payload's hook args to use case input
4. Call use case, return data
**Rule of thumb:** If deleting the hook would break a business requirement, the logic must be in a use case.