n98-magerun2-performance-review: Agent for Claude Code

.claude/agents/performance-optimizer.md

performance-optimizer is an agent for Claude Code from magendooro/n98-magerun2-performance-review. It costs 39 tokens per session (3,596 once invoked), scanned A, original, MIT.

An agent for finding and fixing slow or memory-heavy analyzers in the Performance Review module for Magento installations. It measures the existing behavior before optimizing it.

In plain words
What is it for?
Use it when an analyzer takes too long, uses excessive memory, or fails on a large Magento installation.
Why use it?
It helps locate performance bottlenecks without changing functionality unnecessarily, especially in large Magento projects.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter; mentions CLAUDE.md.

This is magendooro/n98-magerun2-performance-review's own configuration. It tells Claude Code how to work on n98-magerun2-performance-review itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything n98-magerun2-performance-review configures →

Reuse

Borrowing it

Nothing to install: this file belongs to magendooro/n98-magerun2-performance-review. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/magendooro/n98-magerun2-performance-review/main/.claude/agents/performance-optimizer.md
Clone the repo
git clone --depth 1 https://github.com/magendooro/n98-magerun2-performance-review

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for performance-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/magendooro/n98-magerun2-performance-review/performance-optimizer.svg)](https://agentmods.dev/agents/magendooro/n98-magerun2-performance-review/performance-optimizer)
Your own site
<a href="https://agentmods.dev/agents/magendooro/n98-magerun2-performance-review/performance-optimizer"><img src="https://agentmods.dev/badge/agents/magendooro/n98-magerun2-performance-review/performance-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,596 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00039 $0.03596
Opus 5 $0.00019 $0.01798
Sonnet 5 $0.00008 $0.00719
Haiku 4.5 $0.00004 $0.00360

Measured 8d ago against content hash 70ddbc007893, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

performance-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/performance-optimizer.md · 640 lines

How it starts

The opening of the file, as written. The whole thing — 640 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Performance Optimizer Agent

You are a specialized agent for optimizing analyzer performance in the Performance Review module.

Your Mission

Identify performance bottlenecks in analyzers and implement optimizations while maintaining functionality. Make analyzers fast and memory-efficient for large Magento installations.

When To Use This Agent

Use when:

  • Analyzer is slow (takes > 5 seconds)
  • Memory exhausted errors
  • High memory usage reported
  • User complains about performance
  • Large Magento installations experience issues

Do NOT use when:

  • Analyzer has bugs (use analyzer-debugger first)
  • Need to add features (modify directly)
  • Performance is acceptable (premature optimization)

Your Workflow

Phase 1: Profile and Measure

Before any optimization, establish baseline:

  1. Add profiling code:
public function analyze(Collection $results): void
{
    $startTime = microtime(true);
    $startMemory = memory_get_usage(true);

    try {
        // Existing analyzer code
    } catch (\Exception $e) {
        // Error handling
    }

    $endTime = microtime(true);
    $endMemory = memory_get_usage(true);

    $duration = round($endTime - $startTime, 2);
    $memoryUsed = round(($endMemory - $startMemory) / 1024 / 1024, 2);

    // Temporary debug issue
    $results->createIssue()
        ->setPriority('low')
        ->setCategory('Performance')
        ->setIssue("Analyzer performance: {$duration}s, {$memoryUsed}MB")
        ->add();
}
  1. Run and record baseline:
n98-magerun2.phar performance:review --category=custom

Record:

  • Execution time: [X] seconds
  • Memory usage: [Y] MB
  • Problematic scenario: [Description]

Phase 2: Identify Bottlenecks

Common performance issues to look for:

Issue 1: Loading Large Collections

Find:

grep -n "create()" AnalyzerFile.php
grep -n "getCollection()" AnalyzerFile.php

Anti-pattern:

// ❌ BAD: Loads ALL products into memory
$collection = $this->productCollectionFactory->create();
$count = count($collection);

foreach ($collection as $product) {
    // Process each product
}

Read the full file on GitHub · 640 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 640 lines · 39 tokens per session scan A 70ddbc007893

Subscribe to this mod's changes

performance-optimizer is an agent published in the GitHub repository magendooro/n98-magerun2-performance-review (22 stars, last pushed 9mo ago), licensed MIT. It adds 39 tokens to every session and 3,596 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.