electron-pro
FreeRuns bundled scriptsNot checkedExpert Electron desktop application development — main/renderer process architecture, IPC communication, native OS APIs (menus, tray, notifications, dialogs)…
by oimiragieo★ 48 GitHub starsAbout this skill
Electron Pro Skill
Overview
Full-stack Electron desktop app development — from architecture through distribution. Covers process model, security hardening, native OS integration, IPC patterns, packaging, and auto-update.
Process Architecture
┌─────────────────────────────────────┐
│ Main Process │
│ (Node.js — full system access) │
│ app, BrowserWindow, Menu, Tray │
│ nativeImage, shell, ipcMain │
└──────────────┬──────────────────────┘
│ IPC (structured clone)
┌──────────────┴──────────────────────┐
│ Renderer Process │
│ (Chromium — sandboxed by default) │
│ Web UI: React/Vue/Svelte/vanilla │
│ ipcRenderer (via contextBridge) │
└─────────────────────────────────────┘
│ contextBridge
┌──────────────┴──────────────────────┐
│ Preload Script │
│ Bridge between main and renderer │
│ Exposes safe APIs via contextBridge│
└─────────────────────────────────────┘
Security-First Setup (MANDATORY)
// main.js — Always use these security options
const win = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true, // REQUIRED: isolates renderer from preload
sandbox: true, // RECOMMENDED: OS-level sandbox
nodeIntegration: false, // REQUIRED: never expose Node to renderer
webSecurity: true, // REQUIRED: never disable
allowRunningInsecureContent: false,
},
});
// NEVER do this — security violation:
// nodeIntegration: true
// contextIsolation: false
// Use remote: require('@electron/remote') only if absolutely necessary
Preload + contextBridge
// preload.js — the ONLY safe bridge to Node
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
// Expose specific, validated methods only
openFile: () => ipcRenderer.invoke('dialog:openFile'),
saveFile: content => {
if (typeof content !== 'string') throw new Error('Invalid content');
return ipcRenderer.invoke('dialog:saveFile', content);
},
onUpdateAvailable: callback => {
// One-way: main → renderer
const listener = (_, data) => callback(data);
ipcRenderer.on('update-available', listener);
return () => ipcRenderer.removeListener('update-available', listener);
},
// Platform info (read-only)
platform: process.platform,
});
// renderer.js — use the exposed API
window.electronAPI.openFile().then(filePath => {
console.log('Selected:', filePath);
});
IPC Communication Patterns
// main.js — handle IPC calls
const { ipcMain, dialog, app } = require('electron');
// Two-way: renderer calls, main responds
ipcMain.handle('dialog:openFile', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog({
properties: ['openFile'],
filters: [{ name: 'JSON', extensions: ['json'] }],
});
if (canceled) return null;
return filePaths[0];
});
// Validate inputs — never trust renderer
ipcMain.handle('fs:readFile', async (event, filePath) => {
// Validate path is within allowed directories
const allowed = path.join(app.getPath('userData'), 'files');
const resolved = path.resolve(filePath);
if (!resolved.startsWith(allowed)) {
throw new Error('Path traversal denied');
}
return fs.promises.readFile(resolved, 'utf8');
});
// One-way: main → renderer push
win.webContents.send('update-available', { version: '1.2.0' });
// One-way: renderer → main fire-and-forget
// preload: ipcRenderer.send('log', message)
// main: ipcMain.on('log', (event, message) => console.log(message))
Native OS Integration
Menu
const { Menu, MenuItem } = require('electron');
const template = [
{
label: 'File',
submenu: [
{ label: 'New', accelerator: 'CmdOrCtrl+N', click: () => createWindow() },
{ label: 'Open', accelerator: 'CmdOrCtrl+O', click: () => openFileDialog() },
{ type: 'separator' },
{ role: 'quit' },
],
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
],
},
// macOS: add app menu as first item
...(process.platform === 'darwin'
? [
{
label: app.name,
submenu: [{ role: 'about' }, { type: 'separator' }, { role: 'hide' }, { role: 'quit' }],
},
]
: []),
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
System Tray
const { Tray, Menu, nativeImage } = require('electron');
const icon = nativeImage.createFromPath(path.join(__dirname, 'assets/tray-icon.png'));
const tray = new Tray(icon);
tray.setToolTip('My App');
tray.setContextMenu(
Menu.buildFromTemplate([
{ label: 'Open', click: () => win.show() },
{ label: 'Quit', click: () => app.quit() },
])
);
tray.on('click', () => (win.isVisible()
Install electron-pro in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
BashReadWriteEditBundled files
FAQ
What does the electron-pro skill do?
Expert Electron desktop application development — main/renderer process architecture, IPC communication, native OS APIs (menus, tray, notifications, dialogs), auto-updates, code signing, packaging with electron-builder/forge, security hardening (contextIsolation, sandbox), and performance optimization. Use for building cross-platform desktop apps.
How do I install the electron-pro skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the electron-pro skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic