This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Waygate is a standalone WordPress plugin that provides AI-powered pattern page builder capabilities for the Elayne block theme. It integrates with the WordPress Abilities API (WP 7.0+) and WordPress AI Client to generate pages from natural-language descriptions.
- Package:
imagewize/waygateon Packagist - Namespace:
Imagewize\Waygate - Requires: PHP 8.3+, WordPress 7.0+
Install dependencies:
composer installPHP syntax check (matches CI):
find . -name "*.php" -not -path "*/vendor/*" -exec php -l {} \;Run PHP CodeSniffer:
vendor/bin/phpcsRun PHPUnit:
vendor/bin/phpunit --configuration phpunit.xmlAll classes live in includes/ with PSR-4 autoloading (Imagewize\Waygate → includes/). Each class uses a static init() method hooked to plugins_loaded from waygate.php.
Pattern_Lab (includes/class-pattern-lab.php) — The data layer. Queries WordPress's registered block patterns to extract those belonging to the active Elayne theme, returning structured metadata (slug, title, description, categories, keywords). Also handles composing wp:pattern blocks into a page and calling wp_insert_post.
Abilities_API (includes/class-abilities-api.php) — Registers two WordPress Abilities (WP 7.0+ feature):
elayne/list-patterns— lists available patterns, optionally filtered by category; requiresedit_postselayne/create-page— creates a draft page from an ordered pattern slug list; requirespublish_pages
Each ability has a JSON input/output schema for capability validation.
AI_Integration (includes/class-ai-integration.php) — Orchestrates AI page generation. Registers a Mistral provider with the WP AI Client registry, then in generate_page() builds a prompt from all available patterns, sends it to the AI (with fallback chain: Mistral → Claude → OpenAI → Gemini), parses the JSON response, and delegates to Pattern_Lab::create_page(). Enforces layout constraints: 3–7 patterns, hero first, CTA last, no consecutive grid patterns.
Admin (includes/class-admin.php) — WordPress admin UI at Tools → Waygate. Renders status indicators (WP AI Client, Abilities API, Mistral provider, Elayne patterns), the AI generation form, and a searchable pattern catalog. Handles POST form submission with nonce verification and displays success/error notices.
plugins_loaded → Pattern_Lab::init()
→ AI_Integration::init()
→ Abilities_API::init()
→ Admin::init()
Pattern_Lab must init first since the other classes depend on its pattern data.
- WordPress AI Client — configured via Settings → Connectors; required for AI generation
- Mistral provider (
saarnilauri/ai-provider-for-mistral) — setMISTRAL_API_KEYin the site.env - Elayne theme — provides the block patterns that this plugin orchestrates
Use atomic commits: each commit represents one logical change and must build/pass on its own. Group files that belong to the same logical change into one commit; split files that represent different changes into separate commits. Typical split for a patch:
fix: switch autoloader from psr-4 to classmap— the code changedocs: update CHANGELOG for v0.3.0— changelog entrydocs: add CLAUDE.md— documentation
Never bundle unrelated changes into a single commit. Use conventional commit prefixes: feat:, fix:, docs:, refactor:, test:, chore:.
Never mention Claude, Claude Code, or Claude AI in commit messages.
WAYGATE_VERSION— current plugin versionWAYGATE_PLUGIN_DIR— absolute path to plugin directoryWAYGATE_PLUGIN_URL— URL to plugin directory
When releasing a new version, update the version string in three places:
waygate.phpline 8 —* Version:plugin headerwaygate.phpline 19 —define( 'WAYGATE_VERSION', ... )constantCHANGELOG.md— add a new## [x.y.z] - YYYY-MM-DDsection at the top