Agent Skill · WordPress

wp-block-development

Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows.

Provider: WordPress Path in repo: skills/wp-block-development/SKILL.md

Skill body

WP Block Development

When to use

Use this skill for block work such as:

Inputs required

Procedure

0) Triage and locate blocks

  1. Run triage:
    • node skills/wp-project-triage/scripts/detect_wp_project.mjs
  2. List blocks (deterministic scan):
    • node skills/wp-block-development/scripts/list_blocks.mjs
  3. Identify the block root (directory containing block.json) you’re changing.

If this repo is a full site (wp-content/ present), be explicit about which plugin/theme contains the block.

1) Create a new block (if needed)

If you are creating a new block, prefer scaffolding rather than hand-rolling structure:

Read:

After scaffolding:

  1. Re-run the block list script and confirm the new block root.
  2. Continue with the remaining steps (model choice, metadata, registration, serialization).

2) Ensure apiVersion 3 (WordPress 6.9+)

WordPress 6.9 enforces apiVersion: 3 in the block.json schema. Blocks with apiVersion 2 or lower trigger console warnings when SCRIPT_DEBUG is enabled.

Why this matters:

Migration: Changing from version 2 to 3 is usually as simple as updating the apiVersion field in block.json. However:

Read:

3) Pick the right block model

4) Update block.json safely

Make changes in the block’s block.json, then confirm registration matches metadata.

For field-by-field guidance, read:

Common pitfalls:

5) Register the block (server-side preferred)

Prefer PHP registration using metadata, especially when:

Read and apply:

6) Implement edit/save/render patterns

Follow wrapper attribute best practices:

Read:

7) Inner blocks (block composition)

If your block is a “container” that nests other blocks, treat Inner Blocks as a first-class feature:

Read:

8) Attributes and serialization

Before changing attributes:

Read:

9) Migrations and deprecations (avoid “Invalid block”)

If you change saved markup or attributes:

  1. Add a deprecated entry (newest → oldest).
  2. Provide save for old versions and an optional migrate to normalize attributes.

Read:

10) Tooling and verification commands

Prefer whatever the repo already uses:

Read:

Verification

Failure modes / debugging

If something fails, start here:

Escalation

If you’re uncertain about upstream behavior/version support, consult canonical docs first:

Skill frontmatter

compatibility: Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI.