electron
$
npx mdskill add partme-ai/full-stack-skills/electronBuilds cross-platform desktop apps with Electron by managing processes, IPC, windows, and packaging.
- Helps developers create desktop applications using Electron's architecture and features.
- Integrates with Electron APIs like app, BrowserWindow, ipcMain, and ipcRenderer.
- Decides recommendations by matching user requests to Electron documentation topics.
- Presents results through structured examples and guidance aligned with official docs.
SKILL.md
.github/skills/electronView on GitHub ↗
---
name: electron
description: "Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps."
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- Build cross-platform desktop applications with Electron
- Understand Electron architecture (main process, renderer process, preload)
- Implement IPC (Inter-Process Communication) between processes
- Create and manage BrowserWindow instances
- Implement menus, tray icons, and native features
- Package and distribute Electron applications
- Use Electron Forge for project scaffolding and building
- Debug and test Electron applications
- Implement security best practices
- Use Electron APIs (app, BrowserWindow, ipcMain, ipcRenderer, etc.)
## How to use this skill
This skill is organized to match the Electron official documentation structure (https://www.electronjs.org/zh/docs/latest/, https://www.electronjs.org/zh/docs/latest/api/app). When working with Electron:
1. **Identify the topic** from the user's request:
- Getting started/快速开始 → `examples/getting-started/installation.md` or `examples/getting-started/quick-start.md`
- Main process/主进程 → `examples/processes/main-process.md`
- Renderer process/渲染进程 → `examples/processes/renderer-process.md`
- IPC communication/IPC 通信 → `examples/processes/ipc-communication.md`
- BrowserWindow/窗口 → `examples/api/browser-window.md`
- Menu/菜单 → `examples/api/menu.md`
- Packaging/打包 → `examples/advanced/packaging.md`
- Security/安全 → `examples/advanced/security.md`
2. **Load the appropriate example file** from the `examples/` directory:
**Getting Started (快速开始) - `examples/getting-started/`**:
- `examples/getting-started/installation.md` - Installing Electron and basic setup
- `examples/getting-started/quick-start.md` - Quick start tutorial
**Processes (进程) - `examples/processes/`**:
- `examples/processes/main-process.md` - Main process concepts and usage
- `examples/processes/renderer-process.md` - Renderer process concepts
- `examples/processes/preload-scripts.md` - Preload scripts usage
- `examples/processes/ipc-communication.md` - IPC communication patterns
**API Examples (API 示例) - `examples/api/`**:
- `examples/api/browser-window.md` - BrowserWindow usage
- `examples/api/menu.md` - Menu and context menu
- `examples/api/tray.md` - System tray
- `examples/api/dialog.md` - File dialogs
- `examples/api/ipc-main.md` - ipcMain usage
- `examples/api/ipc-renderer.md` - ipcRenderer usage
**Advanced (高级) - `examples/advanced/`**:
- `examples/advanced/packaging.md` - Application packaging
- `examples/advanced/security.md` - Security best practices
- `examples/advanced/auto-updater.md` - Auto updater
- `examples/advanced/native-modules.md` - Native modules
**Tools (工具) - `examples/tools/`**:
- `examples/tools/electron-forge.md` - Electron Forge usage
- `examples/tools/electron-fiddle.md` - Electron Fiddle usage
3. **Follow the specific instructions** in that example file for syntax, structure, and best practices
**Important Notes**:
- All examples follow Electron latest API
- Examples use both CommonJS (require) and ES modules (import)
- Each example file includes key concepts, code examples, and key points
- Always check the example file for best practices and common patterns
- Electron supports Windows, macOS, and Linux
4. **Reference API documentation** in the `api/` directory when needed:
- `api/app.md` - app module API
- `api/browser-window.md` - BrowserWindow API
- `api/ipc-main.md` - ipcMain API
- `api/ipc-renderer.md` - ipcRenderer API
- `api/menu.md` - Menu API
- `api/tray.md` - Tray API
5. **Use templates** from the `templates/` directory:
- `templates/main-process.md` - Main process template
- `templates/preload-script.md` - Preload script template
- `templates/renderer-process.md` - Renderer process template
- `templates/package-json.md` - package.json template
### Doc mapping (one-to-one with official documentation)
- `examples/` → https://www.electronjs.org/zh/docs/latest/
- `api/` → https://www.electronjs.org/zh/docs/latest/api/app
## Quick Start Example
```javascript
// main.js
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
function createWindow() {
const win = new BrowserWindow({
width: 800, height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false, // Security: always disable
contextIsolation: true // Security: always enable
}
})
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
// IPC handler example
ipcMain.handle('get-data', async () => {
return { message: 'Hello from main process' }
})
```
```javascript
// preload.js
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('api', {
getData: () => ipcRenderer.invoke('get-data')
})
```
## API Reference (`api/`)
- `api/app.md` - app module API
- `api/browser-window.md` - BrowserWindow API
- `api/ipc-main.md` / `api/ipc-renderer.md` - IPC APIs
- `api/menu.md` / `api/tray.md` / `api/dialog.md` - UI APIs
## Best Practices
1. **Security**: Never enable nodeIntegration in renderer process, use preload scripts
2. **Process separation**: Keep main and renderer processes separate
3. **IPC communication**: Use IPC for safe communication between processes
4. **Resource management**: Properly clean up resources (windows, listeners)
5. **Error handling**: Implement proper error handling and crash reporting
6. **Performance**: Optimize for performance, use webContents for debugging
7. **Packaging**: Use Electron Forge or electron-builder for packaging
8. **Auto updates**: Implement auto-updater for production apps
9. **Native modules**: Handle native module compatibility
10. **Cross-platform**: Test on all target platforms
## Resources
- **Official Website**: https://www.electronjs.org/zh/
- **Documentation**: https://www.electronjs.org/zh/docs/latest/
- **API Reference**: https://www.electronjs.org/zh/docs/latest/api/app
- **Electron Forge**: https://www.electronforge.io
- **Electron Fiddle**: https://www.electronjs.org/zh/fiddle
- **GitHub Repository**: https://github.com/electron/electron
## Keywords
Electron, desktop app, main process, renderer process, preload, IPC, BrowserWindow, Menu, Tray, Dialog, packaging, electron-builder, electron-forge, electron-fiddle, cross-platform, 桌面应用, 主进程, 渲染进程, IPC 通信, 窗口, 菜单, 托盘, 打包
More from partme-ai/full-stack-skills
- adobe-xd"Guides creation of UI/UX designs, interactive prototypes, reusable components, and design specs in Adobe XD. Use when the user asks about Adobe XD artboards, prototype links, repeat grids, component states, design tokens export, or developer handoff."
- angular"Provides comprehensive guidance for Angular framework including components, modules, services, dependency injection, routing, forms, and TypeScript integration. Use when the user asks about Angular, needs to create Angular applications, implement Angular components, or work with Angular features."
- ansible"Provides comprehensive guidance for Ansible automation including playbooks, roles, inventory, and module usage. Use when the user asks about Ansible, needs to automate IT tasks, create Ansible playbooks, or manage infrastructure with Ansible."
- ant-design-mini"Builds mini-program UIs with Ant Design Mini components for Alipay and WeChat mini-programs. Covers Button, Form, List, Modal, Tabs, NavBar, and 60+ components with theme customization and CSS variable theming. Use when the user needs to create mini-program interfaces with Ant Design Mini, configure themes, or implement mini-program-specific UI patterns."
- ant-design-mobile"Builds React mobile UIs with Ant Design Mobile (antd-mobile) components including Button, Form, List, Modal, Picker, Tabs, PullToRefresh, InfiniteScroll, and 50+ mobile-optimized components. Use when the user needs to create mobile-first React interfaces, implement mobile navigation, forms, or data display with Ant Design Mobile."
- ant-design-react"Builds enterprise React UIs with Ant Design (antd) including 60+ components (Button, Form, Table, Select, Modal, Message), design tokens, TypeScript support, and ConfigProvider theming. Use when the user needs to create React applications with Ant Design, build forms with validation, display data tables, or customize the Ant Design theme."
- ant-design-vueProvides comprehensive guidance for Ant Design Vue (AntDV) component library for Vue 3. Covers installation, usage, API reference, templates, and all component categories. Use when building enterprise-class UI with Vue 3 and Ant Design.
- api-doc-generator"Generate API documentation by scanning Controller classes, extracting endpoint URLs, HTTP methods, parameters, and response structures, then producing standardized docs from templates. Use when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting REST APIs. Do not trigger for generic documentation requests without explicit API mention."
- appium"Provides comprehensive guidance for Appium mobile testing including mobile app automation, element location, gestures, and cross-platform testing. Use when the user asks about Appium, needs to test mobile applications, automate mobile apps, or write Appium test scripts."
- ascii-ansi-colorizer"Add an ANSI color layer to existing ASCII/plain-text output (gradient/rainbow/highlights) with alignment-safe rules and a required no-color fallback. Use when the user wants to colorize terminal output, add rainbow effects to CLI text, or style ASCII art with ANSI colors."