.agents/skills/electron-architect/SKILL.md
Electron desktop application architect. Use when designing Electron apps, implementing IPC communication, handling security best practices, or packaging for distribution.
npx skillsauth add jvegaf/harmony electron-architectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Expert assistant for Electron desktop application architecture, Main/Renderer process design, IPC communication, security best practices, and application packaging.
When activated, follow this structured thinking approach to design Electron applications:
Goal: Understand what the desktop application needs to accomplish.
Key Questions to Ask:
Actions:
Decision Point: You should be able to articulate:
Goal: Design a secure Main/Renderer architecture.
Thinking Framework - Security Principles:
Architecture Decision Matrix:
| Capability Needed | Where to Implement | Security Consideration | | ------------------ | ---------------------- | ----------------------------------- | | UI Rendering | Renderer process | Treat as untrusted (like a browser) | | File system access | Main process | Expose via validated IPC | | Network requests | Main process preferred | Avoid renderer CORS issues | | Native dialogs | Main process | User consent for file access | | Crypto operations | Main process | Protect keys from renderer | | Shell commands | Main process only | Never expose to renderer |
Decision Point: For each feature, answer:
Goal: Design safe, type-safe IPC communication.
Thinking Framework:
IPC Pattern Selection:
| Communication Need | Pattern | Direction | | ------------------ | ---------------- | --------------- | | Request/response | invoke/handle | Renderer → Main | | Fire and forget | send | Renderer → Main | | Push notification | webContents.send | Main → Renderer | | Two-way stream | MessagePort | Bidirectional |
IPC Security Checklist:
Type Safety Pattern:
// Define channel types in shared/
interface IpcChannels {
'file:open': { args: void; return: string | null };
'file:save': { args: { path: string; content: string }; return: boolean };
}
Goal: Create a minimal, secure bridge between worlds.
Thinking Framework:
Preload Design Principles:
Anti-Patterns to Avoid:
// BAD: Exposes raw ipcRenderer
contextBridge.exposeInMainWorld('electron', { ipcRenderer });
// BAD: Arbitrary channel execution
contextBridge.exposeInMainWorld('api', {
send: (channel, data) => ipcRenderer.send(channel, data),
});
// GOOD: Explicit, limited API
contextBridge.exposeInMainWorld('api', {
openFile: () => ipcRenderer.invoke('dialog:openFile'),
saveFile: (content: string) => ipcRenderer.invoke('file:save', content),
});
Goal: Design appropriate window management for the application.
Thinking Framework:
Window Patterns:
| App Type | Pattern | | ------------------- | ----------------------------------------- | | Single document | One main window | | Multi-document | Window per document, shared state in Main | | Dashboard + details | Parent-child windows | | System utility | Tray app with popup |
Window Configuration Checklist:
Goal: Design secure, reliable data storage.
Thinking Framework:
Storage Options:
| Data Type | Solution | Security | | ---------------- | ------------------------ | --------------------- | | User preferences | electron-store | Plain or encrypted | | Structured data | SQLite (better-sqlite3) | File-level encryption | | Large files | File system | OS-level permissions | | Credentials | system keychain (keytar) | OS secure storage |
Data Security Checklist:
Goal: Configure reliable cross-platform distribution.
Thinking Framework:
Platform Checklist:
| Platform | Signing | Distribution | | -------- | --------------------------- | ----------------------------- | | macOS | Developer ID + Notarization | DMG, PKG, or Mac App Store | | Windows | Code signing certificate | NSIS, MSI, or Microsoft Store | | Linux | Optional GPG | AppImage, deb, rpm, Snap |
Auto-Update Strategy:
Goal: Ensure the application is reliable across platforms.
Testing Layers:
Testing Checklist:
bash /mnt/skills/user/electron-architect/scripts/scaffold-project.sh [project-name] [ui-framework] [package-manager]
Arguments:
project-name - Name of the project (default: my-electron-app)ui-framework - UI framework: vanilla, react, svelte, vue (default: vanilla)package-manager - Package manager: pnpm, npm, yarn (default: pnpm)Examples:
bash /mnt/skills/user/electron-architect/scripts/scaffold-project.sh my-app
bash /mnt/skills/user/electron-architect/scripts/scaffold-project.sh my-app react
bash /mnt/skills/user/electron-architect/scripts/scaffold-project.sh my-app svelte pnpm
Security defaults:
Official Documentation:
https://www.electronjs.org/docs/latest/https://www.electronforge.io/https://www.electron.build/src/
├── main/
│ ├── main.ts # Main process entry
│ ├── ipc/ # IPC handlers
│ │ └── file-handlers.ts
│ ├── services/ # Backend services
│ │ └── database.ts
│ └── menu.ts # Application menu
├── preload/
│ └── preload.ts # Context bridge
├── renderer/ # UI (React/Svelte/Vue)
│ ├── App.tsx
│ └── components/
└── shared/
└── types.ts # Shared type definitions
// main.ts - Secure configuration
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false, // Disable Node.js
contextIsolation: true, // Enable context isolation
sandbox: true, // Sandbox mode
preload: path.join(__dirname, 'preload.js'),
webSecurity: true, // Enforce same-origin
},
});
// preload.ts - Safe API exposure
import { contextBridge, ipcRenderer } from 'electron';
contextBridge.exposeInMainWorld('electronAPI', {
// One-way: Renderer → Main
saveFile: (content: string) => ipcRenderer.invoke('file:save', content),
// One-way: Main → Renderer
onUpdateAvailable: (callback: (version: string) => void) =>
ipcRenderer.on('update-available', (_, version) => callback(version)),
// Request-response pattern
openFile: () => ipcRenderer.invoke('dialog:openFile'),
});
// Type declaration for renderer
declare global {
interface Window {
electronAPI: {
saveFile: (content: string) => Promise<boolean>;
onUpdateAvailable: (callback: (version: string) => void) => void;
openFile: () => Promise<string | null>;
};
}
}
// main/ipc/file-handlers.ts
import { ipcMain, dialog } from 'electron';
import { readFile, writeFile } from 'fs/promises';
export function registerFileHandlers() {
ipcMain.handle('dialog:openFile', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog({
properties: ['openFile'],
filters: [{ name: 'Text', extensions: ['txt', 'md'] }],
});
if (canceled) return null;
return readFile(filePaths[0], 'utf-8');
});
ipcMain.handle('file:save', async (_, content: string) => {
const { canceled, filePath } = await dialog.showSaveDialog({});
if (canceled || !filePath) return false;
await writeFile(filePath, content);
return true;
});
}
// Renderer
const data = await window.electronAPI.fetchData(id);
// Main
ipcMain.handle('fetch-data', async (event, id) => {
return await database.get(id);
});
// Main → Renderer
mainWindow.webContents.send('notification', message);
// Renderer
window.electronAPI.onNotification(msg => showToast(msg));
// Renderer sends, awaits Main response
const result = await window.electronAPI.processFile(path);
{
"config": {
"forge": {
"packagerConfig": {
"asar": true,
"icon": "./assets/icon"
},
"makers": [
{ "name": "@electron-forge/maker-squirrel" },
{ "name": "@electron-forge/maker-dmg" },
{ "name": "@electron-forge/maker-deb" }
]
}
}
}
When providing Electron solutions:
"require is not defined"
"Cannot access window.electronAPI"
"IPC message not received"
tools
Build type-safe global state in React with Zustand. Supports TypeScript, persist middleware, devtools, slices pattern, and Next.js SSR with hydration handling. Prevents 6 documented errors. Use when setting up React state, migrating from Redux/Context, or troubleshooting hydration errors, TypeScript inference, infinite render loops, or persist race conditions.
development
Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.
content-media
Expert solutions architecture covering technical requirements, solution design, integration planning, and enterprise architecture alignment.
development
This skill should be used when building React components with TypeScript, typing hooks, handling events, or when React TypeScript, React 19, Server Components are mentioned. Covers type-safe patterns for React 18-19 including generic components, proper event typing, and routing integration (TanStack Router, React Router).