webiny-cms-bulk-actions
できること
このスキルは、多くのエントリーに割引を適用するなど、WebinyのCMSのコンテンツ一覧に一括アクションを追加するとき、AIを導きます。多くのエントリーを一度に変える必要がある開発者向けです。
使う場面
- ✓CMSのエントリーの一覧で、多くのエントリーを一度に変えるボタンがほしいとき。
- ✓一括の変更を、大量のエントリーにわたってバックグラウンドタスクとして実行する必要があるとき。
- ✓一括アクションが、カスタムのフィールドでエントリーを絞り込む必要があるとき。
スキルのリンク
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/cms-bulk-actions/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“製品の一覧に、選択したすべてのエントリーに割引を適用する一括アクションを追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、二つの手順を持つ一括アクションのクラスを説明します。一つは読み込むエントリーを選び、もう一つは各エントリーを変更します。その後、Webinyがバックグラウンドタスクとミューテーションを自動で作成し、管理画面のボタンがそれらを起動します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Custom Headless CMS bulk actions
TL;DR
A bulk action is a class implementing EntriesBulkAction.Interface with two methods —
loadData (which entries) and processData (what to do to each). Register it with
export default EntriesBulkAction.createImplementation({...}) via <Api.Extension src>.
For every registered bulk action, Webiny automatically generates a list background
task, a process background task, and a GraphQL mutation. On the Admin side, add a
ContentEntryListConfig.Browser.BulkAction button that calls BulkActionFeature's
useCase.execute({ model, action, where, data }).
Available from Webiny 6.5.0 (webiny/api/cms/entry).
Backend — the bulk action
// extensions/myBulkAction/api/MyBulkAction.ts
import {
EntriesBulkAction,
ListLatestEntriesUseCase,
UpdateEntryUseCase
} from "webiny/api/cms/entry";
class MyBulkActionImpl implements EntriesBulkAction.Interface {
// PascalCased into the task ids + GraphQL enum value, so "applyDiscount" →
// tasks hcmsBulk(List|Process)ApplyDiscountEntries and frontend action "ApplyDiscount".
readonly name = "applyDiscount";
// Optional: restrict which models get the mutation/button.
readonly modelIds = ["product"];
// Optional: entries processed per batch (defaults to the configured batchSize).
// readonly batchSize = 50;
constructor(
private listEntries: ListLatestEntriesUseCase.Interface,
private updateEntry: UpdateEntryUseCase.Interface
) {}
// Runs in the "list" task, with pagination (params.where/search/after/limit).
async loadData(model, params) {
const result = await this.listEntries.execute(model, params);
return result.value; // { entries, meta }
}
// Runs in the "process" task, once per entry, in batches.
async processData(model, params) {
// params.id is a revision id ("<entryId>#0001"); params.data carries whatever the
// Admin action sent.
// ...update / transform the entry here...
}
}
export default EntriesBulkAction.createImplementation({
implementation: MyBulkActionImpl,
dependencies: [ListLatestEntriesUseCase, UpdateEntryUseCase]
});
loadData/processData are the background-task body. You never write scheduling,
batching, retry, or timeout-resume code — the tasks system provides all of it. Webiny
generates hcmsBulkList<Name>Entries, hcmsBulkProcess<Name>Entries, and the mutation
bulkAction<SingularApiName>(action: <Name>, ...).
Convergence — the #1 gotcha
The engine calls loadData repeatedly until it returns zero entries — after each
processing round it re-lists to check for more work. If loadData keeps returning the
same entries, the task never converges: it re-processes them until it hits maxIterations
and fails. So the filter MUST exclude already-processed entries.
- State-transition actions converge naturally: Publish filters
status_not: "published"andprocessDatapublishes; the next list is smaller. Built-in actions rely on this. - Actions with no natural "done" state need a marker:
- A boolean flag:
loadDataexcludesflag = true;processDatasets it. Simple, but blocks re-running until you reset the flag. - A per-run token (re-runnable): the Admin action generates a fresh
runIdper click and filters "not stamped with this run";processDatastamps the entry withrunId. The run converges once everything is stamped, but the next click uses a new token, so the same entries are eligible again — no manual reset.
- A boolean flag:
Where filters — two layers, two formats
The bulk-action list path talks to storage directly, bypassing the GraphQL where-transform. Mind the difference:
- GraphQL where (what the Admin action sends, typed as
<Model>ListWhereInput): system fields are top-level (id_in,status_not,savedOn_lt, …); custom fields are nested undervalues—where: { values: { onSale_not: true } }. A dotted key like"values.onSale_not"is rejected by the typed input. - Storage where (what
loadDatapasses to the list use case): custom fields are flat dotted —{ "values.onSale_not": true }; system fields stay top-level. A bareonSale_notthrowsThere is no field with the fieldId "onSale".
So if the Admin action sends a custom-field filter, flatten it in loadData:
async loadData(model, params) {
const where = { ...params.where };
if (where.values && typeof where.values === "object") {
よくある質問
必要なWebinyのバージョンは?
スキルは、一括アクションはWebiny 6.5.0から利用できると述べています。
どのエントリーを変えるかは誰が決めますか?
loadDataの手順がエントリーを選び、processDataが各エントリーを変更します。
管理画面のボタンも扱いますか?
はい。スキルは、一括アクションを呼び出す管理画面のボタンを説明しています。
詳細
作者による元の説明
Authoring a custom Headless CMS bulk action (EntriesBulkAction) that Webiny runs as a background task, plus the Admin-side button that triggers it. Use this skill when the developer wants to add a bulk action to the content-entry list (e.g. apply a discount, generate content, bulk-transform entries), understand loadData/processData, make the task converge, filter by custom fields, or trigger the action from the Admin UI. Requires Webiny 6.5.0 or newer.
repo: webiny/webiny-js
人気
- GitHubのスター
- 8.1k
- ランキング
- #12584
- ライセンス
- —
- 更新日
- 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エージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。