WeReply: Command for Claude Code

.claude/commands/optimize.md

optimize is a command for Claude Code from cacr92/WeReply. It costs 0 tokens per session (861 once invoked), scanned A, original, MIT.

A command for reviewing application performance across a Rust backend, React frontend, and SQLite database. It uses profiling, benchmarking, query-plan checks, and a list of common bottlenecks.

In plain words
What is it for?
Use it to investigate slow calculations, large-list rendering, database queries, cloning, caching, parallel processing, and N+1 queries. It also organizes findings by priority.
Why use it?
It helps locate slow code, unnecessary work, rendering delays, and inefficient database queries before suggesting what to improve.

Command for Claude Code

Written for Claude Code: installed under .claude/.

This is cacr92/WeReply's own configuration. It tells Claude Code how to work on WeReply itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything WeReply configures →

Reuse

Borrowing it

Nothing to install: this file belongs to cacr92/WeReply. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cacr92/WeReply/main/.claude/commands/optimize.md
Clone the repo
git clone --depth 1 https://github.com/cacr92/WeReply

Made for: Claude Code.

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 optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/cacr92/wereply/optimize/github.svg)](https://agentmods.dev/commands/cacr92/wereply/optimize)
Your own site
<a href="https://agentmods.dev/commands/cacr92/wereply/optimize"><img src="https://agentmods.dev/badge/commands/cacr92/wereply/optimize/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for optimize

Your own site · 80×15
<a href="https://agentmods.dev/commands/cacr92/wereply/optimize"><img src="https://agentmods.dev/badge/commands/cacr92/wereply/optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 861 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.00861
Opus 5.5 $0.00000 $0.00344
Sonnet 5.5 $0.00000 $0.00172
Haiku 4.5 $0.00000 $0.00086

Measured 1mo ago against content hash 2b4e3c484b54, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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.

.claude/commands/optimize.md · 122 lines

What it actually says

/optimize - 性能优化分析

用途

识别性能瓶颈并提供具体的优化建议。

分析步骤

1. Rust 后端性能分析

识别热点代码
# 使用 cargo-flamegraph 生成火焰图
cargo flamegraph --bin cacrfeedformula

# 使用 criterion 进行基准测试
cargo bench
检查点
  • 是否有不必要的克隆?
  • 是否可以使用并行计算(Rayon)?
  • 是否可以添加缓存(Moka)?
  • 数据库查询是否优化?
  • 是否有 N+1 查询问题?

2. React 前端性能分析

使用 React DevTools Profiler
// 识别重渲染问题
// 检查是否需要:
// - React.memo
// - useCallback
// - useMemo
检查点
  • 组件是否过度渲染?
  • 是否需要虚拟滚动(大列表)?
  • 是否需要代码分割(lazy loading)?
  • 是否有内存泄漏?

3. 数据库性能分析

SQLite 优化
-- 检查查询计划
EXPLAIN QUERY PLAN SELECT ...;

-- 检查索引使用
PRAGMA index_list('table_name');

-- 检查表统计信息
ANALYZE;
检查点
  • 是否有缺失的索引?
  • 是否有未使用的索引?
  • 查询是否可以优化?
  • 是否需要批量操作?

优化建议模板

## 性能优化建议

### 高优先级(立即修复)
1. **配方优化计算耗时过长**
   - 问题:单次优化耗时 15 秒
   - 原因:未使用缓存,重复计算
   - 建议:添加 Moka 缓存,缓存原料数据
   - 预期改进:耗时减少到 3 秒

2. **原料列表渲染卡顿**
   - 问题:1000+ 原料渲染缓慢
   - 原因:��使用虚拟滚动
   - 建议:使用 react-window
   - 预期改进:渲染时间从 2 秒降到 200ms

### 中优先级(计划修复)
1. **数据库查询慢**
   - 问题:配方列表查询耗时 500ms
   - 原因:缺少索引
   - 建议:添加 species_code 索引
   - 预期改进:查询时间降到 50ms

### 低优先级(可选优化)
1. **启动时间优化**
   - 问题:应用启动耗时 3 秒
   - 原因:启动时加载所有数据
   - 建议:延迟加载非关键数据
   - 预期改进:启动时间降到 1.5 秒

性能基准

目标指标

  • 应用启动时间: < 2 秒
  • 配方优化计算: < 5 秒
  • 数据库查询: < 100ms
  • UI 响应时间: < 100ms
  • 大列表渲染: < 500ms

测量工具

  • Rust: cargo-flamegraph, criterion
  • React: React DevTools Profiler
  • 数据库: EXPLAIN QUERY PLAN
  • 整体: Chrome DevTools Performance

何时使用

  • 发现性能问题时
  • 定期性能审查
  • 重大功能上线前
  • 用户反馈卡顿时

相关 Skills

  • rust-optimization
  • react-typescript-development
  • sqlite-optimization
  • performance-standards (规范文件)
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. 1mo ago First seen · 122 lines · 0 tokens per session scan A 2b4e3c484b54

Subscribe to this mod's changes

optimize is a command published in the GitHub repository cacr92/WeReply (9 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 861 tokens. 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-31.