wp-interactivity-api
Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration) including performance, hydration, and directive behavior.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o wp-interactivity-api.zip https://jpskill.com/download/17347.zip && unzip -o wp-interactivity-api.zip && rm wp-interactivity-api.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17347.zip -OutFile "$d\wp-interactivity-api.zip"; Expand-Archive "$d\wp-interactivity-api.zip" -DestinationPath $d -Force; ri "$d\wp-interactivity-api.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
wp-interactivity-api.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
wp-interactivity-apiフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 3
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
WP Interactivity API
どのような時に使うか
ユーザーが以下について言及した場合に、このスキルを使用してください。
- Interactivity API,
@wordpress/interactivity data-wp-interactive,data-wp-on--*,data-wp-bind--*,data-wp-context- ブロック
viewScriptModule/ モジュールベースのビュースクリプト - ハイドレーションの問題、または「ディレクティブが発火しない」
必要な入力
- リポジトリのルート + トリアージの出力 (
wp-project-triage) - 影響を受けるブロック/テーマ/プラグインのサーフェス(フロントエンド、エディター、両方)
- 制約事項: WP のバージョン、ビルドでモジュールがサポートされているかどうか
手順
1) 既存の使用状況 + 統合スタイルの検出
以下を検索します。
data-wp-interactive@wordpress/interactivityviewScriptModule
以下を判断します。
- これは
block.jsonのビュースクリプトモジュールを介してインタラクティビティを提供するブロックですか? - これはテーマレベルのインタラクティビティですか?
- これはプラグイン側の「既存のマークアップの拡張」の使用法ですか?
新しいインタラクティブブロックを作成する場合(単なるデバッグではない)、公式の scaffold テンプレートを優先してください。
@wordpress/create-block-interactive-template(via@wordpress/create-block)
2) ストアの特定
ストアの定義を見つけて、以下を確認します。
- state の形状
- actions (ミューテーション)
data-wp-on--*で使用される callbacks/event handlers
3) ディレクティブの安全な実装または変更
マークアップディレクティブを操作する場合:
- ディレクティブの使用を最小限に抑え、スコープを絞る
- ストアの状態に明確にマッピングされる、安定したデータ属性を優先する
- サーバーでレンダリングされたマークアップとクライアントのハイドレーションが一致することを確認する
WordPress 6.9 の変更点:
data-wp-ignoreは非推奨 であり、将来のバージョンで削除されます。コンテキストの継承を壊し、クライアント側のナビゲーションで問題を引き起こしました。使用を避けてください。- 一意のディレクティブ ID: 同じタイプの複数のディレクティブが、
---セパレーターを使用して 1 つの要素に存在できるようになりました(例:data-wp-on--click---plugin-a="..."およびdata-wp-on--click---plugin-b="...")。 - 新しい TypeScript 型:
AsyncAction<ReturnType>およびTypeYield<T>は、非同期アクションの型付けに役立ちます。
ディレクティブの簡単なリマインダーについては、references/directives-quickref.md を参照してください。
4) ビルド/ツールのアラインメント
リポジトリが必要なモジュールビルドパスをサポートしていることを確認します。
@wordpress/scriptsを使用している場合は、その規約を優先します。- カスタムバンドルを使用している場合は、モジュールの出力がサポートされていることを確認します。
5) 一般的な失敗モードのデバッグ
インタラクションで「何も起こらない」場合:
viewScriptModuleがエンキュー/ロードされていることを確認します。- DOM 要素に
data-wp-interactiveがあることを確認します。 - ストアの名前空間がディレクティブの値と一致することを確認します。
- ハイドレーションの前に JS エラーがないことを確認します。
references/debugging.md を参照してください。
検証
wp-project-triageは、変更後、signals.usesInteractivityApi: trueを示します(該当する場合)。- 手動スモークテスト:ディレクティブがトリガーされ、状態が期待どおりに更新されます。
- テストが存在する場合:インタラクションパスの周りに Playwright E2E を追加/拡張します。
失敗モード / デバッグ
- ディレクティブが存在するが、機能しない:
- ビュースクリプトがロードされていない、モジュールのエントリポイントが間違っている、または
data-wp-interactiveが欠落している。
- ビュースクリプトがロードされていない、モジュールのエントリポイントが間違っている、または
- ハイドレーションの不一致/ちらつき:
- サーバーのマークアップがクライアントの期待と異なる。初期状態を簡素化または調整します。
- パフォーマンスの低下:
- インタラクティブなルートが広すぎる。インタラクティビティをより小さなサブツリーにスコープします。
- クライアント側のナビゲーションの問題 (WordPress 6.9):
getServerState()およびgetServerContext()は、ページ遷移間でリセットされるようになりました。コードが古い値が永続することを前提としていないことを確認してください。- ルーターリージョンは、オーバーレイ(モーダル、ポップアップ)を動的にレンダリングするための
attachToをサポートするようになりました。
エスカレーション
- リポジトリのビルド制約が不明確な場合は、「これは
@wordpress/scriptsまたはカスタムバンドラー(webpack/vite)を使用していますか?」と質問してください。 - 以下を参照してください。
references/directives-quickref.mdreferences/debugging.md
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
WP Interactivity API
When to use
Use this skill when the user mentions:
- Interactivity API,
@wordpress/interactivity, data-wp-interactive,data-wp-on--*,data-wp-bind--*,data-wp-context,- block
viewScriptModule/ module-based view scripts, - hydration issues or “directives don’t fire”.
Inputs required
- Repo root + triage output (
wp-project-triage). - Which block/theme/plugin surfaces are affected (frontend, editor, both).
- Any constraints: WP version, whether modules are supported in the build.
Procedure
1) Detect existing usage + integration style
Search for:
data-wp-interactive@wordpress/interactivityviewScriptModule
Decide:
- Is this a block providing interactivity via
block.jsonview script module? - Is this theme-level interactivity?
- Is this plugin-side “enhance existing markup” usage?
If you’re creating a new interactive block (not just debugging), prefer the official scaffold template:
@wordpress/create-block-interactive-template(via@wordpress/create-block)
2) Identify the store(s)
Locate store definitions and confirm:
- state shape,
- actions (mutations),
- callbacks/event handlers used by
data-wp-on--*.
3) Implement or change directives safely
When touching markup directives:
- keep directive usage minimal and scoped,
- prefer stable data attributes that map clearly to store state,
- ensure server-rendered markup + client hydration align.
WordPress 6.9 changes:
data-wp-ignoreis deprecated and will be removed in future versions. It broke context inheritance and caused issues with client-side navigation. Avoid using it.- Unique directive IDs: Multiple directives of the same type can now exist on one element using the
---separator (e.g.,data-wp-on--click---plugin-a="..."anddata-wp-on--click---plugin-b="..."). - New TypeScript types:
AsyncAction<ReturnType>andTypeYield<T>help with async action typing.
For quick directive reminders, see references/directives-quickref.md.
4) Build/tooling alignment
Verify the repo supports the required module build path:
- if it uses
@wordpress/scripts, prefer its conventions. - if it uses custom bundling, confirm module output is supported.
5) Debug common failure modes
If “nothing happens” on interaction:
- confirm the
viewScriptModuleis enqueued/loaded, - confirm the DOM element has
data-wp-interactive, - confirm the store namespace matches the directive’s value,
- confirm there are no JS errors before hydration.
See references/debugging.md.
Verification
wp-project-triageindicatessignals.usesInteractivityApi: trueafter your change (if applicable).- Manual smoke test: directive triggers and state updates as expected.
- If tests exist: add/extend Playwright E2E around the interaction path.
Failure modes / debugging
- Directives present but inert:
- view script not loading, wrong module entrypoint, or missing
data-wp-interactive.
- view script not loading, wrong module entrypoint, or missing
- Hydration mismatch / flicker:
- server markup differs from client expectations; simplify or align initial state.
- Performance regressions:
- overly broad interactive roots; scope interactivity to smaller subtrees.
- Client-side navigation issues (WordPress 6.9):
getServerState()andgetServerContext()now reset between page transitions—ensure your code doesn't assume stale values persist.- Router regions now support
attachTofor rendering overlays (modals, pop-ups) dynamically.
Escalation
- If repo build constraints are unclear, ask: “Is this using
@wordpress/scriptsor a custom bundler (webpack/vite)?” - Consult:
references/directives-quickref.mdreferences/debugging.md
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (4,152 bytes)
- 📎 references/debugging.md (1,371 bytes)
- 📎 references/directives-quickref.md (1,083 bytes)