WP Feature Builder
AI-powered WordPress feature generation from plain English
by SmartWeb Agency · github.com/sethshoultes/wp-feature-builder · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/sethshoultes/wp-feature-builder/archive/refs/heads/master.zipReadme
WP Feature Builder
Describe what you want your WordPress site to do. Get WPCS-compliant PHP code that works.
WP Feature Builder is an AI-powered code generator that turns plain-English descriptions into production-ready WordPress features. It generates Custom Post Types, meta boxes, shortcodes, REST endpoints, and Gutenberg blocks -- all following WordPress Coding Standards, with built-in version control and one-click activation.
Features
- Natural language input -- describe your feature in plain English
- Five feature types -- CPT, meta box, shortcode, REST endpoint, Gutenberg block
- WPCS-compliant output -- generated code follows WordPress Coding Standards strictly
- Security by default -- nonce verification, capability checks, prepared queries, output escaping
- Pre-flight validation -- syntax checking and security scanning before activation
- Version control -- every generation creates a version snapshot with full rollback support
- Provider flexibility -- Claude, ChatGPT, or OpenRouter with automatic fallback
- Proxy or BYOK -- use the SmartWeb proxy (credit-based) or bring your own API keys
- Code preview -- review generated code with plain-English summaries before activating
- Activity logging -- full audit trail of generations, activations, and rollbacks
- Plugin export -- export any feature as a standalone WordPress plugin
Requirements
- WordPress 6.0+
- PHP 7.4+
- Composer (for autoloading)
Installation
- Upload the
wp-feature-builderdirectory towp-content/plugins/. - Run
composer installinside the plugin directory. - Activate the plugin through the WordPress admin.
- Navigate to Feature Builder > Settings to configure your AI provider.
Configuration
API Key Modes
Proxy Mode (recommended for most users): The plugin connects to the SmartWeb proxy worker, which handles API keys and billing. You receive credits based on your license tier (Free: 5/month, Pro: 20/month, Agency: 50/month). No API keys required on your end.
- Go to Feature Builder > Settings.
- Enable Proxy Mode.
- The proxy URL is pre-configured. Your site token is generated automatically on activation.
BYOK Mode (Bring Your Own Key): Use your own API keys for direct provider access. No credit limits -- you pay the provider directly.
- Go to Feature Builder > Settings.
- Disable Proxy Mode.
- Enter your API key for one or more providers:
- Claude (Anthropic) -- recommended for code generation
- ChatGPT (OpenAI)
- OpenRouter -- access to multiple models through a single key
API keys are encrypted at rest using WordPress salts before storage.
Provider Selection
Set a default provider in settings. If the default provider's credentials are invalid or the API is down, the plugin automatically falls back through the chain: Claude > ChatGPT > OpenRouter.
You can also override the provider per-request through the REST API.
Complexity Preference
Choose between Simple (fewer lines, minimal implementation) and Feature-rich (more functionality, more options). This preference is injected into the AI prompt.
Usage
Generating a Feature
- Go to Feature Builder in the admin menu.
- Select a feature type (e.g., Custom Post Type).
- Describe what you want in plain English:
"A testimonials post type with fields for client name, company, rating (1-5 stars), and testimonial text. Include a shortcode to display the three most recent testimonials in a grid."
- Click Generate.
- Review the generated code and pre-flight report.
- Click Activate to enable the feature on your site.
Managing Features
- View -- see the generated code, version history, and pre-flight status
- Activate/Deactivate -- toggle features on and off without deleting them
- Rollback -- revert to any previous version (current state is auto-saved first)
- Delete -- permanently remove a feature and all its versions
- Export -- download a feature as a standalone plugin ZIP
Feature Lifecycle
- Draft -- generated but not active, code on disk but not loaded
- Active -- code is loaded on every request via the FeatureLoader
- Inactive -- deactivated, code remains on disk for re-activation
Supported Feature Types
| Type | Slug | What It Generates |
|---|---|---|
| Custom Post Type | cpt |
register_post_type(), labels, taxonomies, meta boxes, admin columns, REST support |
| Meta Box | meta-box |
add_meta_box(), custom fields (text, textarea, select, checkbox, date), nonce + save handling |
| Shortcode | shortcode |
add_shortcode(), attributes via shortcode_atts(), escaped HTML output |
| REST Endpoint | rest-endpoint |
register_rest_route() in wfb/v1 namespace, GET/POST handlers, permission callbacks |
| Gutenberg Block | gutenberg-block |
register_block_type(), block.json, edit/save JSX, InspectorControls, CSS |
REST API
All endpoints are under the wfb/v1 namespace and require manage_options capability.
Generate a Feature
POST /wp-json/wfb/v1/generate
Body (JSON):
{
"description": "A FAQ accordion shortcode with schema markup",
"feature_type": "shortcode",
"provider": "claude"
}
Response (201):
{
"id": 12,
"slug": "faq-accordion-shortcode-with",
"name": "A FAQ accordion shortcode with...",
"feature_type": "shortcode",
"status": "draft",
"code": "<?php ...",
"provider": "claude",
"model": "claude-sonnet-4-5-20250514",
"tokens_used": 2847,
"validation": { "passed": true, "errors": [] },
"preflight": { "status": "pass", "checks": [...] }
}
List Features
GET /wp-json/wfb/v1/features?status=active&per_page=20&page=1
Returns an array of features. Total count in X-WP-Total header.
Get a Single Feature
GET /wp-json/wfb/v1/features/{id}
Returns the feature with version history, code content, and a plain-English summary.
Activate / Deactivate
POST /wp-json/wfb/v1/features/{id}/activate
POST /wp-json/wfb/v1/features/{id}/deactivate
Rollback to a Version
POST /wp-json/wfb/v1/features/{id}/rollback/{version_id}
Auto-saves the current state before rolling back.
Delete a Feature
DELETE /wp-json/wfb/v1/features/{id}
Settings
GET /wp-json/wfb/v1/settings
POST /wp-json/wfb/v1/settings
POST body accepts: default_provider, proxy_mode, proxy_url, complexity_preference, api_keys (object keyed by provider ID).
Activity Log
GET /wp-json/wfb/v1/activity?per_page=50&page=1
Available Providers
GET /wp-json/wfb/v1/providers
Returns each provider's ID, display name, and whether credentials are configured.
Development
Project Structure
wp-feature-builder/
src/
AI/
ClaudeProvider.php # Anthropic API integration
ChatGPTProvider.php # OpenAI API integration
OpenRouterProvider.php # OpenRouter API integration
PromptBuilder.php # System/user prompt assembly
ProviderFactory.php # Provider instantiation + fallback chain
ProviderInterface.php # Contract for all providers
Admin/
CodePreview.php # Plain-English code summaries
FeatureManager.php # Activate, deactivate, delete operations
RestAPI.php # All wfb/v1 REST endpoints
SettingsPage.php # Admin settings UI
Export/
PluginExporter.php # Export features as standalone plugins
Feature/
FeatureInterface.php # Contract for loaded features
FeatureLoader.php # Loads active features on every request
FeatureRegistry.php # CRUD for wfb_features table
VersionControl.php # Version snapshots and rollback
Generator/
CodeValidator.php # WPCS + security validation
CodeWriter.php # Writes generated code to disk
FeatureGenerator.php # Orchestrates the generation pipeline
Sandbox.php # Pre-flight syntax and security checks
Encryption.php # AES encryption for API keys
Plugin.php # Singleton bootstrap, DB migrations
templates/
prompts/ # Overridable prompt templates per feature type
assets/ # Admin CSS and JS
data/ # Static data files
languages/ # Translation files
Autoloading
PSR-4 via Composer. Namespace WPFeatureBuilder\ maps to src/.
composer install
composer dump-autoload -o
Coding Standards
composer require --dev squizlabs/php_codesniffer wp-coding-standards/wpcs
./vendor/bin/phpcs --standard=phpcs.xml src/
Database Tables
The plugin creates three tables on activation:
{prefix}wfb_features-- feature records (slug, type, status, provider, tokens used){prefix}wfb_versions-- version snapshots (code, prompt, provider response){prefix}wfb_activity_log-- audit trail (feature ID, action, user, timestamp)
Generated Code Storage
Generated PHP files are written to wp-content/wfb-generated/ with .htaccess protection (deny direct access). Each feature gets a file named by its slug.
FAQ
Q: Is the generated code safe to run on production? A: Every feature goes through pre-flight validation (syntax check, security scan) before it can be activated. However, you should always review generated code before activating on a production site.
Q: What happens if I deactivate the plugin? A: All generated features stop loading immediately. The code files and database records are preserved. Reactivating the plugin restores everything.
Q: Can I edit the generated code manually?
A: Yes. The generated PHP files in wp-content/wfb-generated/ are regular PHP files. Manual edits persist until the next generation or rollback.
Q: How does the fallback chain work? A: If your default provider fails (invalid key, API down), the plugin tries the next configured provider automatically: Claude > ChatGPT > OpenRouter. This only applies when using BYOK mode with multiple keys configured.
Q: What does uninstalling do?
A: The uninstall.php file removes all plugin options, database tables, and generated code files.
Changelog
1.0.0
- Initial release
- Five feature types: CPT, meta box, shortcode, REST endpoint, Gutenberg block
- Three AI providers: Claude, ChatGPT, OpenRouter
- Version control with rollback
- Pre-flight validation
- Plugin export
- Proxy and BYOK modes
License
GPL-2.0-or-later. See LICENSE.