๐Ÿ“– Lesson 6 of 13

Setting Up AI Agents for Accelerated Engineering

AI Coding Assistants (such as Cursor, VS Code Copilot, Windsurf, or Claude) can dramatically accelerate your theme development โ€” but only if they have the proper context.

In this lesson, you will learn how to configure local AI coding assistants inside WP Rig and use our pre-packaged `.ai/` system to prevent model hallucinations.


The AI Challenge in WordPress

WordPress theme development historically relies on procedural scripts and global templates. When an AI assistant attempts to write code in a standard theme, it often: * Generates global namespace collisions. * Uses outdated or legacy PHP functions. * Writes custom CSS that overrides theme variables.

WP Rig v3 resolves this by incorporating an **AI-Native Framework**. By combining WP Rig’s strict PHP namespaces, OOP Components, and PSR-4 autoloading, AI agents can trace, read, and write code cleanly with near-zero errors!


Step-by-Step AI Agent Activation

To boot up and configure your local AI agent, run the following setup script inside the theme folder:

npm run ai:setup

This script scans your active project configurations and configures standard environment rules for your workspace (writing configurations for Cursor, Windsurf, Copilot, and Claude).


Navigating the `.ai/` Directory

WP Rig integrates a specialized directory to act as the “long-term memory” and command center for your AI assistant. Look under `./.ai/`:

.ai/
โ”œโ”€โ”€ agent-state.md         # Tracks onboarding status (Pending vs. Completed)
โ”œโ”€โ”€ developer-directions.md # Write your custom coding guidelines here
โ”œโ”€โ”€ PROJECT_RULES.md       # Chronological log of custom architectural learnings
โ””โ”€โ”€ skills/                # Core technical tutorials for AI (CSS, PHP, Blocks)

1. `developer-directions.md`

2. `PROJECT_RULES.md`

3. Contract-First specs


The Quality Check Sweep

After your AI writes PHP, CSS, or JS, have it run:

npm run ai:check

This runs automated lints, PHPStan static checks, and Playwright tests. If any check fails, the AI can read the console logs and debug/heal its own code autonomously!

In our next section, we will see how to leverage WP Rig’s built-in generators to scaffold OOP PHP components and blocks!