Home › Electron › Electron app AGENTS.md

Electron app AGENTS.md

AGENTS.md for Electron desktop apps (Electron Forge or electron-vite): process layout, IPC contracts, and release safety.

AGENTS.mdElectron

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: Electron app

## Commands
`npm run dev` · `npm test` · `npm run lint` · `npm run typecheck` · package: `npm run make` (don't publish)

## Layout
- `src/main/` (Node, privileged), `src/preload/` (bridge), `src/renderer/` (web UI, unprivileged), `src/shared/` (types and IPC channel names).
- Renderer code may not import `electron`, `fs`, or other Node modules. If it needs something, add a typed method to the preload API and a handler in main.

## IPC contract
- Each channel is defined once in `src/shared/ipc.ts` with request/response types.
- Main: `ipcMain.handle(CHANNEL, handler)`; handlers validate input (zod) and return plain serializable data.
- Preload: `contextBridge.exposeInMainWorld('api', { getSettings: () => ipcRenderer.invoke(...) })` and a matching `window.api` type declaration.

## Security (keep these on)
- `contextIsolation`, `sandbox`, no `nodeIntegration`, strict CSP, navigation and `window.open` blocked except allowlisted URLs.
- Never load remote code into a window with preload access.

## Native and files
- Use `app.getPath('userData')` for app data; never write next to the executable.
- Native modules must be rebuilt for Electron (`@electron/rebuild` or the bundler plugin).

## Don't
- Don't bump the Electron major, change signing/notarization config, or publish releases without approval.

## Done
Typecheck, lint and tests pass; the packaged app launches and the changed flow works.

More: all Electron rules · all AGENTS.md rules

Related rules

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

Tauri 2 Rust backend rules

Cursor rules for the Rust side of Tauri 2 apps: commands, typed errors, state, plugins, and capability files.

CursorTauri

Tauri 2 desktop app Windsurf rules

Windsurf rules for Tauri 2 desktop/mobile apps: Rust commands, capabilities and permissions, and a web frontend.

WindsurfTauri

REST API design AGENTS.md

AGENTS.md for designing consistent HTTP/JSON APIs: resource naming, status codes, errors, pagination, and versioning.

AGENTS.mdAPI design

Bevy game engine AGENTS.md

AGENTS.md for Bevy (0.16+) games in Rust: ECS systems, plugins, required components, and fast dev builds.

AGENTS.mdBevy (Rust)

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.