This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Deploy Forge - A WordPress plugin by Jordan Burch that automates theme deployment from GitHub repositories. When a developer commits to GitHub, the plugin triggers GitHub Actions to build the theme and automatically deploys compiled files to the WordPress theme directory.
- Developer commits to GitHub → GitHub webhook notifies WordPress plugin
- Plugin validates webhook and triggers GitHub Actions workflow
- GitHub Actions builds theme (npm install, compile assets, etc.)
- Plugin polls GitHub API for build completion
- Plugin downloads artifact ZIP from GitHub
- Plugin creates backup of current theme
- Plugin extracts and deploys new theme files
- Deployment logged to database with full details
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ GitHub │────────▶│ WordPress │────────▶│ Theme │
│ Repository │ webhook │ Plugin │ deploy │ Directory │
└─────────────┘ └──────────────┘ └─────────────┘
│ │
│ │
▼ ▼
┌─────────────┐ ┌──────────────┐
│ GitHub │◀────────│ Database │
│ Actions │ trigger │ Deployments │
└─────────────┘ └──────────────┘
Core Classes:
class-github-api.php- GitHub REST API v3 wrapper usingwp_remote_request()class-deployment-manager.php- Orchestrates deployment workflow, backup/rollbackclass-webhook-handler.php- REST API endpoint for GitHub webhooks with HMAC validationclass-database.php- Custom tables for deployment historyclass-settings.php- Encrypted token storage and configurationclass-admin-pages.php- Admin UI (settings, dashboard, history)
- PHP: 7.4+ (typed properties, arrow functions, null coalescing)
- JavaScript: Vanilla ES6+ (Fetch API, async/await) - NO frameworks
- CSS: WordPress admin styles + minimal custom CSS
- HTTP Client:
wp_remote_request()(WordPress HTTP API, not cURL) - Database:
wpdbwith custom tables (NOT post types) - Caching: Transients API for GitHub API responses
- Background Jobs: WP_Cron for polling build status
- File Operations:
WP_FilesystemAPI - Authentication: GitHub Personal Access Token (encrypted with
sodium_crypto_secretbox())
- REST API: Custom endpoints for webhooks, AJAX operations
- Settings API: Options page registration
- Transients API: Caching GitHub API responses
- WP_Cron: Every-minute polling for build completion
- WP_Filesystem: Safe file operations (backups, deployments)
- Nonces: CSRF protection on all forms and AJAX
Custom table {prefix}_deploy_forge_deployments:
id- Primary keycommit_hash- 40 char SHAcommit_message,commit_author- Git metadatadeployed_at- Datetimestatus- enum: pending, building, success, failed, rolled_backbuild_url,build_logs,deployment_logs- Text fieldstrigger_type- enum: auto, manual, webhooktriggered_by_user_id- WP user ID
deploy-forge.php # Main plugin file with header
deploy-forge/
├── includes/
│ ├── class-database.php # Schema and table creation
│ ├── class-github-api.php # GitHub API wrapper
│ ├── class-deployment-manager.php # Deployment orchestration
│ ├── class-webhook-handler.php # REST endpoint for webhooks
│ └── class-settings.php # Options management
├── admin/
│ ├── class-admin-pages.php # Menu registration
│ ├── class-setup-wizard.php # Setup wizard
│ ├── css/admin-styles.css # Custom admin styles
│ └── js/admin-scripts.js # AJAX handlers, UI logic
└── templates/
├── settings-page.php # Configuration form
├── deployments-page.php # Deployments landing page (stats, deploy now, history)
└── setup-wizard/ # Setup wizard templates
- Capability checks: Only admins (
manage_options) - Nonces: All AJAX and form submissions
- Input sanitization: All user inputs via
sanitize_*() - Output escaping: All outputs via
esc_*() - Token encryption:
sodium_crypto_secretbox()with WordPress salts - Webhook validation: HMAC SHA256 signature verification
- Path validation: Prevent directory traversal in file operations
- Rate limiting: Webhook endpoint protection
v1.0 Scope (In):
- Single repository/branch connection
- Theme deployment only (NOT plugins)
- GitHub Actions integration only
- Basic deployment history
- Manual and automatic modes
- Rollback to previous version
- Webhook support
Out of Scope:
- Plugin deployments
- Multiple repositories
- Multi-environment (staging/prod)
- Email/Slack notifications
- Deployment scheduling
- GitLab/Bitbucket support
- WordPress 5.8+
- PHP 7.4+
- MySQL 5.7+ or MariaDB 10.2+
- Write permissions to
wp-content/themes - HTTPS (for webhooks)
- wp-cron enabled
- Personal Access Token with scopes:
repo,actions - GitHub Actions enabled
- Workflow file (e.g.,
.github/workflows/build-theme.yml)
- Minimize dependencies: Use WordPress native functions over external libraries
- No build process for plugin itself (simple PHP/JS)
- No Composer autoloader (simple requires)
- No jQuery plugins (vanilla JS only)
- No ORMs (wpdb is sufficient)
- Keep it simple: WordPress best practices, maximum compatibility
When making changes to the codebase:
- ✅ Update
CHANGELOG.md- Track all features, fixes, and changes with version numbers - ❌ DO NOT create feature markdown files - No files like
NEW-FEATURE.md,FEATURE-NOTES.md,IMPLEMENTATION.md, etc.
Use CHANGELOG.md as the single source for tracking changes, features, and notes.