optimize-performance

A performance-optimization command that measures a system, identifies a bottleneck, applies a change, and compares the result with a baseline.

In plain words
What is it for?
Use it to investigate measurable performance goals, inspect the related code, apply optimizations, and write a report with before-and-after results.
Why use it?
It avoids making performance changes without evidence of the original problem or proof that the change helped. It also considers trade-offs such as cost and data consistency.

Command 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 commands/zenobia0000/cursor-agentic-coding-template/optimize-performance
Clone the repo
git clone --depth 1 https://github.com/Zenobia0000/cursor-agentic-coding-template

Made for: Cursor.

Per session 17 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,239 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00017 $0.01239
Opus 5 $0.00009 $0.00620
Sonnet 5 $0.00003 $0.00248
Haiku 4.5 $0.00002 $0.00124

Measured yesterday against content hash 127657656c83, 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.

Origin

This is a copy

100% identical to optimize-performance — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/commands/optimize-performance.md · 72 lines

How it starts

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

⚡ OPTIMIZE MODE (v3)

像索隆的三刀流一樣,基於數據,精準、快速地斬斷效能瓶頸。

1. PLAN 🎯 (規劃)

Objective

遵循「測量-識別-優化-驗證」的循環,系統性地解決效能問題,並寫入一份包含前後對比數據的效能報告,以證明優化的有效性。

Guiding Rules

在執行此指令時,AI Agent 必須遵循以下規則:

  • 主要規則: .cursor/rules/principles/global.mdc
  • 架構原則: .cursor/rules/backend/overview.mdc.cursor/rules/frontend/overview.mdc
  • 測試要求: .cursor/rules/testing/overview.mdc (確保優化不破壞功能)
  • 核心隔離: .cursor/rules/isolation_rules/main.mdc

Prerequisites Check

在開始優化之前,請確保:

  • 目標已量化: 有一個清晰、可量化的效能目標 (e.g., "將 P95 延遲從 800ms 降至 300ms 以下")。
  • 基準已存在: 已有一份可靠的效能基準測試報告,可能儲存在 memory-bank/current/ 中。
  • Failure Action: 如果目標模糊或沒有基準數據,AI 必須拒絕優化,並建議:「我們需要先建立效能基準。我應該先編寫一個負載測試腳本來測量當前的 API 延遲嗎?」

2. DO 実行 (執行)

Core Process

遵循一個嚴格的、數據驅動的優化循環:

Step 0: 健康檢查 (Health Check)

  • 檢查目標和基準: 驗證效能目標是否具體、可衡量,且基準報告是否可信。
  • 批判性思考: 優化是權衡的藝術。AI 應思考目標是否現實,並思考潛在的副作用,例如:「追求極致的低延遲可能會增加伺服器成本或降低數據一致性。我們應該在哪個指標上做權衡?」

Step 1: 記憶體互動 - 讀取 (Memory Interaction - Read)

  • 讀取目標:memory-bank/current/tasks.md 讀取效能優化目標。
  • 讀取基準報告:memory-bank/current/perf-report-[baseline-date].md 讀取詳細的基準數據。
  • 讀取相關程式碼: 根據基準報告中指出的瓶頸,讀取相關的產品程式碼。

Step 2: 假設與實施 (Hypothesize & Implement)

  • 提出假設: 針對瓶頸,提出一個具體的優化假設。
  • 實施優化: 修改產品程式碼以實現該優化。

Step 3: 驗證與測量 (Verify & Measure)

  • 功能驗證: 運行所有單元測試和整合測試,確保優化沒有破壞任何現有功能。
  • 效能驗證: 在與基準測試完全相同的環境下,重新運行效能測試。

Step 4: 記憶體互動 - 寫入 (Memory Interaction - Write)

  • 寫入效能報告: 創建一份新的效能報告 memory-bank/current/perf-report-[optimization-date].md。此報告必須包含優化目標、措施、以及優化前後的數據對比表

3. CHECK ✓ (檢查)

Verification Checklist

  • 目標是否達成: 優化後的指標是否達到了預設的目標?
  • 功能無迴歸: 所有測試是否都已通過?
  • 報告已生成: 是否已在 memory-bank/current 中創建了包含前後對比數據的效能報告?

4. ACT 改善 (行動)

Finalization

  • 向用戶確認權衡: 在提交一個涉及重要權衡的優化之前,AI 必須向用戶確認。
  • 提交程式碼: 在用戶確認後,將優化程式碼和新的效能報告提交到版本控制系統。

Next Steps

效能優化是一個持續的過程。

  • 👉 Primary Next Step: 如果仍有未達標的效能指標,可以執行 /task-next 來建議下一個要優化的點。
  • 💡 Alternative: 將新的效能測試腳本整合到 CI/CD 流程中,建立效能迴歸監控。

Read the full file on GitHub · 72 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 · 72 lines · 17 tokens per session scan A 127657656c83

Subscribe to this mod's changes

optimize-performance is a command published in the GitHub repository Zenobia0000/cursor-agentic-coding-template (5 stars, last pushed 4mo ago), licensed MIT. It adds 17 tokens to every session and 1,239 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to optimize-performance, differing in 0 lines, and is treated as a copy.