webiny-api-cms-content-models
What it does
This skill guides your AI when creating or changing CMS content models in a Webiny project through code. It is for developers who want their data structures defined in version-controlled code.
When to use it
- ✓When you want to create a content model such as products or blog posts in code.
- ✓When fields need validation or references to other models.
- ✓When you need to choose the right admin display for a field type.
Skill link
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/content-models/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Create a content model for products in code with name, price and a reference to a category model.”
5 new skills a week. 1 minute to read.
How it works
The skill shows a model class that uses a fluent builder to declare fields, layouts, title fields and API names. The model is registered in the project's configuration file.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Creating Content Models via Code
TL;DR
Content models are created using the ModelFactory pattern. You define a class implementing ModelFactory.Interface, use the fluent ModelFactory.Builder API to declare fields, validators, layout, and API names, then export with ModelFactory.createImplementation(). Register in webiny.config.tsx as <Api.Extension>.
The ModelFactory Pattern
Every code-based content model follows the same structure:
import { ModelFactory } from "webiny/api/cms/model";
class MyModelImpl implements ModelFactory.Interface {
async execute(builder: ModelFactory.Builder) {
return [
builder
.public({ modelId: "myModel", name: "My Model", group: "ungrouped" })
.description("Description of the model")
.fields(fields => ({
// field definitions here
}))
.layout([/* row definitions */])
.titleFieldId("fieldId")
.singularApiName("MyModel")
.pluralApiName("MyModels")
];
}
}
export default ModelFactory.createImplementation({
implementation: MyModelImpl,
dependencies: []
});
Register in webiny.config.tsx:
<Api.Extension src={"/extensions/MyModel.ts"} />
YOU MUST include the full file path with the .ts extension in the src prop. For example, use src={"/extensions/MyModel.ts"}, NOT src={"/extensions/MyModel"}. Omitting the file extension will cause a build failure.
YOU MUST use export default for the createImplementation() call when the file is targeted directly by an Extension src prop. Using a named export (export const MyModel = ...) will cause a build failure. Named exports are only valid inside files registered via createFeature.
Model Configuration Methods
| Method | Purpose |
|---|---|
.public({ modelId, name, group }) |
Creates a public model (accessible via Read API). modelId is the internal DB identifier. group organizes it in the Admin sidebar. |
.description("...") |
Model description shown in Admin UI |
.fields(fields => ({ ... })) |
Define all fields using the fluent field builder |
.layout([["field1", "field2"], ["field3"]]) |
Arrange fields in rows in the Admin editor. Each inner array is one row. |
.titleFieldId("name") |
Which field to use as the entry's display title |
.descriptionFieldId("message") |
Which field to use as the entry's description |
.singularApiName("Product") |
Singular name for GraphQL queries (e.g., getProduct) |
.pluralApiName("Products") |
Plural name for GraphQL queries (e.g., listProducts) |
.singleEntry() |
Makes the model a singleton (only one entry can exist). Automatically adds |
FAQ
How is the model registered?
As an API extension in the webiny configuration file, using the full file path with the .ts extension.
Can fields be nested?
Yes. The skill covers nested layouts inside object and dynamic zone fields.
Does it cover choosing field display types?
Yes. It explains which admin display to use for each field type.
Details
Original description by the author
Creating Headless CMS content models via code using the ModelFactory pattern. Use this skill when the developer wants to create, modify, or understand content model definitions, define fields and validators, set up reference fields between models, configure field layouts (including nested layouts inside object or dynamicZone fields), pick the correct Admin UI renderer for a field type (textInput/textInputs, lexicalEditor/lexicalEditors, file/files, objectAccordionSingle/objectAccordionMultiple, etc.), or work with the ModelFactory builder API. Also covers field types (text, longText, number, b
repo: webiny/webiny-js
Popularity
- GitHub stars
- 8.1k
- Ranking position
- #12598
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
prd-to-plan
8.1kHelps your agent turn a product requirements document into a phased plan of small end-to-end slices, saved as a Markdown file.
webiny-admin-architect
8.1kTeaches your agent how to build admin screens for the Webiny platform, using its business logic layers and presenter pattern.
webiny-admin-permissions
8.1kTeaches your agent to add permission controls to Webiny admin screens, including auto-generated permission forms and hide-or-show checks.
webiny-form-model
8.1kTeaches your agent to build forms in Webiny using a declarative field builder, layouts, validation and conditional rules.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.