一键导入
electron-flamegraph
Profile Electron main-process CPU usage, generate launch commands, analyze .cpuprofile files, and identify actionable performance fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Profile Electron main-process CPU usage, generate launch commands, analyze .cpuprofile files, and identify actionable performance fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Set up, audit, or repair Cloudflare Workers PR previews with aliased URLs, branch-isolated D1 databases, migrations, binding injection, stable environments, and PR-close cleanup.
Integrate the PR base, run a configurable persistent read-only reviewer cohort, fix and re-review findings, require pnpm precommit, address review bots, and compare model quality.
Close GitHub PR review-bot feedback loops for Claude, Devin, and similar AI reviewers after a push.
| name | electron-flamegraph |
| description | Profile Electron main-process CPU usage, generate launch commands, analyze .cpuprofile files, and identify actionable performance fixes. |
| metadata | {"source":"biw/skills","homepage":"https://github.com/biw/skills"} |
Two-phase skill: give the user the exact command to profile their Electron app, do not run it, then analyze the .cpuprofile they return with.
The user is running the app on their own machine because (a) reproducing the slow behavior usually requires interaction they have to drive, and (b) their Electron app can't run in this environment anyway. Respect the boundary — don't try to execute the profiling command.
Read these before suggesting any command:
package.json — scripts, main entry, and electron-related deps (electron, @electron-forge/*, electron-vite, electron-builder, vite, esbuild, tsx). This determines the launcher.forge.config.{js,ts,cjs,mjs}, electron.vite.config.*, electron-builder.{yml,json,js}, vite.config.*.package.json#main or the forge/vite config). Note whether it's TypeScript or plain JS, and whether it's bundled before launch (affects source map usability).The launcher matters because raw electron . takes Node flags directly, Electron Forge needs -- --flag passthrough, and electron-vite sometimes needs NODE_OPTIONS. Read references/setup-patterns.md for the exact invocation per launcher.
Ask the user briefly if the right choice isn't obvious from the conversation. Three options:
A. Whole-process --cpu-prof — pass Node flags to the Electron main process. Best when the user has no specific hypothesis. Cost: captures startup noise, file is large, harder to read.
B. Programmatic scoped profiling — wrap the suspect code with node:inspector Session. Best when they already suspect a specific operation (a query, an import, a window transition). Gives a clean profile of just that slice. Requires a small code edit.
C. Live --inspect + Chrome DevTools — launch with the inspector, attach DevTools, hit record before the suspect action. Best for interactive investigation where the slow thing requires clicking around.
Default: B if they have a hypothesis, A otherwise. If they describe the problem as "it feels blocked when I do X", that's a hypothesis — push them toward B.
Read references/setup-patterns.md and generate the invocation for their specific launcher. Do not guess — the flag passthrough rules differ and getting it wrong wastes the user's time.
For strategy B, write the profileBlock helper into their codebase matching the existing style (TS vs JS) and show them exactly where to wrap the suspect code. Use arrow functions. If something similar already exists, reuse it rather than duplicating.
End Phase 1 with:
.cpuprofile file will land (cwd by default, or --cpu-prof-dir)Do not execute the command. Stop and wait.
Verify:
nodes, samples, timeDeltas keysnode scripts/analyze-cpuprofile.mjs <path-to-cpuprofile>
Run the bundled analyzer from this skill directory. If needed, resolve the directory containing this SKILL.md and pass the script path explicitly.
Optional flags:
--top=N — how many hot functions to list (default 20)--stall-threshold-ms=N — minimum sample duration to flag as a stall (default 50)--json — machine-readable output for further processingThe script produces:
The raw output is a starting point. The job is to correlate it with what the user was doing during capture and point at the specific thing to fix.
Ground rules:
Module._compile, require, V8 compilation, and first-query engine warmup dominate a full-lifetime profile but usually aren't the real problem.t, e$1, etc. Tell the user to enable source maps in their dev build and re-profile if the names are unreadable.For each finding worth addressing:
If the profile doesn't show a clear main-thread stall but the user's complaint was "it feels blocked," say that directly. Possible the complaint is a renderer/UX issue, not a main-process CPU issue — in which case they need the renderer's built-in DevTools Performance tab, not this skill. Don't invent findings to match the original hypothesis.