Skip to main content
skill CX Codex

wordpress-performance-best-practices — Claude Code skill: WordPress

A skill that feeds your coding agent 34 WordPress performance rules, ordered by impact. Useful when you write or review PHP for plugins and themes.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add bartekmis/wordpress-performance-best-practices --skill wordpress-performance-best-practices -a claude-code
Open on GitHub

What wordpress-performance-best-practices does

The skill loads as a rule set and triggers on tasks that touch WP_Query, database queries, caching, hooks, the REST API, or theme and plugin development. It holds 34 rules in 8 categories, sorted by how much they affect page speed.

Rules live in separate files with prefixes db-, cache-, asset-, theme-, plugin-, media-, api- and advanced-. Each file explains why the rule matters, shows a wrong code example with commentary, then a correct one. A compiled AGENTS.md collects every rule in one document.

The first two categories carry the weight. db-prepared-statements says to wrap queries in $wpdb->prepare(), and db-limit-query-results rules out posts_per_page => -1. Point the agent at an existing plugin and it will flag direct database calls during review, which is a good reason to count how many you already have. MIT licensed, no API keys needed.

What it helps with

  • spot slow queries in plugin code
  • swap raw database calls for WP_Query
  • cache responses from external APIs
  • stop loading unused scripts and styles
  • find queries buried in theme templates

Example prompts for the agent

  • Review my plugin against wordpress-performance-best-practices, start with the database category
  • Refactor this WP_Query loop using the skill rules
  • Show me the cache-transients-proper-use rule and rewrite my code to match it

How to install wordpress-performance-best-practices

1Skills CLI (Vercel)

npx skills add bartekmis/wordpress-performance-best-practices --skill wordpress-performance-best-practices -a claude-code

2Manually: put the files in place

~/.claude/skills/wordpress-performance-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/wordpress-performance-best-practices/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about wordpress-performance-best-practices

How do I install wordpress-performance-best-practices in Claude?

Run npx skills add bartekmis/wordpress-performance-best-practices --skill wordpress-performance-best-practices -a claude-code. The skill lands at ~/.claude/skills/wordpress-performance-best-practices/SKILL.md.

What does wordpress-performance-best-practices do?

It gives the agent 34 WordPress performance rules across 8 categories, each with code examples. The agent applies them while writing, reviewing or refactoring plugin and theme PHP.

Which platforms does it work with?

Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode. Each platform has its own install command and skill file path.

Source text

SKILL.md · MIT
---
name: wordpress-performance-best-practices
description: WordPress performance optimization guidelines for plugin, theme, and custom code development. This skill should be used when writing, reviewing, or refactoring WordPress PHP code to ensure optimal performance patterns. Triggers on tasks involving WP_Query, database queries, caching, hooks, REST API, or WordPress theme/plugin development.
license: MIT
metadata:
  author: bartekmis
  version: "1.0.0"
---

# WordPress Performance Best Practices

Comprehensive performance optimization guide for WordPress development, designed for AI agents and LLMs. Contains 34 rules across 8 categories, prioritized by impact to guide code review and generation.

## When to Apply

Reference these guidelines when:
- Writing WordPress plugins or themes
- Working with WP_Query or database operations
- Implementing caching (transients, object cache)
- Optimizing asset loading (scripts, styles)
- Reviewing WordPress code for performance issues
- Working with REST API or AJAX handlers

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Database Optimization | CRITICAL | `db-` |
| 2 | Caching Strategies | CRITICAL | `cache-` |
| 3 | Asset Management | HIGH | `asset-` |
| 4 | Theme Performance | HIGH | `theme-` |
| 5 | Plugin Architecture | MEDIUM-HIGH | `plugin-` |
| 6 | Media Optimization | MEDIUM | `media-` |
| 7 | API and AJAX | MEDIUM | `api-` |
| 8 | Advanced Patterns | LOW-MEDIUM | `advanced-` |

## Quick Reference

### 1. Database Optimization (CRITICAL)

- `db-prepared-statements` - Always use $wpdb->prepare() for queries
- `db-avoid-post-not-in` - Avoid post__not_in, filter in PHP instead
- `db-use-wp-query` - Use WP_Query/get_posts instead of direct DB queries
- `db-limit-query-results` - Never use posts_per_page => -1
- `db-meta-query-indexing` - Optimize meta queries, consider taxonomies
- `db-fields-optimization` - Use fields => 'ids' when only IDs needed

### 2. Caching Strategies (CRITICAL)

- `cache-transients-proper-use` - Use transients for external API calls
- `cache-object-cache` - Use wp_cache_* with cache groups
- `cache-remote-requests` - Always cache wp_remote_get responses
- `cache-invalidation` - Implement precise, event-driven invalidation
- `cache-fragment-caching` - Cache expensive template fragments

### 3. Asset Management (HIGH)

- `asset-proper-enqueue` - Use wp_enqueue_script/style, never hardcode
- `asset-conditional-loading` - Only load assets where needed
- `asset-defer-async` - Use defer/async for non-critical scripts
- `asset-dequeue-unused` - Remove unused plugin assets
- `asset-minification` - Minify assets, use critical CSS

### 4. Theme Performance (HIGH)

- `theme-avoid-queries-in-templates` - Keep queries out of template files
- `theme-template-parts` - Use get_template_part with data passing
- `theme-loop-optimization` - Optimize loops, use meta/term cache priming
- `theme-hooks-placement` - Use appropriate hook priorities

### 5. Plugin Architecture (MEDIUM-HIGH)

- `plugin-conditional-loading` - Load code only when needed
- `plugin-autoloading` - Use PSR-4 autoloading
- `plugin-activation-hooks` - Use activation hooks for setup tasks
- `plugin-hook-removal` - Remove hooks properly with matching priority

### 6. Media Optimization (MEDIUM)

- `media-responsive-images` - Use srcset and sizes attributes
- `media-lazy-loading` - Lazy load below-fold, eager load LCP
- `media-image-sizes` - Define appropriate custom image sizes

### 7. API and AJAX (MEDIUM)

- `api-rest-optimization` - Optimize REST endpoints, add caching headers
- `api-admin-ajax` - Use REST API for frontend, avoid admin-ajax
- `api-nonce-validation` - Implement proper nonce validation

### 8. Advanced Patterns (LOW-MEDIUM)

- `advanced-autoload-optimization` - Keep autoloaded options under 800KB
- `advanced-cron-optimization` - Use system cron, batch long tasks
- `advanced-memory-management` - Process in batches, clean up memory
- `advanced-query-monitor` - Profile before optimizing

## How to Use

Read individual rule files for detailed explanations and code examples:

```
rules/db-prepared-statements.md
rules/cache-transients-proper-use.md
rules/_sections.md
```

Each rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

© bartekmis · MIT · bartekmis/wordpress-performance-best-practices

Similar skills

All skills for Backend and APIs →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor