wp-admin-browser
Use when a WordPress admin panel needs real browser interaction via Chrome DevTools MCP — logging in, navigating admin menus, clicking buttons, filling and…
Use when a WordPress plugin needs to run work outside the HTTP request cycle — scheduling async or recurring jobs with Action Scheduler (as_enqueue_async_action, as_schedule_single_action, as_schedule_recurring_action, as_unschedule_action), implementing WP_Background_Process
$ npx -y skills add mralaminahamed/wp-dev-skills --skill wp-background-processing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/wp-background-processingContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when a WordPress plugin needs to run work outside the HTTP request cycle — scheduling async or recurring jobs with Action Scheduler (as_enqueue_async_action, as_schedule_single_action, as_schedule_recurring_action, as_unschedule_action), implementing WP_Background_Process
name: wp-background-processing description: "Use when a WordPress plugin needs to run work outside the HTTP request cycle — scheduling async or recurring jobs with Action Scheduler (as_enqueue_async_action, as_schedule_single_action, as_schedule_recurring_action, as_unschedule_action), implementing WP_Background_Process (push_to_queue, save, dispatch, is_queue_empty), registering WP Cron events (wp_schedule_event, wp_clear_scheduled_hook), batch-processing large datasets without hitting PHP timeouts, tracking job progress, handling retries on failure, or debugging the actionscheduler_actions table. Triggers: \"schedule this for later\", \"run this without hitting timeout\", \"queue these items for background processing\", \"why is my cron not running\", \"Action Scheduler job keeps failing\", \"as_enqueue_async_action\", \"WP_Background_Process\", \"push_to_queue\", \"dispatch the queue\", \"DISABLE_WP_CRON\", \"process records in batches\", \"send emails in the background\", \"WP Cron not firing\", \"batch import without timeout\", \"scheduled action not running\", \"background job stuck\", \"wp action-scheduler list\", \"recurring cron event\", \"progress tracking for batch job\", \"retry failed background tasks\", \"chunked processing to avoid timeout\", \"scheduled action completes but nothing happens\", \"my hook never fires in cron\", \"handler registered behind is_admin\", \"job runs in admin but not from cron\", \"webhook fired twice\", \"background job double-processed\", \"make my background job idempotent\". Not for: real-time AJAX handlers or synchronous REST endpoints."
> **Model note:** Scaffolding a new Action Scheduler or `WP_Background_Process` implementation is pattern-matching — `haiku` handles it well. Debugging a stuck queue or race condition across async jobs requires reasoning; use `sonnet`.
Implement background jobs and queued tasks in WordPress plugins. Three primary tools with distinct trade-offs: Action Scheduler (persistent, battle-tested), `WP_Background_Process` (lightweight, no DB table), WP Cron (built-in, unreliable timing).
**Not for:** One-off scheduled events (use `wp_schedule_single_event`). REST API async patterns — use `wp-rest-api`.
| Tool | Persistent | Retry | Progress | Requires | Best for | |---|---|---|---|---|---| | Action Scheduler | ✅ DB table | ✅ Configurable | Via hooks | AS or WC | Reliable multi-step queues | | WP_Background_Process | ✅ Options API | ❌ Manual | Via option | ~5KB class | Simple batches, no WC dep | | WP Cron | ❌ (transient) | ❌ | ❌ | Nothing | Maintenance, low-priority tasks |
**Rule of thumb:** WooCommerce already installed → Action Scheduler. Simple background batch → `WP_Background_Process`. Periodic cleanup task → WP Cron.
Bundled with WooCommerce. Can also be installed as a standalone library.
**Standalone install:**
composer require woocommerce/action-scheduler
require_once plugin_dir_path( __FILE__ ) . 'vendor/woocommerce/action-scheduler/action-scheduler.php';
**Schedule and handle actions:**
// Schedule a single action (fires once ASAP)
as_enqueue_async_action( 'my_plugin_process_item', [ 'item_id' => 123 ], 'my-plugin' );
// Schedule a recurring action
as_schedule_recurring_action( time(), HOUR_IN_SECONDS, 'my_plugin_hourly_sync', [], 'my-plugin' );
// Schedule a single action in the future
as_schedule_single_action( time() + 300, 'my_plugin_delayed_job', [ 'batch' => 1 ], 'my-plugin' );
// Handle the action
add_action( 'my_plugin_process_item', function( $item_id ) {
$result = my_plugin_do_work( $item_id );
if ( is_wp_error( $result ) ) {
// AS will retry on exception; throw to trigger retry
throw new \Exception( $result->get_error_message() );
}
} );**Batch queue (fan-out pattern):**
function my_plugin_queue_all_items() {
$items = get_posts( [ 'post_type' => 'my_type', 'posts_per_page' => -1, 'fields' => 'ids' ] );
foreach ( $items as $id ) {
// Skip if already scheduled
if ( ! as_has_scheduled_action( 'my_plugin_process_item', [ 'item_id' => $id ], 'my-plugin' ) ) {
as_enqueue_async_action( 'my_plugin_process_item', [ 'item_id' => $id ], 'my-plugin' );
}
}
}**Cancel scheduled actions:**
as_unschedule_action( 'my_plugin_hourly_sync', [], 'my-plugin' ); as_unschedule_all_actions( 'my_plugin_process_item', [], 'my-plugin' );
**Monitor via WP-CLI:**
wp action-scheduler list --group=my-plugin --status=pending wp action-scheduler run --group=my-plugin
Lightweight 2-class library using WP options + transients for queue state. No extra DB table.
composer require deliciousbrains/wp-background-processing
**Extend the class:**
class My_Plugin_Batch_Process extends WP_Background_Process {
protected $action = 'my_plugin_batch'; // Unique key — used for cron and option names
protected function task( $item ) {
// Process one item. Return false to remove from queue; return $item to re-queue.
$result = my_plugin_process( $item['id'] );
if ( is_wp_error( $result ) ) {
// Log and skip — returning $item would re-queue endlessly
error_log( 'my-plugin: failed item ' . $item['id'] . ': ' . $result->get_error_message() );
return false;
}
return false; // Done — remove from queue
}
protected function completCovers the complete WordPress plugin development lifecycle — build, test, audit, release, and ship to WP.org — for Claude Code, Gemini CLI, Cursor, Windsurf, Cline, Codex, GitHub Copilot, opencode, and more.
Repo: mralaminahamed/wp-dev-skills
Use when a WordPress admin panel needs real browser interaction via Chrome DevTools MCP — logging in, navigating admin menus, clicking buttons, filling and…
Use when setting up, configuring, or debugging the JavaScript/CSS build pipeline for a WordPress plugin — @wordpress/scripts, webpack (webpack.config.js, entry…
Use when a pull request has QA failures, a \"Testing Failed\" label, or QA comments reporting broken features — reading QA feedback and PR comments, tracing…
Use when setting up PHPCS with WordPress Coding Standards (WPCS), configuring phpcs.xml.dist, running phpcs/phpcbf, fixing sniff violations, adding PHPCS to CI…
Use when a WordPress plugin needs a custom database table — creating with dbDelta (strict SQL format: two spaces before PRIMARY KEY, no trailing comma),…
Use when adding or refactoring transactional emails in a WordPress plugin — extracting inline HTML strings into reusable templates sharing a branded base…