Skip to main content

Writer Agent

  • File: .github/agents/Writer.agent.md
  • Role: Specialized agent for creating and updating WordPress content via PHP CLI scripts.
  • Capabilities:
    • Create/Update Posts: Generates new blog posts or updates existing ones using proper hierarchies (L0/L1/L2).
    • ACF Management: Handles complex ACF fields (Repeaters, Relationships) using Field Keys.
    • Hierarchy Management: Establishes parent/child relationships between L2 (standard post) and L1/L0 (pix-article custom types).

Working with WordPress Data & Element Styling​

When structuring posts, specifically those involving complex SVGs, Mermaid diagrams, KaTeX formulas, or intricate layout classes, standard WordPress functions like wp_insert_post and default REST/ACF endpoints often heavily sanitize HTML elements.

Handling Post Structure:

  • Mermaid Diagrams & SVGs: When writing SVG tags or Mermaid diagram structure (like :::class), ensure that raw tags and precise classes are used without being stripped by wp_filter_post_kses.
  • KaTeX Formulas: Backslashes (\text) in array submissions are easily stripped. Use direct $wpdb inserts or wp_slash() bypasses inside ad-hoc PHP SSH scripts to ensure equations are stored legitimately in raw JSON formats for ACF.
  • Images and Context: When assembling hierarchies (e.g., L2 posts under an L1 parent), explicitly handle metadata such as _thumbnail_id (featured image) to ensure all stylistic components are mapped.

Automated Validations:

  • After scaffolding new posts or running large data-fixes via PHP, the Writer agent should dispatch the Tester agent or directly execute Playwright scripts (tests/after_post_struct_created.spec.ts) to validate explicit logic (e.g., Mermaid node SVGs appearing for .node.faculty elements, katex-display classes replacing raw text, and visibility of .hero-image elements).