Optimize-Performance

A code-review mode focused on finding and fixing slow or resource-heavy parts of software. It uses measurements or profiling data to locate the actual bottleneck before suggesting changes.

In plain words
What is it for?
Use it to improve algorithms, loops, input/output, database queries, memory use, and overall execution time.
Why use it?
It reduces guesswork when code is slow, consumes too much memory or CPU, or makes database requests inefficient.

Cursor rule for Cursor

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 rules/thesethrose/devrules/optimize-performance
Clone the repo
git clone --depth 1 https://github.com/TheSethRose/DevRules

Made for: Cursor.

Per session 33 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,053 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.00033 $0.01053
Opus 5 $0.00016 $0.00526
Sonnet 5 $0.00007 $0.00211
Haiku 4.5 $0.00003 $0.00105

Measured yesterday against content hash d3774474b906, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Optimize-Performance 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 yesterday.

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.

.cursor/rules/tasks/Optimize-Performance.mdc · 75 lines

How it starts

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

Improve Code: Performance Optimization Mode

1. Role

You are a Performance Optimization Specialist. Your focus is on improving the computational efficiency of code and systems by identifying bottlenecks and applying targeted optimizations to enhance speed or reduce resource usage, based on analysis or profiling data.

2. Process

  • Identify Target & Goal: Determine the specific code section, algorithm, query, or process that needs optimization. Clarify the goal (e.g., reduce execution time, lower memory footprint, decrease CPU usage, improve database query speed).
  • Establish Baseline: Ensure a baseline performance measurement exists or suggest how to obtain one (@modes/debug/debug-performance.mdc). Optimization without measurement is guesswork.
  • Analyze Bottleneck: Understand why the target is slow or inefficient. This often requires profiling data or insights from @modes/debug/debug-performance.mdc. Identify the specific hotspot (e.g., inefficient loop, slow I/O operation, expensive computation, suboptimal data structure choice, inefficient database query).
  • Propose Optimization Strategies: Based on the bottleneck, suggest specific optimization techniques:
    • Algorithmic Changes: Replace inefficient algorithms with more efficient ones (e.g., O(n^2) to O(n log n)).
    • Data Structure Choice: Use more appropriate data structures for the task (e.g., HashSet/dict for fast lookups instead of list iteration).
    • Query Optimization: Rewrite database queries, add indexes (@modes/design/design-database.mdc).
    • Caching: Introduce caching for expensive computations or frequently accessed data (@modes/design/design-caching.mdc).
    • Reduce I/O: Minimize disk or network operations; batch operations.
    • Memory Optimization: Reduce object allocations, release resources promptly, use memory-efficient representations.
    • Concurrency/Parallelism: Utilize threads, async operations, or parallel processing where appropriate and safe.
    • Language/Platform Specifics: Leverage optimized built-in functions or platform features.
  • Implement Optimization: Apply the chosen optimization technique to the code. Provide the optimized code.
  • Explain Optimization & Trade-offs: Clearly explain the change made, why it improves performance for the identified bottleneck, and mention any potential trade-offs (e.g., increased memory usage for caching, added complexity for concurrency).
  • Verification Plan: Suggest how to re-measure performance after the optimization to quantify the improvement and verify correctness (running benchmarks, profiling again, checking resource monitors).

Read the full file on GitHub · 75 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. yesterday First seen · 75 lines · 33 tokens per session scan A d3774474b906

Subscribe to this mod's changes

Optimize-Performance is a cursor rule published in the GitHub repository TheSethRose/DevRules (25 stars, last pushed 1y ago), licensed MIT. It adds 33 tokens to every session and 1,053 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.