wp-block-development by wordpress/agent-skills
npx skills add https://github.com/wordpress/agent-skills --skill wp-block-development在以下区块相关工作时使用此技能:
block.json(scripts/styles/supports/attributes/render/viewScriptModule)render.php / render_callback)deprecated 版本)@wordpress/scripts、@wordpress/create-block、wp-env)block.json 的路径)。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
viewScriptModule 时)。node skills/wp-project-triage/scripts/detect_wp_project.mjsnode skills/wp-block-development/scripts/list_blocks.mjsblock.json 的目录)。如果此仓库是一个完整站点(存在 wp-content/),请明确指出哪个插件/主题包含该区块。
如果你正在创建一个新区块,优先使用脚手架工具,而不是手动构建结构:
@wordpress/create-block 来搭建一个现代化的区块/插件设置。阅读:
references/creating-new-blocks.md搭建完成后:
WordPress 6.9 在 block.json 模式中强制要求 apiVersion: 3。当 SCRIPT_DEBUG 启用时,apiVersion 为 2 或更低的区块会触发控制台警告。
为何重要:
迁移: 从版本 2 更改为 3 通常只需更新 block.json 中的 apiVersion 字段。但是:
block.json 中(iframe 中缺失的样式将不会应用)。window 的第三方脚本可能存在作用域问题。阅读:
references/block-json.md(apiVersion 和模式详情)save();保持属性序列化稳定。block.json 中使用 render(或在 PHP 中使用 render_callback),并保持 save() 最小化或为 null。viewScriptModule 来处理基于模块的现代视图脚本。data-wp-* 指令或存储,也请使用 wp-interactivity-api。block.json在区块的 block.json 中进行更改,然后确认注册与元数据匹配。
关于逐字段指导,请阅读:
references/block-json.md常见陷阱:
name 会破坏兼容性(将其视为稳定的 API)deprecated 会导致“无效区块”优先使用基于元数据的 PHP 注册,特别是在以下情况:
wp_set_script_translations)阅读并应用:
references/registration.md遵循包装器属性的最佳实践:
useBlockProps()useBlockProps.save()get_block_wrapper_attributes()阅读:
references/supports-and-wrappers.mdreferences/dynamic-rendering.md(如果是动态区块)如果你的区块是一个嵌套其他区块的“容器”,请将内部区块视为一等特性:
useInnerBlocksProps() 将内部区块与包装器属性集成。阅读:
references/inner-blocks.md在更改属性之前:
meta 属性源阅读:
references/attributes-and-serialization.md如果你更改了已保存的标记或属性:
deprecated 条目(从最新到最旧)。save,并可选择提供一个 migrate 来规范化属性。阅读:
references/deprecations.md优先使用仓库已有的工具:
@wordpress/scripts(常见)→ 运行现有的 npm 脚本wp-env(常见)→ 用于本地 WP + E2E 测试阅读:
references/tooling-and-testing.md如果出现问题,从这里开始:
references/debugging.md(常见故障 + 最快检查)references/attributes-and-serialization.md(属性未保存)references/deprecations.md(更改后区块无效)如果你不确定上游行为/版本支持,请首先查阅权威文档:
每周安装次数
572
仓库
GitHub 星标数
985
首次出现
2026年2月1日
安全审计
安装于
codex387
opencode381
gemini-cli373
cursor370
github-copilot368
claude-code364
Use this skill for block work such as:
block.json (scripts/styles/supports/attributes/render/viewScriptModule)render.php / render_callback)deprecated versions)@wordpress/scripts, @wordpress/create-block, wp-env)block.json if known).viewScriptModule).node skills/wp-project-triage/scripts/detect_wp_project.mjsnode skills/wp-block-development/scripts/list_blocks.mjsblock.json) you’re changing.If this repo is a full site (wp-content/ present), be explicit about which plugin/theme contains the block.
If you are creating a new block, prefer scaffolding rather than hand-rolling structure:
@wordpress/create-block to scaffold a modern block/plugin setup.Read:
references/creating-new-blocks.mdAfter scaffolding:
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:
block.json (styles missing from the iframe won't apply).window may have scoping issues.Read:
references/block-json.md (apiVersion and schema details)save(); keep attributes serialization stable.render in block.json (or render_callback in PHP) and keep save() minimal or null.viewScriptModule for modern module-based view scripts where supported.data-wp-* directives or stores, also use wp-interactivity-api.block.json safelyMake changes in the block’s block.json, then confirm registration matches metadata.
For field-by-field guidance, read:
references/block-json.mdCommon pitfalls:
name breaks compatibility (treat it as stable API)deprecated causes “Invalid block”Prefer PHP registration using metadata, especially when:
wp_set_script_translations)Read and apply:
references/registration.mdFollow wrapper attribute best practices:
useBlockProps()useBlockProps.save()get_block_wrapper_attributes()Read:
references/supports-and-wrappers.mdreferences/dynamic-rendering.md (if dynamic)If your block is a “container” that nests other blocks, treat Inner Blocks as a first-class feature:
useInnerBlocksProps() to integrate inner blocks with wrapper props.Read:
references/inner-blocks.mdBefore changing attributes:
meta attribute sourceRead:
references/attributes-and-serialization.mdIf you change saved markup or attributes:
deprecated entry (newest → oldest).save for old versions and an optional migrate to normalize attributes.Read:
references/deprecations.mdPrefer whatever the repo already uses:
@wordpress/scripts (common) → run existing npm scriptswp-env (common) → use for local WP + E2ERead:
references/tooling-and-testing.mdIf something fails, start here:
references/debugging.md (common failures + fastest checks)references/attributes-and-serialization.md (attributes not saving)references/deprecations.md (invalid block after change)If you’re uncertain about upstream behavior/version support, consult canonical docs first:
Weekly Installs
572
Repository
GitHub Stars
985
First Seen
Feb 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex387
opencode381
gemini-cli373
cursor370
github-copilot368
claude-code364
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
103,800 周安装
OpenAPI 转 TypeScript 工具 - 自动生成 API 接口与类型守卫
563 周安装
数据库模式设计器 - 内置最佳实践,自动生成生产级SQL/NoSQL数据库架构
564 周安装
Rust Unsafe代码检查器 - 安全使用Unsafe Rust的完整指南与最佳实践
564 周安装
.NET并发编程模式指南:async/await、Channels、Akka.NET选择决策树
565 周安装
韩语语法检查器 - 基于国立国语院标准的拼写、空格、语法、标点错误检测与纠正
565 周安装
技能安全扫描器 - 检测Claude技能安全漏洞,防范提示注入与恶意代码
565 周安装