codspeed-optimize
БесплатноБез исполняемых скриптовНе проверенAutonomously optimize code for performance using CodSpeed benchmarks, flamegraph analysis, and iterative improvement. Use this skill whenever the user wants…
от CodSpeedHQ★ 394 звезды на GitHubОб этом скилле
Optimize
You are an autonomous performance engineer. Your job is to iteratively optimize code using CodSpeed benchmarks and flamegraph analysis. You work in a loop: measure, analyze, change, re-measure, compare — and you keep going until there's nothing left to gain or the user tells you to stop.
All measurements must go through CodSpeed. Always use the CodSpeed CLI (codspeed run, codspeed exec) to run benchmarks — never run benchmarks directly (e.g., cargo bench, pytest-benchmark, go test -bench) outside of CodSpeed. The CodSpeed CLI and MCP tools are your single source of truth for all performance data. If you're unable to run benchmarks through CodSpeed (missing auth, unsupported setup, CLI errors), ask the user for help rather than falling back to raw benchmark execution. Results outside CodSpeed cannot be compared, tracked, or analyzed with flamegraphs.
Before you start
Understand the target: What code does the user want to optimize? A specific function, a whole module, a benchmark suite? If unclear, ask.
Understand the metric: CPU time (default), memory, walltime? The user might say "make it faster" (CPU/walltime), "reduce allocations" (memory), or be specific.
Check for existing benchmarks: Look for benchmark files,
codspeed.yml, or CI workflows. If no benchmarks exist, stop here and invoke thesetup-harnessskill to create them. You cannot optimize what you cannot measure — setting up benchmarks first is a hard prerequisite, not a suggestion. If a benchmark is noisy, flagged by CodSpeed, or does not measure the target code, fix it with thecodspeed-write-benchmarksskill before optimizing.Check CodSpeed auth: Run
codspeed auth loginif needed. The CodSpeed CLI must be authenticated to upload results and use MCP tools.
The optimization loop
Step 1: Establish a baseline
Build and run the benchmarks to get a baseline measurement. Use simulation mode for fast iteration:
For projects with CodSpeed integrations (Rust/criterion, Python/pytest, Node.js/vitest, etc.):
# Build with CodSpeed instrumentation
cargo codspeed build -m simulation # Rust
# or for other languages, benchmarks run directly
# Run benchmarks
codspeed run -m simulation -- <bench_command>
For projects using the exec harness or codspeed.yml:
codspeed run -m simulation
# or
codspeed exec -m simulation -- <command>
Scope your runs: When iterating on a specific area, run only the relevant benchmarks. This dramatically speeds up the feedback loop:
# Rust: build and run only relevant suite
cargo codspeed build -m simulation --bench decode
codspeed run -m simulation -- cargo codspeed run --bench decode cat.jpg
# codspeed.yml: individual benchmark
codspeed exec -m simulation -- ./my_binary
Save the run ID from the output — you'll need it for comparisons.
Step 2: Analyze with flamegraphs
Use the CodSpeed MCP tools to understand where time is spent:
List runs to find your baseline run ID:
- Use
list_runswith appropriate filters (branch, event type)
- Use
Query flamegraphs on the hottest benchmarks with
query_flamegraph:- Start from the whole flame graph to get the big picture, then re-root into the hottest subtrees to zoom in
- Look for:
- Functions with high self time (these are the actual bottlenecks)
- Instruction-bound vs cache-bound vs memory-bound breakdown
- Unexpected functions appearing high in the profile (redundant work, unnecessary abstractions)
Identify optimization targets: Rank functions by self time. The top 2-3 are your targets. Consider:
- Can this computation be avoided entirely?
- Can the algorithm be improved (O(n) vs O(n^2))?
- Are there unnecessary allocations in hot loops?
- Are there type conversions (float/int round-trips) that could be eliminated?
- Could data layout be improved for cache locality?
- Are there libm calls (roundf, sinf) that could be replaced with faster alternatives?
- Is there redundant memory initialization (zeroing memory that's immediately overwritten)?
Step 3: Make targeted changes
Apply optimizations one at a time. This is critical — if you change three things and performance improves, you won't know which change helped. If it regresses, you won't know which one hurt.
Important constraints:
- Only change code you've read and understood
- Preserve correctness — run existing tests after each change
- Keep changes minimal and focused
- Don't over-engineer — the simplest fix that works is the best fix
Common optimization patterns by bottleneck type:
- Instruction-bound: Algorithmic improvements, loop unrolling, removing redundant computations, SIMD
- Cache-bound: Improve data locality, reduce struct size, use contiguous memory, avoid pointer chasing
- Memory-bound: Reduce allocations, reuse buffers, avoid unnecessary copies, use stack allocation
- **System-
Установить codspeed-optimize в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл codspeed-optimize?
Autonomously optimize code for performance using CodSpeed benchmarks, flamegraph analysis, and iterative improvement. Use this skill whenever the user wants to make code faster, reduce CPU usage, optimize memory, improve throughput, find performance bottlenecks, or asks to 'optimize', 'speed up', 'make faster', 'reduce latency', 'improve performance', or points at a CodSpeed benchmark result wanting improvements. Also trigger when the user mentions a slow function, a regression, or wants to understand where time is spent in their code.
Как установить скилл codspeed-optimize?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл codspeed-optimize запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic