Skip to content
Cursor Rules Generator
Frontend4 sections

Electron Cursor Rules Template

Generate production-ready Electron Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Electron. Desktop app framework using Chromium and Node.js with native OS integration.

The Complete Electron Cursor Rules

The full rule set in all three formats Cursor understands — copy the one your project uses. Project Rules (.mdc) load per-file via globs, AGENTS.md is portable across AI tools, and .cursorrules is the legacy single-file format.

Replacing a legacy file? Read the guide to migrate .cursorrules to Cursor Project Rules (.mdc) before copying this template into your project.

.cursor/rules/electron-architecture.mdc
---
description: "Process Architecture"
alwaysApply: false
---
- Use IPC (ipcMain/ipcRenderer) for main-renderer communication — never access Node APIs from renderer directly.
- Keep the main process minimal: app lifecycle, window management, native menus, and IPC handlers only.
- Use contextBridge.exposeInMainWorld() to safely expose APIs to the renderer process.
- Set contextIsolation: true and nodeIntegration: false in webPreferences for security.
- Use preload scripts to bridge main and renderer processes — never enable nodeIntegration.
- Use BrowserWindow with sandbox: true for untrusted content.
.cursor/rules/electron-security.mdc
---
description: "Security Best Practices"
alwaysApply: false
---
- Validate all external URLs before loading them in BrowserWindow or webview.
- Use Content-Security-Policy headers to prevent XSS and code injection.
- Disable remote module: set enableRemoteModule: false.
- Never trust user input in IPC handlers — validate and sanitize all arguments.
- Use webContents.session.setPermissionRequestHandler() to manage permissions.
- Keep Electron and all dependencies updated to the latest stable versions.
- Use electron-builder or electron-forge for packaging with code signing.
.cursor/rules/electron-performance.mdc
---
description: "Performance & Optimization"
alwaysApply: false
---
- Lazy-load heavy modules only when needed — avoid loading them at startup.
- Use BrowserWindow pooling for multi-window apps instead of creating/destroying windows repeatedly.
- Offload CPU-intensive work to a hidden BrowserWindow or Worker thread.
- Use webFrame.setZoomLevel() sparingly — prefer CSS zoom for UI scaling.
- Monitor memory usage and implement cleanup for long-running windows.
- Use requestIdleCallback for non-critical renderer work.
- Minimize main process synchronous operations — use async IPC handlers.

Customize These Rules

The generator below is preloaded with the Electron template. Adjust indentation, quotes, naming, add your own rules, then download — no need to start from scratch on the homepage.

What This Template Covers

Required guidance

  • - Process Architecture
  • - Security Best Practices
  • - Performance & Optimization

Default style

  • - Indentation: 2 spaces
  • - Quotes: single
  • - Semicolons: enabled
  • - Naming: camelCase

Optional sections: Packaging & Distribution.

Frequently Asked Questions

What does the Electron Cursor rules template include?
It includes 4 rule sections covering process architecture, security best practices, performance & optimization and other Electron development conventions.
Can I generate Electron Project Rules and AGENTS.md from the same template?
Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
Should I combine Electron with other Cursor rules templates?
Yes. You can combine Electron with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.