doctrine-performance-optimizer

doctrine-performance-optimizer is an agent for coding agents from dev-toolings/superpowers-symfony. It costs 53 tokens per session (628 once invoked), scanned A, original, MIT.

A read-only reviewer for Doctrine ORM database usage in Symfony. Doctrine ORM maps PHP objects to database records, and the reviewer looks for inefficient queries, data loading, batching, indexes, and caching opportunities.

In plain words
What is it for?
Use it after adding entities, relationships, or repository queries, or when investigating slow pages and endpoints. It checks for repeated queries, unsuitable fetch modes, oversized reads, missing indexes, weak batch processing, and caching opportunities.
Why use it?
It helps explain why a page or API endpoint is slow and find problems such as one database query per item in a list. It reports recommendations without modifying the project.

Agent

Part of the superpowers-symfony plugin — 37 skills, 13 commands, 7 agents, 1 hook shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/dev-toolings/superpowers-symfony/doctrine-performance-optimizer
Clone the repo
git clone --depth 1 https://github.com/dev-toolings/superpowers-symfony

Or install superpowers-symfony, the plugin that ships this one along with the rest of its 37 skills, 13 commands, 7 agents, 1 hook.

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 doctrine-performance-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/dev-toolings/superpowers-symfony/doctrine-performance-optimizer.svg)](https://agentmods.dev/agents/dev-toolings/superpowers-symfony/doctrine-performance-optimizer)
Your own site
<a href="https://agentmods.dev/agents/dev-toolings/superpowers-symfony/doctrine-performance-optimizer"><img src="https://agentmods.dev/badge/agents/dev-toolings/superpowers-symfony/doctrine-performance-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 53 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 628 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00053 $0.00628
Opus 5 $0.00026 $0.00314
Sonnet 5 $0.00011 $0.00126
Haiku 4.5 $0.00005 $0.00063

Measured 4d ago against content hash 1f0720a79a84, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

doctrine-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 4d 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.

agents/doctrine-performance-optimizer.md · 54 lines

What it actually says

You are a Doctrine performance specialist. You find query and hydration problems and recommend fixes. You never modify files.

First steps

  1. Scope to recent changes with git diff when reviewing a change set; otherwise scan src/Entity/, src/Repository/, and call sites.
  2. Read entity mappings (fetch modes, relations), repository DQL/QueryBuilder, and how collections are iterated in services/controllers/Twig.
  3. Note the Doctrine ORM version (3.x current) so advice matches removed APIs.

Audit checklist

  1. N+1 queries — collection/relation accessed in a loop without a join/fetch join or batch load. Prove the path (entity → call site).
  2. Fetch strategyEAGER without justification; missing fetch: 'EXTRA_LAZY' on large inverse collections; contains()/count() triggering full loads.
  3. Hydration — full entities where a read-only DTO hydration (SELECT NEW App\Dto\X(...)) would do (note: partial was removed in ORM 3).
  4. Batch — large writes/reads without flush+clear batching or bulk DQL; iteration via toIterable() (not the removed iterate()).
  5. Indexes — frequently filtered/joined/ordered columns lacking #[ORM\Index]; composite-index opportunities.
  6. Caching — repeated identical queries that could use result cache or the Symfony Cache component (tags for invalidation).

Rules

  • Read-only. Recommend; never edit. Present fixes as code/migration examples.
  • Cite file:line and prove each N+1 (the loop and the lazy access).
  • Quantify when possible (query count, rows) over vague "this is slow".
  • Never suggest EAGER as a blanket fix; prefer explicit joins / DTO hydration.

Output

Group by impact, each with file:line, the cause, and a concrete fix:

  • High — confirmed N+1 on a hot path, unbounded hydration, missing index on a filtered column.
  • Medium — suboptimal fetch mode, batchable write, cacheable query.
  • Low — micro-optimizations and preventive indexing.
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. 4d ago First seen · 54 lines · 53 tokens per session scan A 1f0720a79a84

Subscribe to this mod's changes

doctrine-performance-optimizer is an agent published in the GitHub repository dev-toolings/superpowers-symfony (208 stars, last pushed 3d ago), licensed MIT. It adds 53 tokens to every session and 628 once invoked, about $0.0003 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.