agentleFS
Alexander-TyagunovAlexander-Tyagunov/magician/skills/accelerate/SKILL.md

accelerate

Skill14 starsChanged 48 days agoMITView on GitHub

Performance profiling and optimization, baseline first. Use when something is slow or must hit a latency/throughput target.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ask both questions in one message:

    line 26
  2. Distinctive:

    Use the Lighthouse CLI if it is already installed (or the project's own Lighthouse script):

    line 49
  3. Distinctive:

    Use the profiler to identify the actual bottleneck.

    line 74
  4. Distinctive:

    Run the same benchmark as Phase 2.

    line 84
  5. Distinctive:

    Ask once, in one sentence, after the Phase 5 report.

    line 96

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/accelerate — Performance Profiling

Bundled command: if kg is not found, run it as ${CLAUDE_PLUGIN_ROOT}/tools/kg and give subagents that full path. If that is missing too (Claude chat ships no plugin tools), skip the kg steps and search the code directly.

Profile and optimize performance systematically. No optimization without measurement.

Scale /effort to the optimization scope: low for a single hot path, high for cross-cutting work. (Haiku and the 4.5 generation have no effort axis at all — don't suggest a level there.)

Scope the work with the knowledge graph when the repo is indexed: kg query "<slow area>" to locate the hot code and kg blast/kg neighbors to see what it touches — so you profile and change the right thing, in fewer tokens than grepping.

<HARD-GATE> Establish a baseline measurement BEFORE making any changes. Optimization without a baseline is guesswork. </HARD-GATE>

Process

Phase 1: Define the Target

Ask both questions in one message:

"Before I start profiling, two quick questions:

  1. What specifically is slow? (page load, API response, query, computation — be as specific as possible)
  2. What's the acceptable performance target? (e.g., 'under 200ms', 'p99 < 500ms')"

End your turn. Wait for both answers before proceeding to Phase 2. Do not run any benchmarks until you have a defined target.

Autonomy — approve the plan, then run

After the Phase 1 gate (the two target answers — what's slow, and the acceptable target), run Phases 2–5 autonomously: reading, searching, kg query/blast, read-only git, and every profiling read, baseline, and benchmark go ahead without a confirmation question from you. Claude Code still shows its own permission prompt for commands this skill does not pre-approve (benchmarks, profilers) unless the session is in auto mode or the user already allowed them. After baseline + profiling, show the proposed Phase 4 targeted fix ONCE for approval; the bounded evaluator-optimizer loop then iterates without per-round prompts.

Re-gate only on real side effects — applying the fix (file edits) and any git add/commit/push. See lore/autonomy.md.

Phase 2: Baseline

Measure current performance using the appropriate tool:

API:

wrk -t4 -c100 -d30s http://localhost:8080/api/endpoint
# or: hey -n 1000 -c 50 http://localhost:8080/api/endpoint

Web (browser): Use the Lighthouse CLI if it is already installed (or the project's own Lighthouse script):

lighthouse http://localhost:3000 --output json --output-path baseline.json

Python:

import cProfile, pstats
profiler = cProfile.Profile()
profiler.enable()
# ... run the slow code ...
profiler.disable()
stats = pstats.Stats(profiler).sort_stats('cumulative')
stats.print_stats(20)

Go:

import _ "net/http/pprof"
// Then: go tool pprof http://localhost:6060/debug/pprof/profile

Record baseline numbers.

Phase 3: Profile to Find Bottleneck

Use the profiler to identify the actual bottleneck. The bottleneck is where the most time is spent — not the most obvious place.

Phase 4: Targeted Fix

Fix ONLY the identified bottleneck. Common fixes:

  • DB: add index, use JOIN instead of N+1, batch queries
  • API: cache response, reduce payload size, move work async
  • Frontend: code splitting, lazy loading, image optimization
  • Computation: use better algorithm, vectorize, parallelize

Phase 5: Measure Again

Run the same benchmark as Phase 2. Compare: baseline vs. optimized.

This is a bounded evaluator-optimizer loop: if the target isn't met, return to Phase 3 and attack the next bottleneck — but stop after a few rounds, when a round's marginal gain is negligible, or when the /effort/token budget is exhausted, then report the best result with the target marked met/not-met. Never loop indefinitely. For long benchmarks or load tests, start them with the Bash tool's background option and read the output when Claude Code reports the command finished, instead of blocking the turn.

Circulate the result (optional)

For a result worth circulating, you can publish the baseline→optimized report as a Claude Code Artifact (a live page on claude.ai, team-co-editable on Team/Enterprise) — offer it, don't create it unprompted. Publishing to a public link (anyone with the URL can view it) is an outward sharing action: confirm it, keep it account-private by default, and never expose proprietary/internal system detail or secrets to a public link.

Dashboard offer. Offer a Dashboard artifact (a page that re-runs its queries) only when both conditions hold:

  • the session has the Artifact tool;
  • the metrics come from a warehouse or a query source (BigQuery, Snowflake, Redshift, ClickHouse, a metrics database), not from a one-off local benchmark.

Ask once, in one sentence, after the Phase 5 report. Do not build it without a yes. Keep it account-private, and never put credentials in the page.

Obstacles

If this skill runs as a dispatched unit and hits something that blocks or degrades the work, do not wait for a human who is not there and do not silently ship a degraded result — return the Obstacles block from lore/obstacles.md (fields: STATUS, OBSTACLE, BLOCKER, SEVERITY, WORKAROUND, RECURRENCE, SCOPE, NEXT) to the caller alongside whatever you completed; interactively, say the same in prose.

Completion Signal

"Accelerate complete. Baseline: <N>. Optimized: <N>. Improvement: <X>%. Target <met/not met>."

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.