home / skills / wesleysmits / agent-skills / wordpress-fse-generator

wordpress-fse-generator skill

/.agent/skills/wordpress-fse-generator

This skill generates WordPress Full Site Editing blocks and theme files, guiding block.json, theme.json, and PHP registrations for seamless FSE development.

npx playbooks add skill wesleysmits/agent-skills --skill wordpress-fse-generator

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
3.8 KB
---
name: generating-wordpress-fse-blocks
description: Generates WordPress Full Site Editing blocks and theme files. Use when the user asks about block.json, Gutenberg blocks, FSE themes, WordPress block development, or theme.json configuration.
---

# WordPress FSE Theme Code Generator

## When to use this skill

- User asks to create a Gutenberg block
- User mentions Full Site Editing or FSE
- User wants to scaffold block.json files
- User asks about WordPress theme.json
- User needs block templates or patterns

## Workflow

- [ ] Identify block or theme requirement
- [ ] Generate block.json with attributes
- [ ] Create edit component (React/JSX)
- [ ] Create save component
- [ ] Add block styles
- [ ] Register in PHP
- [ ] Update theme.json if needed

## Instructions

### Step 1: Identify Block Type

| Block Type   | Use Case                      | Complexity |
| ------------ | ----------------------------- | ---------- |
| Static       | Content display only          | Low        |
| Dynamic      | Server-rendered, PHP callback | Medium     |
| Interactive  | Client-side JS behavior       | High       |
| Inner Blocks | Container with nested blocks  | Medium     |

### Step 2: Create Block Structure

```bash
mkdir -p src/blocks/my-block
touch src/blocks/my-block/{block.json,edit.tsx,save.tsx,index.ts,style.scss,editor.scss}
```

### Step 3: Generate Block Files

See [examples/block-templates.md](examples/block-templates.md) for complete templates:

- block.json with attributes and supports
- Edit component with InspectorControls and MediaUpload
- Save component (static) and render.php (dynamic)
- Block registration (JS and PHP)
- Block styles (frontend and editor)

### Step 4: Configure theme.json

See [examples/theme-json.md](examples/theme-json.md) for:

- Color palette and typography settings
- Spacing scale configuration
- Layout settings (content/wide)
- Custom font registration
- Block-specific styles
- Template parts and custom templates

### Step 5: Setup functions.php

See [examples/functions-php.md](examples/functions-php.md) for:

- Block registration hooks
- Asset enqueueing
- Block category registration
- Block patterns
- Theme support setup

### Quick Reference: block.json Attributes

```json
{
  "attributes": {
    "text": { "type": "string", "default": "" },
    "number": { "type": "number", "default": 0 },
    "boolean": { "type": "boolean", "default": false },
    "array": { "type": "array", "default": [] },
    "object": { "type": "object", "default": {} }
  }
}
```

### Quick Reference: Block Supports

```json
{
  "supports": {
    "html": false,
    "align": ["wide", "full"],
    "color": { "background": true, "text": true },
    "spacing": { "margin": true, "padding": true },
    "typography": { "fontSize": true }
  }
}
```

## Validation

Before completing:

- [ ] block.json schema validates
- [ ] Block appears in inserter
- [ ] Edit component renders in editor
- [ ] Save outputs valid HTML
- [ ] Styles apply correctly
- [ ] PHP render works (if dynamic)

```bash
npm run build
npm run lint:js
npm run lint:css
```

## Error Handling

- **Block not appearing**: Check block.json name matches registration and category exists.
- **Validation error**: Ensure save output matches stored content exactly.
- **Styles not loading**: Verify file paths in block.json are correct.
- **PHP render not working**: Check render.php exists and block.json has `render` key.
- **TypeScript errors**: Install @wordpress/blocks types: `npm i -D @types/wordpress__blocks`.

## Resources

- [Block Editor Handbook](https://developer.wordpress.org/block-editor/)
- [block.json Schema](https://schemas.wp.org/trunk/block.json)
- [theme.json Reference](https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/)
- [@wordpress/scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/)

Overview

This skill generates production-ready WordPress Full Site Editing (FSE) blocks and theme files. It scaffolds block.json, React edit/save components, PHP registration, and theme.json configuration so you can build, test, and ship Gutenberg blocks and FSE themes quickly.

How this skill works

Provide the block or theme requirements and the skill outputs a complete file structure: block.json, edit/save (JSX/TSX), styles, registration code, and optional render.php for dynamic blocks. It also offers theme.json snippets, functions.php hooks, and validation checks to ensure the block appears and builds correctly.

When to use it

  • When a user asks to create or scaffold a Gutenberg block
  • When building or updating a Full Site Editing theme or theme.json
  • When you need block.json attributes, supports, or asset references
  • When implementing dynamic server-rendered blocks with PHP
  • When creating block templates, patterns, or template parts

Best practices

  • Choose block type (static, dynamic, interactive, inner blocks) before scaffolding
  • Define clear attributes and defaults in block.json and match save output to stored content
  • Use InspectorControls in the edit component for editable settings
  • Register and enqueue assets via functions.php and name blocks with a unique namespace
  • Run build and lint scripts (npm run build, lint:js, lint:css) and validate block.json schema

Example use cases

  • Scaffold a simple static text block with attributes and editor styles
  • Create an interactive block with client-side behavior and bundled JS
  • Build a dynamic testimonials block with render.php for server-side content
  • Add a new block category and register multiple blocks in functions.php
  • Generate theme.json entries for palette, typography, spacing, and block styles

FAQ

What block types can this skill generate?

Static, dynamic (server-rendered), interactive (client JS), and inner blocks with nested content.

How do I ensure a block appears in the inserter?

Confirm block.json name matches registration, category exists, and build assets are enqueued.

How do I validate block.json?

Use the official block.json schema and run your build/lint pipelines to catch schema issues.