wp-interactivity-api
Skill19 starsChanged 20 days agoMITView on GitHub
Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration, wp_interactivity_*()) including performance, hydration, and directive behavior.
4 other projects use a version of this, 4 of them edited.
Adopted by
Most recently taken up by
- shinobiashi/claude-skillsedited, first seen Oct 8, 2026
- morrealev/wordpress-manageredited, first seen Mar 1, 2026
- eugenepyvovarov/mcpbundler-agent-skills-marketplaceedited, first seen Feb 15, 2026
- WordPress/agent-skillsedited, first seen Dec 23, 2025
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 4
- WordPress/agent-skills★ 2.3k97% same
- eugenepyvovarov/mcpbundler-agent-skills-marketplace★ 1297% same
- morrealev/wordpress-manager★ 894% same
- shinobiashi/claude-skills★ 091% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository120 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- adaptSkill
- animateSkill
- auditSkill
- ckm:banner-designSkill
- bolderSkill
- cinematic-editorial-graphicsSkill
- colorizeSkill
- critiqueSkill
- delightSkill
- ckm:designSkill
- ckm:design-systemSkill
- desktop-app-showcaseSkill
- distillSkill
- extractSkill
- featured-image-creatorSkill
- frontend-designSkill
- hand-drawn-explainersSkill
- hardenSkill
- modern-frontend-designSkill
- monoline-iconsSkill
- normalizeSkill
- onboardSkill
- polishSkill
- quieterSkill
- saas-product-graphicsSkill
- svg-graphicsSkill
- teach-impeccableSkill
- ui-design-brainSkill
- ui-skillsSkill
- ckm:ui-stylingSkill
- ui-ux-pro-maxSkill
- elementor-to-generateblocksSkill
- figma-to-generateblocksSkill
- html-to-generateblocksSkill
- just-htmlSkill
- react-pdfSkill
- ab-test-setupSkill
- ad-creativeSkill
- ckm:brandSkill
- churn-preventionSkill
- clarifySkill
- cold-emailSkill
- competitor-alternativesSkill
- content-strategySkill
- copy-editingSkill
- copywritingSkill
- email-sequenceSkill
- form-croSkill
- free-tool-strategySkill
- launch-strategySkill
- marketing-ideasSkill
- marketing-psychologySkill
- mkbhd-voiceSkill
- omm-styleSkill
- onboarding-croSkill
- page-croSkill
- paid-adsSkill
- paywall-upgrade-croSkill
- popup-croSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 12 are common, 0 are distinctive, and 3 are very specific to this project.
12
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 14
Use this skill when the user mentions:
- Common: line 43
If you’re creating a new interactive block (not just debugging), prefer the official scaffold template:
- Common: line 57
Pre-render HTML on the server: before outputting to ensure:
- Very specific: line 79
Use wp_interactivity_state() to define initial global state:
- Common: line 101
When derived state affects initial HTML rendering, replicate the logic in PHP:
- Common: line 119
When touching markup directives:
- Common: line 121
keep directive usage minimal and scoped,
- Common: line 122
prefer stable data attributes that map clearly to store state,
- Common: line 123
ensure server-rendered markup + client hydration align.
- Common: line 135
Verify the repo supports the required module build path:
- Very specific: line 137
if it uses @wordpress/scripts, prefer its conventions.
- Common: line 138
if it uses custom bundling, confirm module output is supported.
- Common: line 142
If “nothing happens” on interaction:
- Common: line 155
If tests exist: add/extend Playwright E2E around the interaction path.
- Very specific: line 178
If repo build constraints are unclear, ask: "Is this using @wordpress/scripts or a custom bundler (webpack/vite)?"
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
From Agent Skills for WordPress. Copyright (C) 2026 WordPress Contributors, licensed under GPL-2.0-or-later. Changed from upstream: the
compatibility:frontmatter line was dropped when this copy was made in March 2026, and license frontmatter plus this notice were added on 2026-10-24. See NOTICE.md.
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) Server-side rendering (best practice)
Pre-render HTML on the server before outputting to ensure:
- Correct initial state in the HTML before JavaScript loads (no layout shift).
- SEO benefits and faster perceived load time.
- Seamless hydration when the client-side JavaScript takes over.
Enable server directive processing
For components using block.json, add supports.interactivity:
{
"supports": {
"interactivity": true
}
}For themes/plugins without block.json, use wp_interactivity_process_directives() to process directives.
Initialize state/context in PHP
Use wp_interactivity_state() to define initial global state:
wp_interactivity_state( 'myPlugin', array(
'items' => array( 'Apple', 'Banana', 'Cherry' ),
'hasItems' => true,
));For local context, use wp_interactivity_data_wp_context():
<?php
$context = array( 'isOpen' => false );
?>
<div <?php echo wp_interactivity_data_wp_context( $context ); ?>>
...
</div>Define derived state in PHP
When derived state affects initial HTML rendering, replicate the logic in PHP:
wp_interactivity_state( 'myPlugin', array(
'items' => array( 'Apple', 'Banana' ),
'hasItems' => function() {
$state = wp_interactivity_state();
return count( $state['items'] ) > 0;
}
));This ensures directives like data-wp-bind--hidden="!state.hasItems" render correctly on first load.
For detailed examples and patterns, see references/server-side-rendering.md.
4) 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.
5) 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.
6) 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.
- derived state not defined in PHP: use
wp_interactivity_state()with closures.
- Initial content missing or wrong:
supports.interactivitynot set inblock.json(for blocks).wp_interactivity_process_directives()not called (for themes/plugins).- state/context not initialized in PHP before render.
- Layout shift on load:
- derived state like
state.hasItemsmissing on server, causinghiddenattribute to be absent.
- derived state like
- 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/server-side-rendering.mdreferences/directives-quickref.mdreferences/debugging.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

