collection
Generate a new Momentum CMS collection with fields, access control, and hooks
Best use case
collection is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generate a new Momentum CMS collection with fields, access control, and hooks
Teams using collection should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/collection/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How collection Compares
| Feature / Agent | collection | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generate a new Momentum CMS collection with fields, access control, and hooks
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Generate Momentum CMS Collection
Create a new collection file following project conventions.
## Arguments
- `$ARGUMENTS` - Collection name (e.g., "posts", "products", "users")
## Important: Collection Location
All collections are defined in `libs/example-config/src/collections/`. Both example apps (`example-angular`, `example-analog`) import from `@momentumcms/example-config/collections`. **Never define collections in individual apps.**
## Steps
1. Create the collection file at `libs/example-config/src/collections/<name>.collection.ts`
2. Use this template:
```typescript
import {
defineCollection,
text,
richText,
number,
date,
checkbox,
select,
relationship,
} from '@momentumcms/core';
export const <PascalName> = defineCollection({
slug: '<kebab-name>',
admin: {
useAsTitle: 'title', // or 'name' - the field to display as title
defaultColumns: ['title', 'createdAt'],
group: 'Content', // Admin sidebar group
icon: 'heroNewspaper', // Sidebar icon (must be registered — see below)
},
access: {
read: () => true,
create: ({ req }) => !!req.user,
update: ({ req }) => req.user?.role === 'admin',
delete: ({ req }) => req.user?.role === 'admin',
},
hooks: {
beforeChange: [],
afterChange: [],
},
fields: [
text('title', { required: true }),
// Add more fields as needed
],
});
```
3. Export from `libs/example-config/src/collections/index.ts`:
```typescript
// Add import at top
import { <PascalName> } from './<name>.collection';
// Add to the collections array
export const collections: CollectionConfig[] = [
// ... existing collections,
<PascalName>,
];
// Add to named exports
export {
// ... existing exports,
<PascalName>,
};
```
Both example apps automatically pick up changes since they import from `@momentumcms/example-config/collections`.
4. Remind user: if migration mode is enabled, run `nx run <app>:migrate:generate` after collection changes to create a migration file.
## Field Types Available
### Text Input Fields
- `text(name, options)` - Short text with optional min/max length
- `textarea(name, options)` - Multi-line text with optional rows
- `richText(name, options)` - Rich text editor
- `email(name, options)` - Email input
- `password(name, options)` - Password input with optional min length
### Numeric & Date Fields
- `number(name, options)` - Numeric value with optional min/max/step
- `date(name, options)` - Date/datetime picker
### Boolean & Selection Fields
- `checkbox(name, options)` - Boolean checkbox
- `select(name, { options: [...] })` - Dropdown select (supports `hasMany`)
- `radio(name, { options: [...] })` - Radio button group
### Media & Files
- `upload(name, options)` - File upload with MIME type filtering
### Relationship & Data Fields
- `relationship(name, { collection: () => Ref })` - Reference to another collection (supports `hasMany`, polymorphic)
- `array(name, { fields: [...] })` - Array of nested fields
- `group(name, { fields: [...] })` - Nested object grouping
- `blocks(name, { blocks: [...] })` - Block-based content
- `json(name, options)` - Raw JSON field
- `point(name, options)` - Geolocation point
- `slug(name, { from: 'fieldName' })` - Auto-generated slug from another field
### Layout Fields (non-data storing)
- `tabs(tabs: [...])` - Tabbed sections for organization
- `collapsible(label, { fields: [...] })` - Collapsible section
- `row(fields: [...])` - Horizontal row layout
## Sidebar Icons
All heroicons/outline (324 icons) are provided globally at the admin route level. Just set `admin.icon` to any `hero*` name — no manual registration needed.
The sidebar resolves icons via: `collection.admin.icon` → `collectionIcons[slug]` fallback map → `'heroFolder'` default. To add a slug-based fallback, update `collectionIcons` in `libs/admin/src/lib/widgets/admin-sidebar/admin-sidebar.component.ts`.
Browse available icons at Heroicons. Naming: `hero` + PascalCase (e.g., `heroEnvelopeOpen` for `envelope-open`).Related Skills
headless-ui
Use @momentumcms/headless inside generated Momentum apps. Use when building custom public UI, composing accessible primitives, configuring global styles for hdl-* elements, or adding app-level tests around headless interactions.
ui-audit
Comprehensive UI component audit for Momentum CMS. Use when asked to audit, review, check, or validate a UI component. Checks Storybook stories, interaction tests, variants, kitchen sink integration, admin dashboard usage, accessibility, and responsive design (mobile-first). AUTOMATICALLY FIXES issues found and verifies with visual inspection. Triggers include "audit button", "review the card component", "check accessibility of tabs", or "/ui-audit <component-name>".
test-all
Run the FULL Momentum CMS test suite — every single suite, no skips. Triggers on "test all", "test everything", "run all tests", "run the test all script", "test-all script", "run the full suite", "run every test", "test the whole thing", "make sure everything passes", "run test:all", or ANY variation asking to run all/every/full tests. Also triggers on typos like "test al", "tets all", "tes all". NEVER skip suites unless the user EXPLICITLY names suites to skip.
stroll-test
End-to-end CLI stroll test of npm-published Momentum CMS packages. Scaffolds a fresh project with create-momentum-app, adds all plugins, runs migrations, starts server, and verifies everything works. Triggers include "stroll test", "cli stroll", "test published packages", or "/stroll-test".
skill-improve
Self-improving skill loop. Analyzes eval failures, rewrites the skill, re-evaluates, and repeats until convergence. Run after /skill-eval produces baseline results.
skill-eval
Run structured evaluations comparing skill vs no-skill performance. Measures assertion pass rates, timing, and output quality to systematically improve skills.
prepare-release
Prepare a patch/minor/major version release for all Momentum CMS packages. Bumps versions, generates changelogs, verifies builds/tests, adds new packages to Nx release config, and commits. Triggers include "prepare release", "bump version", "release patch", or "/prepare-release".
momentum-api
Work with Momentum API for data operations in Angular components
migrations
Run migrations, generate schemas, and manage code generation for Momentum CMS. Use when working with database migrations, Drizzle schema generation, type generation, or Angular schematics.
mcp-setup
Set up the Momentum CMS MCP server plugin and generate Claude Code MCP config for AI tool integration. Use when connecting Claude Code (or any MCP client) to a Momentum CMS instance.
SYSTEM ROLE & BEHAVIORAL PROTOCOLS
**ROLE:** Senior Frontend Architect & Avant-Garde UI Designer.
headless-primitive
Author, extend, or repair primitives in libs/headless. Use when adding a new headless primitive, changing its accessibility contract, updating slots/state attrs, wiring overlay behavior, or expanding the example styling lab and tests.