Skip to main content
Glama

Write a theme file

write_theme_file

Create or overwrite theme files in a WordPress draft theme; PHP is syntax-checked before saving so parse errors are reported instead of breaking the live site.

Instructions

Create or overwrite a theme file, replacing its entire contents. Refuses to write to a live active theme by default — work in a draft (create_draft_theme) so the site stays untouched until you publish. PHP is syntax-checked before it is saved, so a parse error is reported rather than fataling the site.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath relative to the theme root, e.g. "template-parts/hero.php". Parent directories are created as needed.
themeNoTheme stylesheet or draft id. Defaults to the active draft if there is one.
contentYesFull file contents.
site_idNoWhich configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids.
allow_live_themeNoPermit writing directly into the live active theme. Strongly discouraged — use a draft.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.0.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • removedInput schema / additionalProperties
      Removed value: -false
  2. First observedv1.0.0

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds substantial behavioral context beyond the annotations: full-content replacement semantics, the default refusal to touch a live theme, and the PHP syntax-check with graceful parse-error reporting instead of fatally breaking the site. This is exactly the 'what gets destroyed and what protects it' context the rubric rewards. The overwrite semantics sit in mild tension with destructiveHint: false, but the description is honest and the live-theme guardrail makes the non-destructive framing defensible, so no contradiction is flagged.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences with zero waste: behavior, safe workflow, and safety validation each get exactly one sentence, and the core overwrite semantics are front-loaded. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter mutating file writer with no output schema, the description covers the calling decision (what it does), the safety envelope (draft vs. live), and failure behavior (parse errors reported). The only real gap is that it never says what a successful call returns, and idempotency/rollback behavior is unaddressed — minor since the schema and annotations carry the parameter and safety load.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% — path, theme, content, site_id, and allow_live_theme all have meaningful schema descriptions (including defaults, parent-directory creation, and list_sites lookup). The description itself adds no parameter-level detail beyond reinforcing the draft workflow already captured by the theme and allow_live_theme fields, so it earns the baseline 3 rather than more.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource — 'Create or overwrite a theme file, replacing its entire contents' — and the 'entire contents' qualifier sharply distinguishes it from the partial-edit sibling edit_theme_file and from delete_theme_file. An agent can tell exactly what this tool does without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit workflow direction: 'work in a draft (create_draft_theme) so the site stays untouched until you publish,' naming the exact sibling to use first and explaining why. It also defines when the tool refuses to act (against a live active theme). It does not explicitly route partial edits to edit_theme_file or list exclusion conditions, but the draft-first workflow is clear enough to guide correct use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools