Agent skill

Electron Best Practices

by jwynia in jwynia/agent-skills

Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing.

MITAuto-check passedMobile

Install Electron Best Practices

skills CLI
$ npx skills add jwynia/agent-skills --skill electron-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jwynia/agent-skills electron-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jwynia/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/tech/development/tooling/electron-best-practices .claude/skills/electron-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
electron-best-practices
GitHub stars
170
Token cost
~3.1k tokens
SKILL.md length
844 words
Files
42 (incl. scripts, references, assets)
Skills in repo
111
Repo updated
First seen
Licence
MIT

At a glance

Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing.

  • Works in 4 steps: Security First Architecture → Type-Safe IPC Communication → Modern Project Setup → …
  • Tasks that involve Type safety
  • SKILL.md covers When to Use This Skill, Core Principles, Quick Reference and Code Generation Guidelines, plus 3 more sections
  • Calls deno

What it does

Electron Best Practices is an agent skill from jwynia/agent-skills. Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing. Keywords: electron, electron-vite, electron-forge, contextBridge, IPC, security, react, packaging, code signing, notarization, playwright, desktop app.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 47 other files, including scripts, reference files and assets (for example `assets/configs/electron-vite.config.ts.md`, `assets/configs/forge.config.js.md` and `assets/configs/playwright.config.ts.md`). Compatibility notes: Requires Deno for analysis scripts. Applicable to any Electron project using TypeScript and React.

It sits in Mobile, covering Type safety, App store release and Browser testing. It works with React, Playwright and Electron. The licence is MIT.

When your agent uses it

  • Tasks that involve Type safety
  • Tasks that involve App store release
  • Tasks that involve Browser testing

Example prompts

  • “/electron-best-practices”

Requirements

  • Node.js
  • Compatibility (from SKILL.md): Requires Deno for analysis scripts. Applicable to any Electron project using TypeScript and React.

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Security First Architecture
  2. Type-Safe IPC Communication
  3. Modern Project Setup
  4. React Integration Patterns

What it can do on your machine

Read from SKILL.md and the folder at commit e02ec7e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/, which the agent can run.

    Shell commands in SKILL.md call:

    • deno

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Requires Deno for analysis scripts. Applicable to any Electron project using TypeScript and React.

    From compatibility in the SKILL.md frontmatter.

Context cost

Electron Best Practices loads about 3.1k tokens when it runs, and up to ~55k if it reads all its reference files. Until then it costs about 85 tokens; SKILL.md has 844 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~85
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~55k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jwynia/agent-skills at commit e02ec7e, republished under its MIT licence (© jwynia). 844 words, ~3,077 tokens.

Download SKILL.mdSave it as .claude/skills/electron-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 41 other files; get the full folder from GitHub.
name
electron-best-practices
description
Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing. Keywords: electron, electron-vite, electron-forge, contextBridge, IPC, security, react, packaging, code signing, notarization, playwright, desktop app.
compatibility
Requires Deno for analysis scripts. Applicable to any Electron project using TypeScript and React.
license
MIT
metadata.author
agent-skills
metadata.version
1.0
metadata.domain
development
metadata.type
utility
metadata.mode
assistive

Electron + React Best Practices

Guide AI agents in building secure, production-ready Electron applications with React. This skill provides security patterns, type-safe IPC communication, project setup guidance, packaging and code signing workflows, and tools for analysis, scaffolding, and type generation.

When to Use This Skill

Use this skill when:

  • Generating Electron main, preload, or renderer process code
  • Configuring electron-vite or Electron Forge
  • Setting up IPC communication between processes
  • Implementing security patterns (contextBridge, sandbox, CSP)
  • Packaging, signing, and notarizing desktop applications
  • Testing Electron apps with Playwright
  • Designing multi-window architectures

Do NOT use this skill when:

  • Building Tauri apps (different paradigm, use Tauri-specific guidance)
  • Building pure web apps with no desktop requirements
  • Targeting Electron versions below 20 (security defaults differ)
  • Using non-React renderer frameworks (use framework-specific skills)

Core Principles

1. Security First Architecture

Modern Electron security relies on three defaults that became standard in Electron 20+: context isolation, sandbox mode, and nodeIntegration disabled. Disabling any of them allows XSS attacks to escalate to full remote code execution. All main-renderer communication must flow through contextBridge:

typescript
// preload.ts - SECURE pattern
contextBridge.exposeInMainWorld('electronAPI', {
  loadPreferences: () => ipcRenderer.invoke('load-prefs'),
  saveFile: (content: string) => ipcRenderer.invoke('save-file', content),
  onUpdateCounter: (callback: (value: number) => void) => {
    const handler = (_event: IpcRendererEvent, value: number) => callback(value);
    ipcRenderer.on('update-counter', handler);
    return () => ipcRenderer.removeListener('update-counter', handler);
  }
});

Set Content Security Policy via HTTP headers for apps loading local files, restricting script sources to 'self'.

2. Type-Safe IPC Communication

The invoke/handle pattern is preferred over send/on for request-response communication, providing proper async/await semantics and error propagation. For typed channels, use a mapped type pattern:

typescript
type IpcChannelMap = {
  'load-prefs': { args: []; return: UserPreferences };
  'save-file': { args: [content: string]; return: { success: boolean } };
};

For complex applications, electron-trpc provides full type safety using tRPC's router pattern with Zod validation:

typescript
export const appRouter = t.router({
  greeting: t.procedure
    .input(z.object({ name: z.string() }))
    .query(({ input }) => `Hello, ${input.name}!`),
});

Error handling across the IPC boundary requires attention because Electron only serializes the message property of Error objects. Wrap responses in a { success, data, error } result type to preserve full error context.

3. Modern Project Setup

The recommended stack uses electron-vite for development and Electron Forge for packaging. electron-vite provides a unified configuration managing main, preload, and renderer processes with sub-second dev server startup and instant HMR. Electron Forge uses first-party Electron packages for signing and notarization.

src/
├── main/           # Main process (Node.js environment)
│   ├── index.ts
│   └── ipc/        # IPC handlers
├── preload/        # Secure bridge via contextBridge
│   ├── index.ts
│   └── index.d.ts  # TypeScript declarations for exposed APIs
└── renderer/       # React application (pure web, no Node access)
    ├── src/
    └── index.html
4. React Integration Patterns

React 18's concurrent features work normally in Electron's Chromium-based renderer. Strict Mode's double-invocation of effects catches IPC listener leaks that would otherwise cause memory issues. Always return cleanup functions from effects that register IPC listeners:

typescript
useEffect(() => {
  const cleanup = window.electronAPI.onUpdateCounter((value) => {
    setCount(value);
  });
  return cleanup;
}, []);

For multi-window applications, the main process should serve as the single source of truth for shared state. Use electron-store for persistence combined with IPC broadcasting so any window's mutation updates all others.

Quick Reference

CategoryPreferAvoid
SecuritycontextBridge.exposeInMainWorld()nodeIntegration: true
IPCinvoke/handle patternsend/on for request-response
PreloadTyped function wrappersExposing raw ipcRenderer
Build toolelectron-vitewebpack-based toolchains
PackagingElectron ForgeManual packaging
StateZustand + electron-storeRedux for simple apps
TestingPlaywright E2ESpectron (deprecated)
Updateselectron-updaterManual update checks
SigningCI-integrated code signingUnsigned releases
CSPHTTP headers, 'self' onlyNo CSP
Error handlingResult type {success, data, error}Raw Error across IPC
Multi-windowMain process as state hubDirect window-to-window

Code Generation Guidelines

When generating Electron code, follow these patterns:

BrowserWindow Creation
typescript
const win = new BrowserWindow({
  webPreferences: {
    preload: path.join(__dirname, '../preload/index.js'),
    contextIsolation: true,
    sandbox: true,
    nodeIntegration: false,
  },
});

Always enable contextIsolation and sandbox. Never enable nodeIntegration. The preload path must resolve to the built output location.

IPC Handler Module
typescript
export function registerFileHandlers(): void {
  ipcMain.handle('save-file', async (_event, content: string) => {
    try {
      await fs.writeFile(filePath, content);
      return { success: true, data: filePath };
    } catch (err) {
      return { success: false, error: (err as Error).message };
    }
  });
}

Group related handlers into modules. Use the result type pattern for all return values. Validate all arguments received from the renderer process.

Show full SKILL.md (328 more words)Show less

Common Anti-Patterns

Avoid these patterns when generating Electron code:

Anti-PatternProblemSolution
nodeIntegration: trueXSS escalates to full RCEKeep disabled (default)
Exposing ipcRenderer directlyFull IPC access from rendererWrap in contextBridge functions
Missing contextIsolationRenderer accesses preload scopeKeep enabled (default since Electron 12)
No code signingOS security warnings, Gatekeeper blocksSign and notarize for all platforms
BrowserWindow without sandboxPreload has full Node.js accessEnable sandbox (default since Electron 20)
Unvalidated IPC argumentsInjection attacks from rendererValidate with Zod or manual checks
0.0.0.0 server bindingNetwork-exposed local serverAlways bind to 127.0.0.1
Missing CSP headersScript injection vectorsSet strict CSP via HTTP headers
No IPC error serializationLost error context across boundaryUse Result type pattern
Spectron for testingDeprecated, Electron 13 maxUse Playwright

See references/security/security-checklist.md for the full security audit checklist.

Scripts Reference

analyze-security.ts

Analyze Electron projects for security misconfigurations:

bash
deno run --allow-read scripts/analyze-security.ts <path> [options]

Options:
  --strict    Enable all checks
  --json      Output JSON for CI
  -h, --help  Show help

Examples:
  # Analyze a project
  deno run --allow-read scripts/analyze-security.ts ./src

  # Strict mode for CI pipeline
  deno run --allow-read scripts/analyze-security.ts ./src --strict --json
scaffold-electron-app.ts

Scaffold a new Electron + React project with secure defaults:

bash
deno run --allow-read --allow-write scripts/scaffold-electron-app.ts [options]

Options:
  --name <name>     App name (required)
  --path <path>     Target directory (default: ./)
  --with-react      Include React setup
  --with-trpc       Include electron-trpc
  --with-tests      Include Playwright tests

Examples:
  # Basic app with React
  deno run --allow-read --allow-write scripts/scaffold-electron-app.ts \
    --name "my-app" --with-react

  # Full setup with trpc and tests
  deno run --allow-read --allow-write scripts/scaffold-electron-app.ts \
    --name "my-app" --with-react --with-trpc --with-tests
generate-ipc-types.ts

Generate TypeScript type definitions from IPC handler files:

bash
deno run --allow-read --allow-write scripts/generate-ipc-types.ts [options]

Options:
  --handlers <path>  Path to IPC handler files
  --output <path>    Output path for type definitions
  --validate         Validate existing types match handlers

Examples:
  # Generate types from handlers
  deno run --allow-read --allow-write scripts/generate-ipc-types.ts \
    --handlers ./src/main/ipc --output ./src/preload/ipc-types.d.ts

  # Validate types in CI
  deno run --allow-read scripts/generate-ipc-types.ts \
    --handlers ./src/main/ipc --validate

Additional Resources

Security
  • references/security/context-isolation.md - contextBridge and isolation patterns
  • references/security/csp-and-permissions.md - Content Security Policy configuration
  • references/security/security-checklist.md - Full security audit checklist
IPC Communication
  • references/ipc/typed-ipc.md - Typed channel map patterns
  • references/ipc/electron-trpc.md - tRPC integration for full type safety
  • references/ipc/error-serialization.md - Result types across IPC boundary
Architecture
  • references/architecture/project-structure.md - Directory organization
  • references/architecture/process-separation.md - Main, preload, and renderer roles
  • references/architecture/multi-window-state.md - Shared state across windows
React Integration
  • references/integration/react-patterns.md - useEffect cleanup, Strict Mode
  • references/integration/state-management.md - Zustand and electron-store patterns
Packaging & Distribution
  • references/packaging/code-signing.md - Platform-specific signing workflows
  • references/packaging/auto-updates.md - electron-updater configuration
  • references/packaging/bundle-optimization.md - Size reduction techniques
  • references/packaging/ci-cd-patterns.md - GitHub Actions matrix builds
Testing
  • references/testing/playwright-e2e.md - Playwright Electron support
  • references/testing/unit-testing.md - Jest/Vitest multi-project configuration
  • references/testing/test-structure.md - Test organization patterns
Tooling
  • references/tooling/electron-vite.md - Build tool configuration
  • references/tooling/electron-forge.md - Packaging and distribution
  • references/tooling/tauri-comparison.md - When to choose Tauri instead
Templates
  • assets/templates/main-process.ts.md - Main process starter template
  • assets/templates/preload-script.ts.md - Preload script with contextBridge
  • assets/templates/ipc-handler.ts.md - IPC handler module template
  • assets/templates/react-root.tsx.md - React root component template
Configuration Examples
  • assets/configs/electron-vite.config.ts.md - electron-vite configuration
  • assets/configs/forge.config.js.md - Electron Forge configuration
  • assets/configs/tsconfig.json.md - TypeScript configuration presets
  • assets/configs/playwright.config.ts.md - Playwright Electron test config
Complete Examples
  • assets/examples/typed-ipc-example.md - End-to-end typed IPC walkthrough
  • assets/examples/multi-window-example.md - Multi-window state management

© jwynia, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 41 other files (scripts, references, assets) in skills/tech/development/tooling/electron-best-practices of jwynia/agent-skills.

  • SKILL.md
  • assets/configs/electron-vite.config.ts.md
  • assets/configs/forge.config.js.md
  • assets/configs/playwright.config.ts.md
  • assets/configs/tsconfig.json.md
  • assets/examples/multi-window-example.md
  • assets/examples/typed-ipc-example.md
  • assets/templates/ipc-handler.ts.md
  • assets/templates/main-process.ts.md
  • assets/templates/preload-script.ts.md
  • assets/templates/react-root.tsx.md
  • references/architecture/multi-window-state.md
  • references/architecture/process-separation.md
  • references/architecture/project-structure.md
  • references/integration
  • … and 27 more

Open the folder on GitHubat commit e02ec7e

Compare with similar skills

Electron Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Electron Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Electron Best Practices this skilljwynia/agent-skills170—~3.1kAutomated safety check: PassMIT
Desktopgridaco/grida2.7k—~3.2kAutomated safety check: NotesApache-2.0
App Store Deployromankurnovskii/BrewMate300—~813Automated safety check: NotesMIT
Fix Frontend Review CommentsJetBrains/kotlin-web-site1.6k—~444Automated safety check: PassApache-2.0
Liteyuki Webui FrontendLiteyukiStudio/LiteyukiBot157—~2.5kAutomated safety check: PassCustom licence
Type Safetyidavidov13/agentic-playwright225—~3.5kAutomated safety check: PassMIT

Similar skills

  • Desktop

    gridaco/grida

    Grida Desktop Electron shell and release-impact work: BrowserWindow, preload, window.grida, menus, protocol/deep links, file associations, Forge, path-scoped bridge security, Electron-only UI bugs…

    2.7k GitHub stars~3.2k tokensUpdated yesterday
    Testing & QAAuto-check: notes
  • App Store Deploy

    romankurnovskii/BrewMate

    Automates the build and deployment of the Electron app to the Mac App Store and TestFlight.

    300 GitHub stars~813 tokensUpdated 12 days ago
    MobileAuto-check: notes
  • Fix Frontend Review Comments

    JetBrains/kotlin-web-site

    Official

    Apply pull-request review comments to the frontend of kotlinlang.org (Next.js, React, TypeScript, CSS Modules under blocks/, components/, pages/, hooks/, utils/, test/).

    1.6k GitHub stars~444 tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Liteyuki Webui Frontend

    LiteyukiStudio/LiteyukiBot

    Build, review, or test LiteyukiBot v7's React/Vite WebUI under webui/ and its packaged static delivery in packages/webui/.

    157 GitHub stars~2.5k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check passed
  • Type Safety

    idavidov13/agentic-playwright

    TypeScript type safety conventions for the Playwright scaffold — the "no any" rule, Zod 4 schema patterns (z.strictObject, top-level validators like z.uuid / z.email / z.url / z.int / z.enum)…

    225 GitHub stars~3.5k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Config

    idavidov13/agentic-playwright

    Configuration and environment variable conventions for the Playwright scaffold — env file layout (env/.env.), dotenv loading via playwright.config.ts and the ENVIRONMENT variable, config objects in…

    225 GitHub stars~2.8k tokensUpdated 2 days ago
    Testing & QAAuto-check: notes

More from jwynia/agent-skills

All 111 skills in this repo
  • Devcontainer

    jwynia/agent-skills

    Diagnose devcontainer configuration problems and guide development environment setup.

    170 GitHub stars~1.2k tokensUpdated 7 mo ago
    Auto-check: notes
  • Frontend Design

    jwynia/agent-skills

    Create distinctive, production-grade frontend interfaces with high design quality.

    170 GitHub stars~3.2k tokensUpdated 7 mo ago
    Auto-check passed
  • Gitea Workflow

    jwynia/agent-skills

    Orchestrate agile development workflows for Gitea repositories using the tea CLI.

    170 GitHub stars~3.8k tokensUpdated 7 mo ago
    Auto-check passed
  • Godot Asset Generator

    jwynia/agent-skills

    Generate game assets using AI image generation APIs (DALL-E, Replicate, fal.ai) and prepare them for Godot.

    170 GitHub stars~3.8k tokensUpdated 7 mo ago
    Auto-check passed
  • Mastra Hono

    jwynia/agent-skills

    Develop AI agents, tools, and workflows with Mastra v1 Beta and Hono servers.

    170 GitHub stars~2.9k tokensUpdated 7 mo ago
    Auto-check passed
  • PPTX Generator

    jwynia/agent-skills

    Create and manipulate PowerPoint PPTX files programmatically.

    170 GitHub stars~3.1k tokensUpdated 7 mo ago
    Auto-check passed

Questions about Electron Best Practices

What does Electron Best Practices do?

Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing. Electron Best Practices is an agent skill from jwynia/agent-skills. Guide AI agents through Electron app development with React including security patterns, type-safe IPC, React integration, packaging with code signing, and testing.

When should I use Electron Best Practices?

Electron Best Practices fits situations like: tasks that involve Type safety; tasks that involve App store release; tasks that involve Browser testing.

How do I install Electron Best Practices in Claude Code?

Run `npx skills add jwynia/agent-skills --skill electron-best-practices -a claude-code`. Or copy the skill folder (skills/tech/development/tooling/electron-best-practices in jwynia/agent-skills) into .claude/skills/electron-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install Electron Best Practices in Codex?

Run `npx skills add jwynia/agent-skills --skill electron-best-practices -a codex`. Or copy the skill folder (skills/tech/development/tooling/electron-best-practices in jwynia/agent-skills) into .agents/skills/electron-best-practices in your project. Codex loads it when a task matches its description.

Can I use Electron Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jwynia/agent-skills --skill electron-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/electron-best-practices, .gemini/skills/electron-best-practices, .github/skills/electron-best-practices and .opencode/skills/electron-best-practices in your project.

What does Electron Best Practices need to run?

Going by SKILL.md and its folder, Electron Best Practices needs the command-line tools its instructions call (deno). Our summary lists: Node.js. Compatibility (from SKILL.md): Requires Deno for analysis scripts. Applicable to any Electron project using TypeScript and React..

Does Electron Best Practices access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Electron Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Electron Best Practices use?

Electron Best Practices is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Electron Best Practices use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 52k tokens, read only when the agent opens those files.

What are the alternatives to Electron Best Practices?

Skills that share tags, products or a category with Electron Best Practices: Desktop (gridaco/grida, 2.7k stars), App Store Deploy (romankurnovskii/BrewMate, 300 stars), Fix Frontend Review Comments (JetBrains/kotlin-web-site, 1.6k stars) and Liteyuki Webui Frontend (LiteyukiStudio/LiteyukiBot, 157 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Electron Best Practices?

jwynia (a GitHub user) maintains it in jwynia/agent-skills, which has 170 GitHub stars. The repository holds 111 skills in this directory. The repository was last updated on February 24, 2026.

Source: jwynia/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.