electron-dev
Skill192 starsChanged 4 months agoMITView on GitHub
Use this to test, debug, or verify the running Electron app from the command line — ready-to-paste CDP scripts to query renderer state on :9222, read main and renderer logs, drive end-to-end smoke tests without opening DevTools, and decide when (rarely) to restart the dev server vs. instrument.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- corvo007/MioSubtheir own version, first seen Oct 8, 2026
- corvo007/Gemini-Subtitle-Protheir own version, first seen Oct 8, 2026
- FelipeAngeli/skillstheir own version, first seen Apr 10, 2026
- pedronauck/skillstheir own version, first seen Apr 3, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- corvo007/Gemini-Subtitle-Pro★ 835same name
- corvo007/MioSub★ 835same name
- pedronauck/skills★ 649same name
- FelipeAngeli/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository7 other files it gives its agents.
- agent-core/CLAUDE.mdCLAUDE.md
- api/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- .github/workflows/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- shadcnSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
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
- Distinctive: line 60
Instrument before guessing: When something doesn't work:
- Distinctive: line 62
Add a one-line log at each boundary the event crosses: chokidar callback → main flush → IPC send → renderer listener → state-update → DOM.
- Distinctive: line 63
Use CDP to inspect renderer state and the DOM without restarting anything.
- Distinctive: line 68
Anti-pattern: speculating from the symptom: When external file changes weren't showing up in the sidebar, the first three hypotheses …
≈ “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.
Files
Driving the running Electron app
npm run dev exposes Chrome DevTools Protocol on http://localhost:9222. You can query the renderer, evaluate JS in it, and read its console — all from Bash, no GUI needed. This is how to verify a change actually works in the running app without watching it by hand.
For architecture and IPC discipline, read the root CLAUDE.md, src/main/CLAUDE.md, and src/renderer/CLAUDE.md. This skill is only about operating the running app.
Where logs land
- Main-process
console.log→ stdout ofnpm run dev. If the dev script runs as a background task, read the task's output file (tail -n 100 /tmp/.../<task-id>.output). - Renderer
console.log→ DevTools console (Cmd+Opt+I; this app auto-opens detached DevTools in dev). Or programmatically over CDP — see below.
Querying the renderer via CDP
List pages:
curl -s http://localhost:9222/json | python3 -c "import json,sys; print(json.dumps([{'title':p['title'],'url':p['url'][:80]} for p in json.load(sys.stdin)], indent=2))"Evaluate JS in the renderer — inspect React state, check window.api, query the DOM:
node --input-type=module -e "
const r = await fetch('http://localhost:9222/json');
const app = (await r.json()).find(p => p.url.includes('localhost:5173'));
const ws = new WebSocket(app.webSocketDebuggerUrl);
let id = 0; const pending = new Map();
ws.addEventListener('message', e => { const m = JSON.parse(e.data); if (m.id && pending.has(m.id)) { pending.get(m.id)(m); pending.delete(m.id); } });
const eval_ = (expr) => new Promise(res => { const i = ++id; pending.set(i, res); ws.send(JSON.stringify({ id: i, method: 'Runtime.evaluate', params: { expression: expr, returnByValue: true, awaitPromise: true } })); });
await new Promise(r => ws.addEventListener('open', r, { once: true }));
const out = await eval_('JSON.stringify({title: document.title, fileCount: document.querySelectorAll(\".tree-name\").length})');
console.log(out.result.result.value);
ws.close(); process.exit(0);
"Read renderer console output: subscribe to Runtime.consoleAPICalled events after Runtime.enable. Use this when you suspect the renderer is logging something useful but you can't see DevTools.
End-to-end smoke test pattern
Trigger a side effect from your test process (write a file in the workspace, send an IPC, drop something into the active window), poll the renderer DOM via CDP eval, assert. This is how we proved the file-watcher fix without touching the UI.
When to actually restart Electron
npm run dev rebuilds and reloads on edits to src/main/**, src/preload/**, and src/renderer/** automatically. You should almost never need to manually restart. Legitimate reasons:
- You changed
package.jsondependencies(electron-vite watches code, not installed packages). - You changed
electron.vite.config.jsitself. - You changed
package.jsonmainfield.
In those cases: stop the dev task and npm run dev again. Otherwise, edit and watch the rebuild happen.
Debugging philosophy
Instrument before guessing. When something doesn't work:
- Add a one-line log at each boundary the event crosses: chokidar callback → main flush → IPC send → renderer listener → state-update → DOM. Find which boundary it dies at.
- Use CDP to inspect renderer state and the DOM without restarting anything.
- Once you have the answer, remove the logs.
Anti-pattern: "restart and see if it goes away." If a restart fixes a bug, the bug is still there — you've just moved it. Find the actual cause. The original file-watcher bug looked like "stale state cured by restart" but was a real synchronous-cleanup race in a useEffect (see "Renderer-side fs:changed listener discipline" in src/renderer/CLAUDE.md). Restarting masked it; finding it required CDP-driven instrumentation.
Anti-pattern: speculating from the symptom. When external file changes weren't showing up in the sidebar, the first three hypotheses (chokidar broken / IPC dropping / react-arborist not re-rendering) were all wrong. The answer came only after watching events at every boundary.
Path / layout reference
| Source | Built to | Loaded by |
src/main/main.js | out/main/index.js | Electron entry (package.json main) |
src/preload/preload.cjs | out/preload/index.cjs | webPreferences.preload in main.js |
src/renderer/index.html + JS | out/renderer/ | dev: Vite at :5173; prod: loadFile(out/renderer/index.html) |
__dirname in main at runtime is <project>/out/main/ in dev and <app.asar>/out/main/ in prod. Asset paths in main.js (e.g. icon) must be two levels up: path.join(__dirname, '..', '..', 'build', 'icon.png').
Anti-patterns to refuse
--no-sandboxor disablingcontextIsolation/nodeIntegration— security regression, never required for this app.- Reaching for
nodemon— electron-vite handles main-process watching natively. Don't layer extra tooling. - Polling the filesystem from the renderer — the watcher already pushes events; if they're not arriving, fix the watcher, don't bypass it.
pkill -f electronblindly — kills VS Code, other Electron apps. Use the dev script's stop mechanism (orTaskStopif launched as a background task).
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
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.

