Use when working with Electron - IPC security, renderer isolation, Node API access
Use this skill when implementing features that interact with Electron APIs or system resources.
electron/preload.ts
contextBridge.exposeInMainWorld() to expose APIswindow.electronAPI namespace conventionStep 1: Define handler in preload.ts
// electron/preload.ts
import { contextBridge, ipcRenderer } from 'electron'
contextBridge.exposeInMainWorld('electronAPI', {
backend: {
start: () => ipcRenderer.invoke('backend:start'),
stop: () => ipcRenderer.invoke('backend:stop'),
// Add new method here
getStatus: () => ipcRenderer.invoke('backend:status')
}
})
Step 2: Implement handler in main process
// electron/main.ts
ipcMain.handle('backend:status', async () => {
// Access Node.js APIs safely here
return await checkBackendStatus()
})
Step 3: Use in renderer process
// src/components/MyComponent.tsx
'use client'
const status = await window.electronAPI.backend.getStatus()
ipcRenderer.send() or ipcRenderer.invoke() directlytypes/ directoryFile system access:
// ✅ Good - specific, validated
contextBridge.exposeInMainWorld('electronAPI', {
files: {
readConfig: () => ipcRenderer.invoke('files:read-config'),
saveImage: (data: Buffer) => ipcRenderer.invoke('files:save-image', data)
}
})
// ❌ Bad - too generic, security risk
contextBridge.exposeInMainWorld('electronAPI', {
files: {
read: (path: string) => ipcRenderer.invoke('files:read', path) // Unsafe!
}
})
Process management:
// ✅ Good - scoped to backend process
backend: {
start: () => ipcRenderer.invoke('backend:start'),
stop: () => ipcRenderer.invoke('backend:stop')
}
// ❌ Bad - can execute arbitrary commands
system: {
exec: (command: string) => ipcRenderer.invoke('exec', command) // Very unsafe!
}
See Electron Security Guide: https://www.electronjs.org/docs/latest/tutorial/security
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer