Perf

From zeuikli/claude-code-workspace · View interactive version

Perf is an AI agent skill from the GitHub repository zeuikli/claude-code-workspace. 效能分析與最佳化:量測 baseline、定位瓶頸、優化最高影響項、驗證改善效果。適用於應用程式慢、API 超時、前端 Core Web Vitals 問題。

How to use this skill

Skill file

Perf — 效能工程

觸發條件

優化流程(4 步驟)

  1. Measure — 先量測,有 baseline 才能比較(不要憑感覺優化)
  2. Identify — 找到最大瓶頸(用 80/20 原則:20% 的程式碼造成 80% 的效能問題)
  3. Optimize — 優先修復影響最大的問題,一次一個
  4. Verify — 用相同工具重新量測,確認改善數字

Profiling 指令

# Node.js
node --prof app.js
node --prof-process isolate-*.log > profile.txt

# Python
python -m cProfile -o output.prof script.py
python -m pstats output.prof

# Go
go tool pprof http://localhost:6060/debug/pprof/profile

# CLI 效能比較(用 hyperfine,需安裝)
hyperfine 'command_a' 'command_b' --warmup 3

常見瓶頸分類

資料庫

記憶體

CPU

網路

效能預算(參考值)

| 指標 | 目標 | 說明 |

|------|------|------|

| API 回應 | <200ms (P95) | 排除網路 RTT |

| 頁面載入(4G) | <1s | Time to Interactive |

| LCP | <2.5s | Largest Contentful Paint |

| FID / INP | <100ms | 互動回應 |

| CLS | <0.1 | 版面穩定性 |

| Bundle Size | <500KB gzip | JS bundle |

輸出格式

## Performance Report

**Before:** [baseline 量測數字]
**After:**  [優化後數字]
**Improvement:** [百分比改善]

### Bottlenecks Identified
1. [問題] — Impact: High / Medium / Low

### Optimizations Applied
1. [改動] → [結果]

### Remaining Headroom
[還有哪些可以優化但本次未做]

Gotcha

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.