Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add bartekmis/wordpress-performance-best-practises
Or install specific skill: npx add-skill https://github.com/bartekmis/wordpress-performance-best-practises
# 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.
# SKILL.md
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 queriesdb-avoid-post-not-in- Avoid post__not_in, filter in PHP insteaddb-use-wp-query- Use WP_Query/get_posts instead of direct DB queriesdb-limit-query-results- Never use posts_per_page => -1db-meta-query-indexing- Optimize meta queries, consider taxonomiesdb-fields-optimization- Use fields => 'ids' when only IDs needed
2. Caching Strategies (CRITICAL)
cache-transients-proper-use- Use transients for external API callscache-object-cache- Use wp_cache_* with cache groupscache-remote-requests- Always cache wp_remote_get responsescache-invalidation- Implement precise, event-driven invalidationcache-fragment-caching- Cache expensive template fragments
3. Asset Management (HIGH)
asset-proper-enqueue- Use wp_enqueue_script/style, never hardcodeasset-conditional-loading- Only load assets where neededasset-defer-async- Use defer/async for non-critical scriptsasset-dequeue-unused- Remove unused plugin assetsasset-minification- Minify assets, use critical CSS
4. Theme Performance (HIGH)
theme-avoid-queries-in-templates- Keep queries out of template filestheme-template-parts- Use get_template_part with data passingtheme-loop-optimization- Optimize loops, use meta/term cache primingtheme-hooks-placement- Use appropriate hook priorities
5. Plugin Architecture (MEDIUM-HIGH)
plugin-conditional-loading- Load code only when neededplugin-autoloading- Use PSR-4 autoloadingplugin-activation-hooks- Use activation hooks for setup tasksplugin-hook-removal- Remove hooks properly with matching priority
6. Media Optimization (MEDIUM)
media-responsive-images- Use srcset and sizes attributesmedia-lazy-loading- Lazy load below-fold, eager load LCPmedia-image-sizes- Define appropriate custom image sizes
7. API and AJAX (MEDIUM)
api-rest-optimization- Optimize REST endpoints, add caching headersapi-admin-ajax- Use REST API for frontend, avoid admin-ajaxapi-nonce-validation- Implement proper nonce validation
8. Advanced Patterns (LOW-MEDIUM)
advanced-autoload-optimization- Keep autoloaded options under 800KBadvanced-cron-optimization- Use system cron, batch long tasksadvanced-memory-management- Process in batches, clean up memoryadvanced-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
# README.md
WordPress Performance Best Practices
Created by WOW - Wielka Optymalizacja WordPressa, Bartek Miś
A comprehensive performance optimization guide for WordPress development, designed for AI agents and LLMs assisting developers.
How to Use
Install the skill in Claude Code:
npx add-skill bartekmis/wordpress-performance-best-practises
Once installed, Claude will automatically apply these performance guidelines when working with WordPress code.
Overview
This project provides a curated set of performance rules for WordPress development based on:
- WordPress VIP Coding Standards
- WordPress Coding Standards
- 10up Engineering Best Practices
- Official WordPress Developer Documentation
For AI Agents
If you're an AI agent or LLM, use the compiled AGENTS.md file which contains all rules in a single, optimized format.
Structure
wordpress-performance-best-practices/
├── AGENTS.md # Compiled output for AI agents
├── SKILL.md # Skill definition for agent integration
├── README.md # This file
├── metadata.json # Project metadata
├── rules/ # Individual rule files
│ ├── _sections.md # Section definitions
│ ├── _template.md # Template for new rules
│ ├── db-*.md # Database optimization rules
│ ├── cache-*.md # Caching strategy rules
│ ├── asset-*.md # Asset management rules
│ ├── theme-*.md # Theme performance rules
│ ├── plugin-*.md # Plugin architecture rules
│ ├── media-*.md # Media optimization rules
│ ├── api-*.md # API and AJAX rules
│ └── advanced-*.md # Advanced pattern rules
└── build/ # Build tools
├── src/ # TypeScript source
└── package.json # Build dependencies
Sections
| # | Section | Prefix | Impact | Description |
|---|---|---|---|---|
| 1 | Database Optimization | db- |
CRITICAL | Query optimization, prepared statements, indexing |
| 2 | Caching Strategies | cache- |
CRITICAL | Object cache, transients, page caching |
| 3 | Asset Management | asset- |
HIGH | Script/style loading, defer/async |
| 4 | Theme Performance | theme- |
HIGH | Template optimization, loop performance |
| 5 | Plugin Architecture | plugin- |
MEDIUM-HIGH | Conditional loading, hooks, autoloading |
| 6 | Media Optimization | media- |
MEDIUM | Image handling, lazy loading |
| 7 | API and AJAX | api- |
MEDIUM | REST API, admin-ajax optimization |
| 8 | Advanced Patterns | advanced- |
LOW-MEDIUM | Autoload, cron, memory management |
Usage
For Developers
Browse individual rule files in the rules/ directory for detailed explanations and examples.
For AI Agents
- Include
AGENTS.mdin your context - Or use
SKILL.mdfor agent framework integration
Building
cd build
npm install
npm run build
This compiles all rules into AGENTS.md.
Contributing
- Create a new rule file in
rules/using_template.mdas a guide - Use the appropriate prefix for your section (e.g.,
db-for database rules) - Include both incorrect and correct code examples
- Run the build to regenerate
AGENTS.md - Submit a pull request
Rule Format
Each rule follows this structure:
---
title: Rule Title
impact: CRITICAL | HIGH | MEDIUM-HIGH | MEDIUM | LOW-MEDIUM | LOW
impactDescription: Optional quantified improvement
tags: comma, separated, tags
---
## Rule Title
Explanation of the rule.
**Incorrect (description):**
\`\`\`php
// Bad code
\`\`\`
**Correct (description):**
\`\`\`php
// Good code
\`\`\`
Reference: [Link](url)
License
MIT License - Feel free to use this in your projects and AI agents.
References
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.