optimize

A performance-analysis procedure that looks for ways to make code, database queries, or larger systems use less time, memory, or downloaded data.

In plain words
What is it for?
Use it to examine a function, module, database query, frontend bundle, or system architecture and receive suggested performance improvements.
Why use it?
It helps locate slow operations, inefficient queries, oversized frontend bundles, risky algorithms, and possible memory leaks before changing them.

Command

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 commands/florianbruniaux/claude-code-plugins/optimize
Clone the repo
git clone --depth 1 https://github.com/FlorianBruniaux/claude-code-plugins
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,445 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00015 $0.01445
Opus 5 $0.00008 $0.00723
Sonnet 5 $0.00003 $0.00289
Haiku 4.5 $0.00002 $0.00145

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

Security

Grade A, and why

optimize scanned grade A with 1 finding 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 2d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

grep -rn "readFileSync\|writeFileSync\|execSync" --include="*.{ts,js}" . | head -10
plugins/code-quality/commands/optimize.md · 224 lines

How it starts

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

Performance Optimizer

Analyze and suggest performance improvements for code, queries, or systems.

Purpose

Identify optimization opportunities:

  • Runtime performance bottlenecks
  • Memory usage issues
  • Database query inefficiencies
  • Bundle size problems
  • Algorithm complexity

Instructions

Step 1: Scope Identification

Determine optimization target:

  • Function: Single function performance
  • Module: Related functions/classes
  • Query: Database query optimization
  • Bundle: Frontend bundle analysis
  • System: Architecture-level optimization

Step 2: Performance Analysis

Runtime Analysis
# Find potentially slow patterns
grep -rn "forEach\|\.map\|\.filter\|\.reduce" --include="*.{ts,js}" . | head -20

# Find nested loops (O(n²) potential)
grep -rn "for.*for\|\.forEach.*\.forEach\|\.map.*\.map" --include="*.{ts,js}" . | head -10

# Find sync operations that could be async
grep -rn "readFileSync\|writeFileSync\|execSync" --include="*.{ts,js}" . | head -10
Memory Analysis
# Large array operations
grep -rn "new Array\|Array\.from\|\.concat\|spread" --include="*.{ts,js}" . | head -10

# Potential memory leaks (event listeners, intervals)
grep -rn "addEventListener\|setInterval\|setTimeout" --include="*.{ts,js}" . | head -10
Database Query Analysis
# N+1 query patterns
grep -rn "await.*find\|await.*query" --include="*.{ts,js}" . | head -15

# Missing indexes hints
grep -rn "WHERE\|ORDER BY\|GROUP BY" --include="*.{ts,js,sql}" . | head -15
Bundle Analysis
# Check bundle size (if applicable)
[ -f "package.json" ] && npm run build 2>/dev/null && ls -lh dist/*.js 2>/dev/null

# Large dependencies
[ -f "package.json" ] && cat package.json | jq '.dependencies | keys[]' | head -20

Step 3: Prioritization

Rank findings by:

  1. Impact: How much will this improve performance?
  2. Effort: How hard is the fix?
  3. Risk: What could break?

Output Format


Read the full file on GitHub · 224 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. 2d ago First seen · 224 lines · 15 tokens per session scan A 784e2bedc265

Subscribe to this mod's changes

optimize is a command published in the GitHub repository FlorianBruniaux/claude-code-plugins (40 stars, last pushed 2mo ago), licensed MIT. It adds 15 tokens to every session and 1,445 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.