electron-patterns

electron-patterns is a cursor rule for Cursor from zeyadelosherey/tapwisper-desktop. It costs 0 tokens per session (518 once invoked), scanned A, original, MIT.

A set of coding rules for Electron's main process, the part of a desktop app that creates windows, handles system events, and stores data.

In plain words
What is it for?
Use it when adding or changing Electron windows, communication with the renderer, global shortcuts, user settings, activity data, or database migrations.
Why use it?
It gives contributors agreed locations and patterns for windows, messages between app parts, keyboard shortcuts, settings, databases, and data changes.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/zeyadelosherey/tapwisper-desktop/electron-patterns
Clone the repo
git clone --depth 1 https://github.com/zeyadelosherey/tapwisper-desktop

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for electron-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/zeyadelosherey/tapwisper-desktop/electron-patterns.svg)](https://agentmods.dev/rules/zeyadelosherey/tapwisper-desktop/electron-patterns)
Your own site
<a href="https://agentmods.dev/rules/zeyadelosherey/tapwisper-desktop/electron-patterns"><img src="https://agentmods.dev/badge/rules/zeyadelosherey/tapwisper-desktop/electron-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 518 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00518
Opus 5 $0.00000 $0.00259
Sonnet 5 $0.00000 $0.00104
Haiku 4.5 $0.00000 $0.00052

Measured 5d ago against content hash 3bb966b2132a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

electron-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/electron-patterns.mdc · 55 lines

How it starts

The opening of the file, as written. The whole thing — 55 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Electron Main Process Patterns

Window Management

  • Windows are created in src/main/windows.ts
  • Overlay windows (recording pill, pinned panel, command popup, AI panel) are pre-warmed at startup
  • Each overlay loads the same renderer entry point but with a different hash route
  • Main window is 1000x700 and resizable; overlays are small, frameless, and always-on-top

IPC Communication

  • IPC handlers are registered in src/main/ipc-handlers.ts
  • Use ipcMain.handle() for async request/response patterns
  • Use ipcMain.on() for fire-and-forget events
  • Send events to renderer via webContents.send()
  • The preload script (src/preload/index.ts) exposes all IPC methods as window.tapwisper.*

Global Shortcuts

  • Keyboard shortcuts use uiohook-napi (not Electron's globalShortcut)
  • Shortcut logic lives in src/main/shortcuts.ts
  • Key constants (hold threshold, grace period, cooldown) are in src/main/constants.ts

Data Storage

  • Config: electron-store for user settings (API keys, preferences)
  • Database: better-sqlite3 for activity tracking and stats (src/main/database.ts)
  • Migrations: Data migration utilities in src/main/migrate-data.ts

Security

  • Context isolation is enabled -- renderer cannot access Node.js APIs directly
  • All renderer-to-main communication must go through the preload contextBridge
  • Never expose raw ipcRenderer to the renderer process
  • API keys are stored via electron-store (encrypted at rest)

Audio

  • Audio recording and encoding logic is in src/main/audio.ts
  • Audio blobs are passed to the renderer for transcription via AI providers

Permissions

  • Platform-aware permission checking and requesting lives in src/main/permissions.ts
  • macOS: checks microphone (systemPreferences.getMediaAccessStatus), accessibility (isTrustedAccessibilityClient), and screen recording
  • Windows/Linux: only microphone is relevant; accessibility and screen recording are always reported as 'granted'
  • IPC handlers: permissions:check returns all statuses, permissions:request triggers the native prompt or opens system settings
  • Exposed to renderer via window.tapwisper.permissions.check() and window.tapwisper.permissions.request(type)

Read the full file on GitHub · 55 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 55 lines · 0 tokens per session scan A 3bb966b2132a

Subscribe to this mod's changes

electron-patterns is a cursor rule published in the GitHub repository zeyadelosherey/tapwisper-desktop (5 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 518 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.