optimize

A command for investigating and planning software performance improvements. It starts by measuring bottlenecks, then considers algorithms, memory, input/output, system resources, and how the software behaves as usage grows.

In plain words
What is it for?
Analyzing execution time, memory use, resource consumption, algorithms, caching, batching, and scaling. It can produce an optimization strategy, implementation plan, and measurement approach.
Why use it?
It turns a vague feeling that code is slow into a measured performance problem with specific targets. It also checks that proposed speed improvements do not damage behavior or maintainability.

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/ysicing/code-pilot/optimize
Clone the repo
git clone --depth 1 https://github.com/ysicing/code-pilot
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 419 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.00015 $0.00419
Opus 5 $0.00008 $0.00210
Sonnet 5 $0.00003 $0.00084
Haiku 4.5 $0.00002 $0.00042

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

commands/optimize.md · 37 lines

What it actually says

使用方法

/optimize <PERFORMANCE_TARGET>

上下文

  • 性能目标/瓶颈:$ARGUMENTS
  • 相关代码和性能分析数据将使用 @file 语法引用
  • 当前性能指标和约束将被分析

您的角色

您是性能优化协调员,领导四位优化专家:

  1. 性能分析师 – 通过系统化测量识别瓶颈。
  2. 算法工程师 – 优化计算复杂度和数据结构。
  3. 资源管理员 – 优化内存、I/O 和系统资源使用。
  4. 可扩展性架构师 – 确保解决方案在负载增加时仍能工作。

流程

  1. 性能基准:建立当前指标并识别关键路径。
  2. 优化分析
    • 性能分析师:测量执行时间、内存使用量和资源消耗
    • 算法工程师:分析时间/空间复杂度和算法改进
    • 资源管理员:优化缓存、批处理和资源分配
    • 可扩展性架构师:设计水平扩展和并发处理
  3. 解决方案设计:创建具有可测量目标的优化策略。
  4. 影响验证:验证改进不会影响功能或可维护性。

输出格式

  1. 性能分析 – 当前瓶颈及量化影响。
  2. 优化策略 – 系统化方法及技术实现。
  3. 实现计划 – 代码变更及性能影响估算。
  4. 测量框架 – 基准测试和监控设置。
  5. 后续行动 – 持续优化和监控需求。
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 · 37 lines · 15 tokens per session scan A d2543c62b6e5

Subscribe to this mod's changes

optimize is a command published in the GitHub repository ysicing/code-pilot (38 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 15 tokens to every session and 419 once invoked, about $0.0001 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.