agentleFS
nuttarujnuttaruj/rolepod-wplab/skills/wp-edit-theme/SKILL.md

wp-edit-theme

Skill1 starsChanged 6 months agoMITView on GitHub

Read or modify theme-level config on a connected target — theme files (functions.php, templates, style.css), theme.json, Site Editor global-styles, child themes, and theme switches. Phase = Build.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 6 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the marker file $GIT_ROOT/.rolepod/parent-active exists, follow the

    line 19
  2. Very specific:

    NEVER edit a parent theme's files directly when the user owns the site — scaffold a child theme first via rolepod_wp_child_theme_create, …

    line 42
  3. Very specific:

    NEVER call wp_cli_run ["theme", "activate", ...] directly — use rolepod_wp_theme_switch_safe which snapshots the current theme + …

    line 43
  4. Very specific:

    ALWAYS rely on the file_write pre-write validators (PHP php -l server-side, JSON.parse client-side) — they cannot be bypassed.

    line 44
  5. Very specific:

    After theme switch, builder layouts tied to old theme may need re-saving → wp-edit-design.

    line 79
  6. Distinctive:

    If editing an installed parent theme (e.g.

    line 118
  7. Distinctive:

    Only edit parent directly if user is the theme AUTHOR (uncommon).

    line 125
  8. Distinctive:

    If validation throws, do NOT retry the same content.

    line 133
  9. Distinctive:

    If parent edit → child-theme-first.

    line 151
  10. Distinctive:

    Write (validators run automatically).

    line 153
  11. Very specific:

    If broken → toggle via wp-changes (or auto-rollback for theme switch).

    line 155
  12. Very specific:

    No durable artifact per call.

    line 159
  13. Distinctive:

    Read EVERY time before first parent-theme edit on a target — the child-theme-first pattern is in here:

    line 163
  14. Very specific:

    After theme.json / global-styles → wp-edit-design to update any builder layouts that depend on the new tokens.

    line 188
  15. Very specific:

    After theme switch → wp-health-check + spot-check 3 user-visible URLs.

    line 189
  16. Very specific:

    If broken → wp-changes to toggle off the recent writes.

    line 190

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mode selection

If the marker file $GIT_ROOT/.rolepod/parent-active exists, follow the with-rolepod mode — return the edit diff only. The parent's implement-plan owns verify + review; do not re-run them here.

Otherwise, follow standalone mode — edit + impact analysis + verification suggestion in one flow.

GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || GIT_ROOT="$PWD"
if [ -f "$GIT_ROOT/.rolepod/parent-active" ]; then
  MODE=with-rolepod
else
  MODE=standalone
fi

WP Edit Theme

Theme-level writes — the highest-risk surface in WordPress (bad PHP in functions.php = White Screen of Death; bad JSON in theme.json = Site Editor white-page in editor). This skill enforces child-theme-first, pre-write validation, snapshot-before-switch, and atomic session grouping so the user can revert any combination.

Iron Rule

<EXTREMELY-IMPORTANT> 1. NEVER edit a parent theme's files directly when the user owns the site — scaffold a child theme first via `rolepod_wp_child_theme_create`, then edit IN the child. Parent edits get overwritten on theme update; child edits survive. 2. NEVER call `wp_cli_run ["theme", "activate", ...]` directly — use `rolepod_wp_theme_switch_safe` which snapshots the current theme + auto-rolls-back if the new theme breaks the frontend. 3. ALWAYS rely on the file_write pre-write validators (PHP `php -l` server-side, JSON.parse client-side) — they cannot be bypassed. If validation throws, the payload IS broken; do not retry with the same content. </EXTREMELY-IMPORTANT>

When to use

  • "Edit functions.php" / "add a callback to the theme"
  • "Change theme.json palette / typography / spacing"
  • "Edit global styles" / "Site Editor preferences"
  • "Make a child theme of Twenty Twenty-Five"
  • "Switch theme from X to Y"
  • "Override a template" (single.php / archive.php / footer.html)

Skip when:

  • Page-builder widget tree (Elementor / Divi / Oxygen / Bricks) → wp-edit-design.
  • New theme from scratch (skeleton bootstrap) → wp-scaffold.
  • Plugin config (Yoast / RankMath / WPML / Woo / ACF / Forms) → wp-edit-plugin.
  • Core REST CRUD (posts, options, users) → wp-content.

Boundary

Owns:

  • rolepod_wp_child_theme_create — scaffold child theme of a parent.
  • rolepod_wp_theme_switch_safe — snapshot + activate + auto-rollback on red.
  • rolepod_wp_theme_snapshot — manual snapshot for risky multi-file edits.
  • rolepod_wp_theme_restore — restore from snapshot.
  • rolepod_wp_file_write against wp-content/themes/<slug>/** — theme files (functions.php, style.css, templates, parts, patterns, theme.json).
  • rolepod_wp_rest_request POST /wp/v2/global-styles/<id> — Site Editor user customizations (auto-ledgered + cache-flushed).

Does not own:

  • Page-builder layouts → wp-edit-design.
  • New theme bootstrap → wp-scaffold.
  • Plugin config → wp-edit-plugin.

Return / hand off:

  • A theme.json change should also trigger a page-builder re-render → after theme.json write, hand to wp-edit-design for any layout-side adjustments.
  • After theme switch, builder layouts tied to old theme may need re-saving → wp-edit-design.
  • Bad PHP rejected by pre-write validator → STOP, surface line+col, ask user.

Inputs to gather

  • target_id (always).
  • For child theme: parent_slug + child_slug + (optional) name.
  • For theme switch: new_stylesheet + (if production) confirm_production=true.
  • For theme file edit: path under wp-content/themes/<slug>/.
  • For global styles: global-styles post id (resolve via /wp/v2/global-styles/themes/<stylesheet>).

Workflow

1. Pick the operation

User intentTool
edit theme filerolepod_wp_file_write
edit theme.jsonrolepod_wp_file_write (path ends theme.json → auto cache flush after)
edit global stylesrolepod_wp_rest_request POST /wp/v2/global-styles/<id> (auto-ledger + cache flush)
create child themerolepod_wp_child_theme_create
snapshot themerolepod_wp_theme_snapshot
restore themerolepod_wp_theme_restore
switch active themerolepod_wp_theme_switch_safe

2. Session-group multi-file edits

For multi-file work (e.g. add a feature that touches functions.php + template + theme.json):

1. rolepod_wp_session_start { label: "add-product-banner" }
   → returns session_id, sets env so all writes auto-group
2. ...file_write calls...
3. If anything goes wrong:
   rolepod_wp_changes_query { source_session: <id> } → see all writes
   rolepod_wp_changes_toggle_bulk { ids: <all>, applied: false } → atomic revert

3. Child-theme-first for parent edits

If editing an installed parent theme (e.g. Twenty Twenty-Five, Astra, Kadence), default to:

1. rolepod_wp_child_theme_create { parent_slug, child_slug: "<parent>-rolepod" }
2. rolepod_wp_theme_switch_safe { new_stylesheet: "<child>" }
3. file_write into the child dir

Only edit parent directly if user is the theme AUTHOR (uncommon).

4. Pre-write validation

Validators run automatically inside file_write:

  • .php files → companion runs php -l server-side. Reject on syntax error with line + message.
  • .json files → MCP runs JSON.parse client-side. Reject on parse error.

If validation throws, do NOT retry the same content. Read the error, fix the payload.

5. Verify after write

  • wp-health-check after every theme file edit.
  • For theme.json: also GET /wp/v2/global-styles/<id> to confirm the new theme.json keys resolve.
  • For theme switch: implicit (auto-rollback runs if frontend GET fails).

If a matching Rolepod agent is available

  • rolepod:rolepod-builder for theme.json palette / typography decisions.
  • rolepod:rolepod-reviewer with lens: ui for accessibility audit.
  • rolepod:rolepod-builder for template + functions.php logic.
  • rolepod:rolepod-builder for complex callbacks in functions.php.

If no matching agent is available

  1. Pick the operation from the table.
  2. If parent edit → child-theme-first.
  3. Session-start for multi-file work.
  4. Write (validators run automatically).
  5. wp-health-check.
  6. If broken → toggle via wp-changes (or auto-rollback for theme switch).

Output

No durable artifact per call. The Change Ledger row IS the rollback artifact. For theme switches, the .tar.gz snapshot at wp-content/uploads/rolepod-wp-theme-snapshots/ is the canonical restore source.

Examples

Read EVERY time before first parent-theme edit on a target — the child-theme-first pattern is in here:

  • examples/theme-examples.md — good vs bad functions.php edit; good vs bad theme switch; good vs bad theme.json palette change.

References

Load when:

  • Working with theme.json schema (palette / typography / spacing / layout / patterns):
    • references/theme-json-schema.md — block-theme config shape, common pitfalls (preset prefix var:preset|color|<slug>, slug vs name collisions, custom property emission).
  • Working with template hierarchy + parts:
    • references/template-hierarchy.md — single vs archive vs front-page, when override fires.

Hard stops

  • PHP pre-write validator returns PHP_SYNTAX_ERROR → STOP, surface line + message; do not retry with same content.
  • JSON pre-write validator throws → STOP, surface line; do not retry with same content.
  • wp_theme_switch_safe returns rolled_back: true → STOP, the new theme broke the frontend; investigate the new theme (or its required plugins) before retrying.
  • wp_child_theme_create returns CHILD_THEME_ALREADY_EXISTS → STOP, ask the user whether to delete the existing child first OR pick a different slug.
  • About to edit parent theme directly (user is NOT the theme author) → STOP, suggest child-theme-first.

Full Rolepod enhancement

Full Rolepod adds a "design system" group: theme.json + global-styles + custom CSS + font registrations all tagged with the same source_session, revertable as one atomic operation. Standalone, the user runs rolepod_wp_session_start manually for the same grouping.

Next phase

  • After theme.json / global-styles → wp-edit-design to update any builder layouts that depend on the new tokens.
  • After theme switch → wp-health-check + spot-check 3 user-visible URLs.
  • If broken → wp-changes to toggle off the recent writes; restored snapshot is in wp-content/uploads/rolepod-wp-theme-snapshots/.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.