wp-block-development by automattic/agent-skills
npx skills add https://github.com/automattic/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(常见)→ 用于本地 WordPress + E2E阅读:
references/tooling-and-testing.md如果出现问题,从这里开始:
references/debugging.md(常见故障 + 最快检查)references/attributes-and-serialization.md(属性未保存)references/deprecations.md(更改后区块无效)如果你不确定上游行为/版本支持,请首先查阅权威文档:
每周安装次数
108
仓库
GitHub 星标数
195
首次出现
2026年1月21日
安全审计
安装于
opencode65
claude-code64
cursor61
codex58
gemini-cli58
github-copilot55
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
108
Repository
GitHub Stars
195
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode65
claude-code64
cursor61
codex58
gemini-cli58
github-copilot55
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
116,600 周安装
ripgrep (rg) 快速文本搜索工具:比 grep 快 100 倍的正则表达式搜索
104 周安装
Python PDF处理指南:合并、拆分、提取文本与表格,创建PDF文件
104 周安装
Shopify Polaris Web Components 使用指南:为 App Home 构建 UI 的完整教程
104 周安装
每日新闻摘要生成器 - AI自动汇总多源新闻,智能生成Markdown报告
104 周安装
Obsidian CLI 官方命令行工具使用指南:文件管理、搜索、属性与任务操作
104 周安装
流程图创建器 - 在线生成交互式HTML流程图、决策树和工作流可视化工具
104 周安装