wp-block-development: Full-Lifecycle Development Skill for Gutenberg Blocks

Introduction

Modifying block.json, changing saving structures, or adding dynamic rendering can easily lead to “Invalid block” errors in the editor, attributes failing to persist, or styles mismatching in the WordPress 7.0 iframe editor. Block development involves metadata, serialization, asset scopes, and the deprecation chain; if the order of steps is wrong, problems often require going back to untangle them.

Below is an introduction to wp-block-development from the official WordPress Agent Skills: a fixed workflow for creation, registration, rendering, and migration, pointing to reference documents and scripts within the repository.

What is this

wp-block-development is a Skill in the WordPress agent-skills repository, aimed at the complete workflow for Gutenberg blocks from scaffolding to deployment.

The official description covers: block.json metadata, register_block_type / register_block_type_from_metadata, attributes and serialization, supports, dynamic rendering (render.php / render_callback), deprecation migration, viewScript and viewScriptModule, as well as building and testing with @wordpress/scripts and @wordpress/create-block.

Compatibility (SKILL Metadata): Targets WordPress 7.0+ (PHP 7.4.0+); requires bash and node for filesystem-based agents; some workflows depend on WP-CLI.

Core Functions

The capabilities listed in the materials are as follows, all corresponding to the Procedures and references within the SKILL.

Direction Content
Project Identification Works with wp-project-triage’s detect_wp_project.mjs; uses list_blocks.mjs to scan block root directories containing block.json
Creating New Blocks Recommends @wordpress/create-block scaffolding; use the interactive template when the Interactivity API is needed
apiVersion 3 WordPress 6.9+ enforces apiVersion 3 on the schema; prepare styles and script scopes for the iframe editor (WordPress 7.0)
Block Models Static (save() + stable serialization), Dynamic (render / render_callback), Frontend Interactivity (prefer viewScriptModule, use wp-interactivity-api for Interactivity)
Metadata & Safe Modification See references/block-json.md for block.json field descriptions; changing name breaks compatibility; changing saving structure requires deprecated
Server-side Registration PHP metadata registration for translation, conditional loading, and dynamic rendering (references/registration.md)
Edit / Save / Render useBlockProps, useBlockProps.save(), get_block_wrapper_attributes(); use useInnerBlocksProps() for inner blocks
Attributes & Serialization Confirm comment / HTML / context sources; avoid deprecated meta source (references/attributes-and-serialization.md)
Migration deprecated from new to old, save and optional migrate (references/deprecations.md)
Toolchain Follow existing repository tools like @wordpress/scripts, wp-env, etc. (references/tooling-and-testing.md)

Verification Checklist: Inserter can insert; save and reload shows no Invalid block; frontend output matches static or dynamic expectations; editor and frontend assets load correctly; run lint / build / test recommended by triage.

Troubleshooting Entry: references/debugging.md, as well as references related to attributes and deprecation.

Installation and Activation

Install to the local Skills environment using the command published via officialskills.sh:

npx skills add https://github.com/WordPress/agent-skills --skill wp-block-development

Alternatively, provide the Skill directory link to a coding assistant that supports Agent Skills, and have it install according to project conventions:

https://github.com/WordPress/agent-skills/tree/trunk/skills/wp-block-development

After installation, the Agent executes according to the Procedure in SKILL.md; the references/ and scripts/ within the repository are accompanying documentation and scripts, requiring no separate “config file” field (the materials do not provide differences for Cursor / Codex CLI / Claude Code, so this is not expanded upon here).

Typical Usage

Preparation before use: Repository root path, target carrier (Plugin / Theme / Whole Site), block namespace and block.json path, target WordPress version range (especially regarding modules / viewScriptModule). For whole-site repositories, clarify which plugin or theme the block belongs to.

0) Locate Blocks

First perform project triage, then list block directories:

node skills/wp-project-triage/scripts/detect_wp_project.mjs
node skills/wp-block-development/scripts/list_blocks.mjs

Confirm that the directory to be modified is indeed the block root containing block.json.

1) Create New Block (Optional)

Use @wordpress/create-block scaffolding and read references/creating-new-blocks.md. After scaffolding is complete, run list_blocks.mjs again to confirm paths, then proceed with metadata and registration.

2) Upgrade to apiVersion 3

Set apiVersion: 3 in block.json (migration from v2 usually involves changing only this field, but verification in a local environment with the iframe editor enabled is required). Ensure style handles are written in block.json to avoid missing styles in the iframe; pay attention to the scope of third-party scripts on window. See references/block-json.md for details.

3) Modify Metadata and Register

Implement edit / save / render according to the static / dynamic / interactive model, prioritizing register_block_type_from_metadata on the server side. See references/dynamic-rendering.md for dynamic blocks; see references/inner-blocks.md for container blocks.

4) Add Deprecation when Changing Saving Structure

If adjusting markup or attributes in published content:

  1. Declare in deprecated from the new version to the old version in order;
  2. Provide save for the old version, and use migrate to normalize attributes if necessary.

See references/deprecations.md for details to avoid Invalid block errors after saving.

5) Build and Local Verification

Use the project’s existing npm scripts (@wordpress/scripts) or wp-env for local WordPress and E2E testing; see references/tooling-and-testing.md.

Applicable Scenarios and Notes

Suitable for:

  • Creating or maintaining Gutenberg blocks in plugins / themes;
  • Fixing block invalid, not saving, or attribute non-persistence issues;
  • Adding render.php or server-side render_callback to static blocks;
  • Planning apiVersion 2 → 3, adapting to the WordPress 7.0 editor iframe;
  • Container blocks and Inner Blocks wrapper attributes and migration.

Limitations and Notes:

  • The target environment is WordPress 7.0+; behavior for older versions follows official Developer Resources and Gutenberg documentation (Escalation section in the SKILL).
  • Some steps depend on WP-CLI and node scripts; if modifying files manually without running list / triage, the Agent can still follow reference guidelines, but the location cost is higher.
  • name is treated as a stable API; modifying saved HTML without configuring deprecation is explicitly listed as a common pitfall in the materials.

Conclusion

wp-block-development breaks block development into verifiable step-by-step processes: first scanning block.json, selecting the correct static or dynamic model, safely modifying metadata, using deprecation to catch historical content, and aligning registration and serialization with in-repository references. It represents an official path for WordPress regarding the core editing experience within the Agent Skills ecosystem.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye