No slash command · from archon-os
Systematic performance profiling and optimization across frontend (Core Web Vitals, code splitting, lazy loading), backend (N+1 queries, async), and database (EXPLAIN ANALYZE, indexing) layers. Measures first, then applies Pareto principle to fix the 20% of code causing 80% of slowness.
Ships in archon-os. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
AI-consumed reference. Optimized for Claude to read during execution. Human-readable explanation: see docs/architecture/HIERARCHICAL_PLANNING.md or docs/getting-started/ depending on topic.
Rule 0: Don't optimize what you haven't measured. Almost all "obvious" optimizations are wrong.
Performance is relative. Before optimizing:
If no target → ask the user. Don't optimize without a goal — you'll polish forever.
Use the appropriate profiler:
| Language | Profiler |
|---|---|
| Node.js | node --prof, clinic.js, 0x |
| Browser JS | Chrome DevTools Performance tab |
| Python | cProfile, py-spy, memory_profiler |
| Go | pprof (built-in) |
| Rust | cargo flamegraph, perf |
| CLI | hyperfine |
| HTTP | wrk, k6, vegeta |
Run the profiler under realistic load, not trivial input. Capture for 30–60s minimum — short captures miss long-tail events.
Identify the top 3 functions by:
Pareto check: Is there a clear 80/20?
For the bottleneck:
Common bottleneck classes + fixes:
| Bottleneck | Fix |
|---|---|
| O(n²) on large n | Change to O(n log n) or O(n) |
| Sync I/O in hot path | Async, batch, or remove the I/O |
| Allocations in loop | Pre-allocate, object pool, reuse |
| Redundant computation | Memoize, cache result |
| Lock contention | Lock-free structure, sharding, immutable data |
| Large object serialization | Streaming, lazy fields, columnar format |
| Database N+1 | Join, prefetch, dataloader pattern |
| Cold cache / page fault | Warm up, prefetch, locality |
One change at a time. Multiple simultaneous changes = unknown which one helped.
Measure the same workload after the change. Compute speedup. If < 10% improvement on the targeted bottleneck: wrong hypothesis — revert, try next.
Optimization can break correctness OR slow other paths. Run:
In PR or commit message:
map with a for loop "for speed" when the bottleneck is elsewhereIf profiling shows a flat distribution (no single bottleneck), OR if the target is 10× faster: individual optimizations won't close the gap. Options:
These are architectural calls. Use self-consistency for trade-off analysis, tree-of-thoughts for exploring design branches.
Once profiling (above) has named the bottleneck, apply the fix for its layer. Still one change at a time, re-measure each. Don't apply these blind — they're the fix menu, not a checklist to run through.
| Layer | Tools | Metrics to watch |
|---|---|---|
| Frontend | Lighthouse, DevTools Performance | FCP, LCP, TTI, CLS |
| Backend | APM, language profilers | Response time, throughput |
| Database | EXPLAIN ANALYZE, slow query log | Query time, index usage |
| Memory | Heap snapshots | Allocation rate, leaks |
Core Web Vitals targets: LCP < 2.5s · FID/INP < 100ms · CLS < 0.1.
Quick wins once the profile points here:
loading="lazy" on below-the-fold images; serve WebP/AVIF.lazy(() => import(...)) so first paint ships less JS.debounce/throttle high-frequency handlers (scroll, resize, input).useMemo/memoization for expensive re-computations; avoid re-render storms.preload critical fonts.| Issue | Fix |
|---|---|
| N+1 queries | Eager loading, batching, dataloader |
| Missing indexes | Add appropriate index (see Database) |
| Unbounded queries | Pagination, LIMIT |
| Sync blocking in hot path | Async / parallel processing |
| No caching of hot data | Cache with a measured TTL (see Caching) |
EXPLAIN ANALYZE the slow query. Seq Scan on a large table = bad; Index Scan = good. Match the index type to the access pattern:
| Query pattern | Index type |
|---|---|
| Exact match | B-tree |
| Range | B-tree |
| Full-text | GIN / GiST |
| JSON containment | GIN |
| Level | Typical TTL | Use case |
|---|---|---|
| Browser | Hours–Days | Static assets |
| CDN | Minutes–Hours | API responses |
| Application | Seconds–Minutes | Computed / hot data |
Invalidation strategy: time-based, event-based, or version-based. Remember the anti-pattern above — cache only when measured benefit > memory + invalidation cost.
| Leak cause | Fix |
|---|---|
| Uncleaned event listeners | Clean up in useEffect return / destroy |
| Retaining closures | Null out references when done |
| Ever-growing collections | WeakMap, or clear periodically |
| Dangling timers | clearInterval / clearTimeout |
## Performance Profile: [task / endpoint / function]
**Baseline:** p50=Xms, p95=Yms, p99=Zms, memory=N MB
**Target:** p95 < Wms (source: [SLO / user request])
**Gap:** Yms − Wms = Kms to close
**Bottleneck:** [function/query/operation] — X% of total time
**Root Cause:** [why it's slow]
**Optimization Applied:** [single change]
**After:** p50=X'ms, p95=Y'ms, p99=Z'ms
**Speedup:** [factor]
**Correctness:** [tests pass]
**Broader Impact:** [other metrics checked, no regressions]
skills/self-consistency/SKILL.md — for architectural decisionsskills/tree-of-thoughts/SKILL.md — explore optimization branchesrules/core/verification.md — measure before + after, not just aftercommands/check.md — /check perf uses this skillrules/core/simplicity-over-complexity.md — the winning optimization is usually "do less," not "do the same thing with a clever structure"What SKILL.md sets; muted values are Claude Code's defaults
slow, slow code, performance, performance bottleneck, profile, benchmark, optimize speed, latency, memory leak, cpu usage, bottleneck, pareto, flamegraph, p95, p99, SLO, core web vitals, N+1 query, code splitting, lazy loading
highThree short reads, in order
JavaScript, Python, Go, Rust, Node
npx claudepluginhub nguyenthienthanh/archon --plugin archon-os45 skills in this plugin
/agent-detectorCRITICAL: MUST run for EVERY message. Detects agent, complexity, AND model automatically. Without this, tasks route to wrong agents and use wrong models, degrading quality and wasting tokens./api-designerDesigns RESTful APIs with endpoint naming, versioning strategies (URL path, header-based), pagination (offset and cursor), error response schemas, and OpenAPI conventions. Use when the user asks about REST API design, creating endpoints, URL structure, API versioning, status codes, Swagger, or OpenAPI specs./bugfix-quickFast bug fixes with root cause investigation + TDD. Enforces 'no fix without root cause' discipline and verification protocol. Without this skill, fixes are applied at symptoms instead of sources, and bugs return./chain-of-verificationDraft → generate verification questions → answer independently via tools → revise. Catches hallucinated facts in reports and reviews. MANDATORY for Phase 4 security/test claims. Paper: Dhuliawala et al. 2023./code-mapReverse-dependency lookup — "I am about to change this file, what breaks?" Use when assessing the blast radius of an edit, finding every importer of a module (including the ones that never name it), or checking what the startup code-map digest was derived from. Not for finding text: grep is better at that./code-reviewer8-aspect evidence-based code review/audit (security, correctness, compatibility, architecture, error handling, test gaps, type safety, simplicity) built on Google eng-practices, OWASP Top 10:2025, CWE Top 25, SemVer. Every finding needs file:line + a concrete failure scenario. Use when the user asks to review/audit code, check a PR, review before merge, in TDD Phase 4, via /check review or /run review.Other plugins' skills for the same job