Electron bun dev orchestrator
Skill kjuhwa/skills-hub/skills/electron/electron-bun-dev-orchestrator
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill electron-bun-dev-orchestratorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Cross-platform Electron dev launcher that parallel-builds main/preload/MCP subprocess bundles, waits for file stability, watches with esbuild's JS API, and spawns Vite + Electron - replaces a fragile tree of npm scripts.
SKILL.md
3.8 KB, 841 tokens by cl100k_base, as published. Nobody here has run it
Electron + Bun dev orchestrator
When to use
- Electron app with separate main / preload / renderer / MCP-subprocess bundles.
- Team on mixed macOS + Windows + Linux dev machines (you want ONE dev script).
- Running multiple local instances side-by-side (e.g. beta vs stable).
- Need watch rebuild + verify-before-launch to avoid Electron starting on a half-written
main.cjs.
How it works
- Instance detection (
detectInstance, line 68): parses trailing-Noff the project folder name to setCRAFT_VITE_PORT=${N}173,CRAFT_CONFIG_DIR=~/.craft-agent-${N}, a unique app name, and a unique deep-link scheme. Lets you clone the repo intocraft-agents-1/,craft-agents-2/for parallel instances. - Port cleanup:
killProcessOnPort(vitePort)handles bothlsof -ti:PORT | xargs kill -9(unix) andnetstat -ano | findstr :PORT->taskkill /PID x /F(windows). - Initial one-shot build of
main.cjs,bootstrap-preload.cjs,browser-toolbar-preload.cjsviaesbuild.build()withplatform: 'node', format: 'cjs', external: ['electron']. Run inPromise.allfor parallelism. - File-stability gate: after build,
waitForFileStable(path, 10_000)polls size every 100ms, only returningtrueafter 3 consecutive unchanged readings. Prevents Electron from picking up a half-flushed binary. - Syntax verification: shell out to
node --check <file>before launching. If it fails, fail fast - much better DX than Electron crashing later. - Watch mode via esbuild JS API:
ctx = await esbuild.context({...}); await ctx.watch();- keep contexts in an array todispose()on shutdown. - Vite dev server is a separate
spawn(['vite', 'dev', '--port', N, '--strictPort'])- strictPort means it fails loudly rather than silently shifting. - Launch Electron last (
spawn([ELECTRON_BIN, 'apps/electron'])) with env wired:VITE_DEV_SERVER_URL=http://localhost:${port},CRAFT_CONFIG_DIR,CRAFT_APP_NAME, etc. - Clean shutdown: SIGINT/SIGTERM handler disposes esbuild contexts, kills all
Subprocesses.
Example
// Watch main + preload with esbuild's context API
const mainCtx = await esbuild.context({
entryPoints: [join(ROOT, 'apps/electron/src/main/index.ts')],
bundle: true, platform: 'node', format: 'cjs',
outfile: join(ROOT, 'apps/electron/dist/main.cjs'),
external: ['electron'],
define: oauthDefines,
});
await mainCtx.watch();
// after initial build + verify, spawn Electron
spawn([ELECTRON_BIN, 'apps/electron'], {
env: { ...process.env, VITE_DEV_SERVER_URL: `http://localhost:${port}` },
});
Gotchas
- Must build MCP subprocess bundles (e.g.
packages/session-mcp-server) even in dev - the Electron main process spawns them at runtime fromdist/. - Pi-SDK uses ESM-only packages;
bun build --target=bun --format=esmis the ONLY bundler combo that works (esbuildpackages:externalleaves brokenrequire()calls). waitForFileStablematters more than you think - Electron on Windows will happily launch with an empty.cjs.node --checkdoesn't work for Electron-specific packages (e.g.@sentry/electron) because it evaluates top-level code. Use file-exists + non-empty check instead for preload.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.