webiny-api-cms-content-models
できること
このスキルは、Webinyプロジェクトで、コードを通じてCMSのコンテンツモデルを作成または変更するとき、AIを導きます。データ構造をバージョン管理されたコードで定義したい開発者向けです。
使う場面
- ✓製品やブログ記事などのコンテンツモデルを、コードで作成したいとき。
- ✓フィールドに検証や他のモデルへの参照が必要なとき。
- ✓フィールドの種類に合った管理画面の表示を選ぶ必要があるとき。
スキルのリンク
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/content-models/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“名前、価格、カテゴリーモデルへの参照を持つ、製品のコンテンツモデルをコードで作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、流れるようなビルダーを使ってフィールド、レイアウト、タイトルのフィールド、APIの名前を宣言するモデルのクラスを示します。モデルは、プロジェクトの設定ファイルに登録されます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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 |
よくある質問
モデルはどのように登録されますか?
webiny設定ファイルのAPI拡張として、.tsの拡張子を含む完全なファイルパスを使って登録されます。
フィールドは入れ子にできますか?
はい。スキルは、objectとdynamic zoneのフィールドの中の、入れ子のレイアウトを扱います。
フィールドの表示の種類の選択も扱いますか?
はい。フィールドの種類ごとに、どの管理画面の表示を使うかを説明します。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 8.1k
- ランキング
- #12598
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
prd-to-plan
8.1k製品要件書を、それぞれ端から端まで成立する小さなスライスの段階的な計画に変え、Markdownファイルとして保存するよう、エージェントを支援します。
webiny-admin-architect
8.1kビジネスロジックの層とプレゼンターのパターンを使い、Webinyプラットフォームの管理画面を作る方法をエージェントに教えます。
webiny-admin-permissions
8.1k自動生成される権限フォームや、表示・非表示のチェックを含め、Webinyの管理画面に権限の制御を追加するよう、エージェントに教えます。
webiny-form-model
8.1kビルダーで宣言的にフィールドを定義し、レイアウト、検証、条件付きのルールを使って、Webinyのフォームを作るよう、エージェントに教えます。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。