Skip to content

AI agent: Add modification workflow, quality verification, and git safety#2820

Draft
lezama wants to merge 2 commits intoAutomattic:trunkfrom
lezama:add-modification-workflow-and-quality-checks
Draft

AI agent: Add modification workflow, quality verification, and git safety#2820
lezama wants to merge 2 commits intoAutomattic:trunkfrom
lezama:add-modification-workflow-and-quality-checks

Conversation

@lezama
Copy link

@lezama lezama commented Mar 16, 2026

Summary

The AI agent's system prompt currently only covers building sites from scratch. When users ask to modify an existing site ("change the colors", "add a blog section", "install WooCommerce"), the agent has no methodology for understanding what's already there, making safe changes, or verifying it didn't break anything.

This PR adds three capabilities through prompt instructions alone — no new tools or dependencies:

  • Modification workflow: Before changing an existing site, the agent now analyzes the active theme's theme.json, installed plugins, existing content structure, and style.css patterns. It respects the existing design system rather than overriding it.
  • Git safety: The agent initializes git in site directories and creates commits as checkpoints before and after changes. If something breaks, it can revert. The AGENTS.md template also includes a recommended .gitignore for Studio sites.
  • Quality verification: After making changes, the agent checks debug.log for PHP errors, verifies the site is responding, and validates block content — before taking final screenshots.

Both the built-in studio ai agent (via system-prompt.ts) and external agents like Claude Code or Cursor (via the AGENTS.md template) benefit from these changes.

Changes

  • apps/cli/ai/system-prompt.ts — Split the single workflow into Creation and Modification workflows. Added Quality Verification section.
  • tools/common/lib/agents-md.ts — Added Version Control and Quality Checks sections to the AGENTS.md template.

How to test

  1. Build the CLI: npm install && npm run cli:build
  2. Start studio ai and create a site: "Create a site called test-cafe"
  3. After the site is built, ask for a modification: "Change the color scheme to dark mode"
  4. Observe that the agent now:
    • Reads theme.json and existing styles before making changes
    • Creates a git commit checkpoint
    • Takes "before" screenshots
    • Makes targeted changes
    • Checks debug.log for errors
    • Takes "after" screenshots and compares
    • Commits the result

Pre-merge Checklist

  • Linting passes (npx eslint --fix on changed files)
  • Type checking passes (npm run typecheck)
  • Tests pass (npm test -- apps/cli/ai/tests/)
  • Tested manually with studio ai

… agent

The AI agent currently only has a creation workflow — it builds sites from
scratch but has no methodology for modifying existing sites. This adds:

- A dedicated modification workflow that analyzes the existing site (theme.json,
  active plugins, content structure) before making changes
- Git version control as safety checkpoints, enabling undo/revert
- Quality verification steps (PHP error checking, site health, block validation)
- Before/after screenshot comparison for visual regression detection
- Corresponding guidance in the AGENTS.md template for external agents
Verify the new modification workflow, quality verification, git safety
instructions, and that existing sections are preserved in both the
system prompt and AGENTS.md template.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant