Skip to main content
electron-architect Electron desktop application architect. Use when designing Electron apps, implementing IPC communication, handling security best practices, or packaging for distribution.
インストールへ移動 Skills Marketplace コミュニティが作成したAIスキルを発見・探索
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/jvegaf/harmony --skill electron-architectコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Zipをダウンロード ダウンロード中... name electron-architect description Electron desktop application architect. Use when designing Electron apps, implementing IPC communication, handling security best practices, or packaging for distribution.
Electron Architecture Expert
Expert assistant for Electron desktop application architecture, Main/Renderer process design, IPC communication, security best practices, and application packaging.
Thinking Process
When activated, follow this structured thinking approach to design Electron applications:
Step 1: Application Requirements Analysis
Goal: Understand what the desktop application needs to accomplish.
Key Questions to Ask:
What is the core functionality? (editor, dashboard, utility, media)
What system resources are needed? (file system, network, hardware)
What is the target platform? (macOS, Windows, Linux, or all)
Are there offline requirements?
What is the expected data sensitivity? (local files, credentials, user data)
Actions:
List all features requiring system access (files, network, native APIs)
Identify user interaction patterns (single window, multi-window, tray app)
Determine data persistence needs (local storage, SQLite, file system)
Map integration points (external APIs, local services, hardware)
Decision Point: You should be able to articulate:
"This app needs access to [X] system resources"
"The main user flows are [Y]"
"Security sensitivity level is [Z]"
Step 2: Architecture Design (Security First)
Goal: Design a secure Main/Renderer architecture.
Thinking Framework - Security Principles:
Least Privilege: Renderer should have minimal capabilities
Defense in Depth: Multiple layers of protection
Explicit Communication: All IPC channels are explicit and validatedArchitecture 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:
"Does this need Main process access?"
"What is the minimal IPC surface needed?"
Step 3: IPC Design Goal: Design safe, type-safe IPC communication.
"What data flows between Main and Renderer?"
"Who initiates the communication?"
"What validation is needed on each end?"
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
interface IpcChannels {
'file:open' : { args : void ; return : string | null };
'file:save' : { args : { path : string ; content : string }; return : boolean };
}
Step 4: Preload Script Design Goal: Create a minimal, secure bridge between worlds.
"What is the absolute minimum the renderer needs?"
"Am I exposing more than necessary?"
"Is each exposed function validated?"
Preload Design Principles:
Minimal Surface: Only expose what's absolutely needed
No Raw IPC: Wrap ipcRenderer, don't expose directly
Type Definitions: Provide TypeScript types for renderer
One-Way Binding: Prefer invoke over send/on pairs
contextBridge.exposeInMainWorld ('electron' , { ipcRenderer });
contextBridge.exposeInMainWorld ('api' , {
send : (channel, data ) => ipcRenderer.send (channel, data),
});
contextBridge.exposeInMainWorld ('api' , {
openFile : () => ipcRenderer.invoke ('dialog:openFile' ),
saveFile : (content : string ) => ipcRenderer.invoke ('file:save' , content),
});
Step 5: Window Management Strategy Goal: Design appropriate window management for the application.
"How many windows does this app need?"
"How do windows communicate?"
"What happens when windows are closed?"
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:
Step 6: Data Persistence Strategy Goal: Design secure, reliable data storage.
"What data needs to persist?"
"How sensitive is this data?"
"Does data need to sync across devices?"
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
Step 7: Packaging and Distribution Goal: Configure reliable cross-platform distribution.
"Which platforms are targets?"
"How will updates be delivered?"
"What signing/notarization is needed?"
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
Step 8: Testing Strategy Goal: Ensure the application is reliable across platforms.
Unit Tests: Business logic in Main process
Integration Tests: IPC communication
E2E Tests: Spectron/Playwright for UI flows
Platform Tests: CI matrix for all target platforms
Usage
Scaffold New Project bash /mnt/skills/user/electron-architect/scripts/scaffold-project.sh [project-name] [ui-framework] [package-manager]
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)
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
nodeIntegration: false
contextIsolation: true
sandbox: true
Documentation Resources
Electron: https://www.electronjs.org/docs/latest/
Electron Forge: https://www.electronforge.io/
electron-builder: https://www.electron.build/
Project Structure 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
Security Configuration
BrowserWindow Settings
const mainWindow = new BrowserWindow ({
width : 1200 ,
height : 800 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
sandbox : true ,
preload : path.join (__dirname, 'preload.js' ),
webSecurity : true ,
},
});
Preload Script Pattern
import { contextBridge, ipcRenderer } from 'electron' ;
contextBridge.exposeInMainWorld ('electronAPI' , {
saveFile : (content : string ) => ipcRenderer.invoke ('file:save' , content),
onUpdateAvailable : (callback : (version: string ) => void ) =>
ipcRenderer.on ('update-available' , (_, version ) => callback (version)),
openFile : () => ipcRenderer.invoke ('dialog:openFile' ),
});
declare global {
interface Window {
electronAPI : {
saveFile : (content : string ) => Promise <boolean >;
onUpdateAvailable : (callback : (version: string ) => void ) => void ;
openFile : () => Promise <string | null >;
};
}
}
Main Process Handlers
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 ;
});
}
IPC Communication Patterns
Pattern 1: Invoke (Request-Response)
const data = await window .electronAPI .fetchData (id);
ipcMain.handle ('fetch-data' , async (event, id) => {
return await database.get (id);
});
Pattern 2: Send/On (Fire-and-Forget)
mainWindow.webContents .send ('notification' , message);
window .electronAPI .onNotification (msg => showToast (msg));
Pattern 3: Two-Way Events
const result = await window .electronAPI .processFile (path);
Packaging Configuration
Electron Forge {
"config" : {
"forge" : {
"packagerConfig" : {
"asar" : true ,
"icon" : "./assets/icon"
} ,
"makers" : [
{ "name" : "@electron-forge/maker-squirrel" } ,
{ "name" : "@electron-forge/maker-dmg" } ,
{ "name" : "@electron-forge/maker-deb" }
]
}
}
}
Present Results to User When providing Electron solutions:
Always follow security best practices
Provide complete IPC communication examples
Consider cross-platform compatibility
Include TypeScript types for the API
Note Electron version differences
Troubleshooting
nodeIntegration is correctly disabled
Use preload script with contextBridge
"Cannot access window.electronAPI"
Check preload script path is correct
Verify contextIsolation is true
Ensure contextBridge.exposeInMainWorld is called
"IPC message not received"
Verify channel names match exactly
Check if handler is registered before window loads
Use invoke for async responses
このリポジトリの他の Skills Master effective code review practices to provide constructive feedback, catch bugs early, and foster knowledge sharing while maintaining team morale. Use when reviewing pull requests, establishing review standards, or mentoring developers.
Type-safe SQL ORM for TypeScript with zero runtime overhead
Provides comprehensive guidance for Electron framework including main process, renderer process, IPC communication, window management, and desktop app development. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps.