create-wp-ai-block
v1.0.1
Published
Zero-auth scaffolding CLI tool for creating WordPress AI blocks.
Readme
create-wp-ai-block
A zero-config CLI tool for scaffolding AI-powered WordPress blocks. It sets up a fully functional Gutenberg block plugin that connects directly to AI APIs like OpenAI or Google Gemini out of the box.
Requirements
- Node.js
- npm
- WordPress environment (local or live)
🎉 Now Available on NPM!
create-wp-ai-block is officially published to the NPM registry! You don't need to clone this repository or install anything globally.
Anyone can scaffold a new AI block anywhere on their computer instantly using npx:
npx create-wp-ai-block my-ai-pluginIf you prefer to install it globally:
npm install -g create-wp-ai-block
create-wp-ai-block my-ai-pluginSetup Process
- When you run the command, it will ask you for a project slug and display title (if you didn't provide one).
- It will prompt you to select an AI provider:
- OpenAI (GPT-4o-mini)
- Google Gemini (Flash models with multi-model auto-failover)
- The CLI will generate a complete WordPress block plugin inside a new folder matching your project name, replace all placeholders, and install the necessary dependencies via
npm install.
✨ Features
- In-Block Canvas & Sidebar Controls: Interactive UI directly inside the editor canvas with quick prompt suggestion chips, progress indicators, clear button, and inspector sidebar controls.
- Clean HTML Formatting (No Raw Markdown): AI output is automatically converted to semantic HTML (
<p>,<h3>,<strong>,<ul>,<li>), ensuring no raw**or##markdown characters appear in Gutenberg. - Name & Entity Preservation: Strict system instructions ensure all specific names, brands, titles, and entities in the prompt are preserved without alteration.
- Multi-Model Auto-Failover (Gemini): Cascades through
gemini-3.6-flash,gemini-3.5-flash,gemini-3.7-flash, andgemini-flash-latestso your block never fails during temporary provider demand spikes. - Local Dev Friendly: Built-in SSL verification bypass for local environments (XAMPP, LocalWP, Docker, Windows, macOS, Linux).
Using the Scaffolded Plugin
After the scaffolding finishes, navigate into your new project folder:
cd my-ai-pluginBuild the block assets:
npm run buildNote: Use
npm startwhile developing to automatically recompile your code when you save.Add to WordPress: Copy the
my-ai-pluginfolder into your WordPresswp-content/plugins/directory.Activate the Plugin: Log into your WordPress admin dashboard, go to Plugins, and activate it.
Add your API Key: Open the main plugin PHP file (e.g.,
my-ai-plugin.php) or yourwp-config.phpand add your API key for the provider you chose. For example:// If using OpenAI: define( 'OPENAI_API_KEY', 'your-actual-api-key-here' ); // If using Google Gemini: define( 'GEMINI_API_KEY', 'your-actual-api-key-here' );Test it out: Open any post or page, insert your new block from the block inserter, enter a prompt (or click one of the quick suggestions), hit Generate AI Content, and see the formatted content appear right in the block!
License
GPL-2.0
