From cms-cultivator
Comprehensive performance analysis and Core Web Vitals optimization using performance specialist
How this command is triggered — by the user, by Claude, or both
Slash command
/cms-cultivator:audit-perf [options]Files this command reads when invoked
This command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
Spawn the **performance-specialist** agent using: ## Arguments This command supports flexible argument modes for different use cases: ### Depth Modes - `--quick` - Core Web Vitals only (~5 min) - LCP, INP, CLS status check - `--standard` - CWV + major bottlenecks (default, ~15 min) - Comprehensive performance audit - `--comprehensive` - Full profiling + recommendations (~30 min) - Deep analysis with detailed optimizations ### Scope Control - `--scope=current-pr` - Only files changed in current PR (uses git diff) - `--scope=module=<name>` - Specific module/directory (e.g., `--scope=mod...
Spawn the performance-specialist agent using:
Task(cms-cultivator:performance-specialist:performance-specialist,
prompt="Analyze performance and optimize Core Web Vitals (LCP, INP, CLS) with the following parameters:
- Depth mode: [quick/standard/comprehensive - parsed from arguments, default: standard]
- Scope: [current-pr/module/file/entire - parsed from arguments, default: entire]
- Format: [report/json/summary/checklist - parsed from arguments, default: report]
- Target threshold: [good/needs-improvement - parsed from arguments, optional]
- Focus area: [use legacy focus argument if provided, otherwise 'complete analysis']
- Files to analyze: [file list based on scope]
Check database queries, caching strategies, asset optimization, and rendering for both Drupal and WordPress projects. Save the comprehensive audit report to a file (audit-perf-YYYY-MM-DD-HHMM.md) and present the file path to the user.")
This command supports flexible argument modes for different use cases:
--quick - Core Web Vitals only (~5 min) - LCP, INP, CLS status check--standard - CWV + major bottlenecks (default, ~15 min) - Comprehensive performance audit--comprehensive - Full profiling + recommendations (~30 min) - Deep analysis with detailed optimizations--scope=current-pr - Only files changed in current PR (uses git diff)--scope=module=<name> - Specific module/directory (e.g., --scope=module=src/api)--scope=file=<path> - Single file (e.g., --scope=file=src/queries.php)--scope=frontend - Only frontend files (assets, CSS, JS, images)--scope=backend - Only backend files (database queries, caching, API)--scope=entire - Full codebase (default)--format=report - Detailed report with metrics and recommendations (default)--format=json - Structured JSON for CI/CD integration--format=summary - Executive summary with key findings--format=metrics - Core Web Vitals metrics only (LCP, INP, CLS scores)--target=good - Report only if metrics fail "good" thresholds (LCP > 2.5s, INP > 200ms, CLS > 0.1)--target=needs-improvement - Report if metrics need improvement (LCP > 4.0s, INP > 500ms, CLS > 0.25)For backward compatibility, single-word focus areas without -- prefix are treated as legacy focus filters:
queries - Focus on database query optimizationn+1 - Focus on N+1 query detectionassets - Focus on asset optimization (images, fonts, CSS, JS)bundles - Focus on JavaScript bundle analysiscaching - Focus on caching strategy reviewvitals - Focus on Core Web Vitals (LCP, INP, CLS)lcp - Focus on Largest Contentful Paintinp - Focus on Interaction to Next Paintcls - Focus on Cumulative Layout Shift# Quick Core Web Vitals check on your changes
/audit-perf --quick --scope=current-pr
# Quick metrics check with JSON output
/audit-perf --quick --format=metrics
# Quick frontend performance check
/audit-perf --quick --scope=frontend
# Standard audit (same as legacy `/audit-perf`)
/audit-perf
# Standard audit on PR changes
/audit-perf --scope=current-pr
# Standard audit with JSON for CI/CD
/audit-perf --standard --format=json
# Backend performance audit
/audit-perf --standard --scope=backend
# Comprehensive pre-release audit
/audit-perf --comprehensive
# Comprehensive audit with executive summary
/audit-perf --comprehensive --format=summary
# Comprehensive audit with target threshold
/audit-perf --comprehensive --target=good
# Focus on specific area (legacy)
/audit-perf queries
/audit-perf vitals
/audit-perf assets
# Combine legacy focus with new modes
/audit-perf queries --quick
/audit-perf vitals --scope=current-pr
Full Audit:
/audit-perf - Complete performance analysis across all areasFocus Areas:
/audit-perf queries - Database query optimization/audit-perf n+1 - N+1 query detection and fixes/audit-perf assets - Asset optimization (images, fonts, CSS, JS)/audit-perf bundles - JavaScript bundle analysis/audit-perf caching - Caching strategy reviewCore Web Vitals:
/audit-perf vitals - Check all Core Web Vitals (LCP, INP/FID, CLS)/audit-perf lcp - Largest Contentful Paint optimization/audit-perf inp - Interaction to Next Paint optimization/audit-perf fid - First Input Delay optimization (legacy)/audit-perf cls - Cumulative Layout Shift fixesReporting:
/audit-perf lighthouse - Generate Lighthouse performance report/audit-perf report - Generate stakeholder-friendly performance reportQuick Code Analysis:
For quick performance analysis of specific queries or functions during conversation, the performance-analyzer Agent Skill auto-activates when you mention "slow" or "optimize". See: skills/performance-analyzer/SKILL.md
Allowed operations:
Not allowed:
The performance-specialist agent performs all audit operations.
This command spawns the performance-specialist agent, which uses the performance-analyzer skill and performs comprehensive performance audits focused on Core Web Vitals.
The command first parses the arguments to determine the audit parameters:
Depth mode:
--quick, --standard, or --comprehensive flags--standard (if not specified)Scope:
--scope=<value> flag--scope=current-pr: Get changed files using git diff --name-only origin/main...HEAD--scope=frontend: Target CSS, JS, images, fonts--scope=backend: Target PHP, database queries, caching--scope=module=<name>: Target specific directory--scope=file=<path>: Target single file--scope=entire (analyze entire codebase)Format:
--format=<value> flagreport (default), json, summary, metrics--format=reportTarget threshold:
--target=<value> flaggood (strict), needs-improvement (moderate)Legacy focus area:
--, treat as legacy focus areaqueries, n+1, assets, vitals, lcp, inp, cls/audit-perf queries --quickBased on the scope parameter:
For current-pr:
git diff --name-only origin/main...HEAD | grep -E '\.(php|tsx?|jsx?|css|scss|sql)$'
For frontend:
find . -type f \( -name "*.css" -o -name "*.scss" -o -name "*.js" -o -name "*.tsx" -o -name "*.jsx" \)
For backend:
find . -type f \( -name "*.php" -o -name "*.sql" \)
For module=<name> or file=<path>:
Analyze the specified directory or single file.
For entire:
Analyze all relevant files in the codebase.
Pass all parsed parameters to the agent:
Task(cms-cultivator:performance-specialist:performance-specialist,
prompt="Run performance audit focused on Core Web Vitals with:
- Depth mode: {depth}
- Scope: {scope}
- Format: {format}
- Target threshold: {target or 'none'}
- Focus area: {focus or 'complete analysis'}
- Files to analyze: {file_list}")
Analyze Core Web Vitals:
Optimize database performance:
Analyze asset performance:
Review caching strategy:
Platform-specific analysis:
Generate actionable reports:
What it measures: Time until the largest content element (image, text block) renders.
Common issues:
Optimizations:
What it measures: Responsiveness to user interactions throughout page life.
Common issues:
Optimizations:
What it measures: Visual stability - unexpected layout shifts during loading.
Common issues:
Optimizations:
What gets checked:
CMS-specific:
Images:
CSS:
JavaScript:
Fonts:
Browser Caching:
Application Caching:
CDN:
# Performance Audit Report
**Performance Score**: [0-100]
**Core Web Vitals**:
- LCP: [X]s ([Pass/Needs Improvement/Poor])
- INP: [X]ms ([Pass/Needs Improvement/Poor])
- CLS: [X] ([Pass/Needs Improvement/Poor])
## Critical Issues (High Impact)
[Issues severely impacting performance - fix immediately]
## High Priority Optimizations
[Significant improvements - address soon]
## Medium Priority Optimizations
[Moderate impact - plan for future]
## Performance Budget
[Recommended targets for page weight, requests, Core Web Vitals]
## Priority Actions
[Ordered list with effort estimates and expected impact]
When using focused checks (/audit-perf queries, /audit-perf assets, etc.), the performance specialist provides detailed analysis for that specific area only.
Focused report on LCP, INP, and CLS with specific optimizations for each metric.
Comprehensive Lighthouse audit with all metrics, opportunities, and diagnostics.
Executive-friendly report with business impact (conversion rates, revenue), competitor comparison, ROI analysis, and phased remediation roadmap.
Cache System:
// Proper cache configuration
$build['#cache'] = [
'tags' => ['node:' . $node->id()],
'contexts' => ['user.roles', 'url.query_args'],
'max-age' => 3600,
];
Query Optimization:
// Efficient EntityQuery
$query = \Drupal::entityQuery('node')
->condition('type', 'article')
->range(0, 10)
->sort('created', 'DESC');
Lazy Builders (for expensive operations):
$build['expensive'] = [
'#lazy_builder' => ['my_module.lazy_builder:build', [$id]],
'#create_placeholder' => TRUE,
];
Common Drupal Issues:
Transient Caching:
$data = get_transient('my_expensive_data');
if (false === $data) {
$data = expensive_function();
set_transient('my_expensive_data', $data, HOUR_IN_SECONDS);
}
WP_Query Optimization:
$query = new WP_Query([
'post_type' => 'post',
'posts_per_page' => 10,
'no_found_rows' => true, // Skip pagination count
'update_post_term_cache' => false, // Skip if not needed
]);
Asset Loading (defer/async):
wp_enqueue_script(
'my-script',
get_template_directory_uri() . '/js/script.js',
['jquery'],
'1.0',
['strategy' => 'defer', 'in_footer' => true]
);
Common WordPress Issues:
posts_per_page => -1 (loads all)# Check code quality
ddev composer phpstan # Static analysis
ddev composer rector-check # Code modernization
# Check dependencies
ddev composer audit
ddev exec npm audit
# Install tools
ddev exec npm install --save-dev lighthouse @lhci/cli webpack-bundle-analyzer
# Run Lighthouse
ddev exec npx lighthouse [url] --output html --output-path ./report.html
# Run Lighthouse CI
ddev exec npx lhci autorun
# Analyze bundles
ddev exec npx webpack-bundle-analyzer
# Custom performance tests
ddev composer test-performance
Automated Tools:
Monitoring Tools:
Analysis Tools:
Testing Conditions:
The performance specialist recommends budgets based on industry standards:
| Metric | Budget | Impact |
|---|---|---|
| LCP | < 2.5s | Pass Core Web Vitals |
| INP | < 200ms | Pass Core Web Vitals |
| CLS | < 0.1 | Pass Core Web Vitals |
| Total JS | < 200KB | Faster page load |
| Total CSS | < 100KB | Reduced render blocking |
| Images | < 1MB | Faster LCP |
| Requests | < 50 | Reduced connection overhead |
Research shows:
/pr-create - PR creation includes performance checks/pr-review - PR reviews include performance analysis/audit-live-site - Comprehensive audits include performanceperformance-specialist - Core Web Vitals specialist with expertise in database optimization, caching strategies, and CMS-specific performance patterns for Drupal and WordPress.
Before (manual perf review):
With performance-specialist:
After audit completes, export findings as CSV:
/export-audit-csv [report-filename]
Generates Teamwork-compatible CSV for importing tasks into project management tools (also works with Jira, Monday, Linear).
npx claudepluginhub riteshgurung/cms-cultivator