WordPress 区块主题开发
wp-block-themes
开发 WordPress 区块主题时使用:theme.json(全局设置/样式)、模板与模板部件、图案(patterns)、样式变体,以及站点编辑器(Site Editor)故障排查(样式层级、覆盖、缓存)。
- License 许可
- GPL-2.0
- 所属仓库
- gambitph/Cimo
- 最近更新
- 2026-10-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- wp-block-themes
- description
- Use when developing WordPress block themes: theme.json (global settings/styles), templates and template parts, patterns, style variations, and Site Editor troubleshooting (style hierarchy, overrides, caching).
- compatibility
- Targets WordPress 7.0+ (PHP 7.4.0+). Filesystem-based agent with bash + node. Some workflows require WP-CLI.
02 资源文件 11
- 参考文档.claude-plugin/plugin.json694 B
- 参考文档references/alerts.md6.7 KB
- 参考文档references/creating-new-block-theme.md1.3 KB
- 参考文档references/debugging.md1008 B
- 参考文档references/logging_metrics.md5.3 KB
- 参考文档references/patterns.md592 B
- 参考文档references/retrieving_metrics.md9.0 KB
- 参考文档references/style-variations.md439 B
- 参考文档references/templates-and-parts.md442 B
- 参考文档references/theme-json.md3.2 KB
- 脚本scripts/detect_block_themes.mjs2.7 KB
03 SKILL.md 正文
WP Block Themes
When to use
Use this skill for block theme work such as:
- editing
theme.json(presets, settings, styles, per-block styles) - adding or changing templates (
templates/*.html) and template parts (parts/*.html) - adding patterns (
patterns/*.php) and controlling what appears in the inserter - adding style variations (
styles/*.json) - debugging “styles not applying” / “editor doesn’t reflect theme.json”
Inputs required
- Repo root and which theme is targeted (theme directory if multiple exist).
- Target WordPress version range (theme.json version and features vary by core version).
- Where the issue manifests: Site Editor, post editor, frontend, or all.
Procedure
0) Triage and locate block theme roots
- Run triage:
node skills/wp-project-triage/scripts/detect_wp_project.mjs
- Detect theme roots + key folders:
node skills/wp-block-themes/scripts/detect_block_themes.mjs
If multiple themes exist, pick one and scope all changes to that theme root.
1) Create a new block theme (if needed)
If you are creating a new block theme from scratch (or converting a classic theme):
- Prefer starting from a known-good scaffold (or exporting from a WP environment) rather than guessing file layout.
- Be explicit about the minimum supported WordPress version because
theme.jsonschema versions differ.
Read:
references/creating-new-block-theme.md
After creating the theme root, re-run detect_block_themes and continue below.
2) Confirm theme type and override expectations
- Block theme indicators:
theme.jsonpresenttemplates/and/orparts/present
- Remember the style hierarchy:
- core defaults → theme.json → child theme → user customizations
- user customizations can make theme.json edits appear “ignored”
Read:
references/debugging.md(style hierarchy + fastest checks)
3) Make theme.json changes safely
Decide whether you are changing:
- settings (what the UI allows): presets, typography scale, colors, layout, spacing
- styles (how it looks by default): CSS-like rules for elements/blocks
Read:
references/theme-json.md
4) Templates and template parts
- Templates live under
templates/and are HTML. - Template parts live under
parts/and must not be nested in subdirectories.
Read:
references/templates-and-parts.md
5) Patterns
Prefer filesystem patterns under patterns/ when you want theme-owned patterns.
Read:
references/patterns.md
6) Style variations
Style variations are JSON files under styles/. Note: once a user picks a style variation, that selection is stored in the DB, so changing the file may not “update what the user sees” automatically.
Read:
references/style-variations.md
Verification
- Site Editor reflects changes where expected (Styles UI, templates, patterns).
- Frontend renders with expected styles.
- If styles aren’t changing, confirm whether user customizations override theme defaults.
- Run the repo’s build/lint scripts if assets are involved (fonts, custom JS/CSS build).
Failure modes / debugging
Start with:
references/debugging.md
Common issues:
- wrong theme root (editing an inactive theme)
- user customizations override your defaults
- invalid
theme.jsonshape/typos prevent application - templates/parts in wrong folders (or nested parts)
Escalation
If upstream behavior is unclear, consult canonical docs:
- Theme Handbook and Block Editor Handbook for
theme.json, templates, patterns, and style variations.
04 同仓库更多 Skills
智能体技能文档编写
writing-for-agents
为智能体编写文档。在创建或编辑技能(skills),或修改 AGENTS.md 或 CLAUDE.md 时使用。
WordPress REST API 开发
wp-rest-api
用于构建、扩展或调试 WordPress REST API 端点/路由:register_rest_route、WP_REST_Controller/控制器类、schema/参数校验、permission_callback/身份验证、响应构造、register_rest_field/register_meta,或通过 show_in_rest 暴露 CPT/分类法。
WordPress 项目诊断
wp-project-triage
当你需要对 WordPress 仓库(插件/主题/区块主题/WP 核心/Gutenberg/完整站点)进行确定性检查,包括工具链/测试/版本提示,并生成结构化 JSON 报告以指导工作流和防护栏时使用。
WordPress插件目录合规审查
wp-plugin-directory-guidelines
审查 WordPress 插件的 GPL 合规性、检查许可证头或兼容性、评估追加销售/免费增值/试用版(upsell/freemium/trialware)模式、验证插件命名或商标规则、检查插件 slug、理解某个插件为何被 WordPress.org 拒绝,或回答有关 18 条 WordPress.org 插件目录指南的任何问题——即使用户没有明确提到『指南』。
WordPress插件开发
wp-plugin-development
开发 WordPress 插件时使用:架构与钩子、激活/停用/卸载、管理界面与 Settings API、数据存储、定时任务、安全(nonce/权限/清理/转义)以及发布打包。
WordPress 性能剖析与优化
wp-performance
在排查或改进 WordPress 性能时使用(仅限后端代理):性能剖析与测量(WP-CLI profile/doctor、Server-Timing、通过 REST 请求头使用 Query Monitor)、数据库/查询优化、自动加载选项(autoloaded options)、对象缓存、定时任务(cron)、HTTP API 调用,以及安全验证。