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.

What This Template Covers

The template focuses Cursor AI on concrete Electron practices instead of generic coding advice. Required sections are always included; optional sections can be enabled when they match your project.

Required guidance

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

Default style

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

Optional sections: Packaging & Distribution.

Example Electron Rules

The generator turns these sections into Project Rules with frontmatter, AGENTS.md, or a single .cursorrules file depending on the output format you choose.

Process Architecture

- 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.

Security Best Practices

- 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.

Performance & Optimization

- 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.

Common Searches This Page Helps With

electron cursor ruleselectron .cursorruleselectron AGENTS.md

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.

Related Cursor Rules Templates