advanced-patterns

advanced-patterns is a cursor rule for Cursor from adonai-labs/agent-runway. It costs 0 tokens per session (1,701 once invoked), scanned A, original, MIT.

Development guidance for complex Electron desktop apps, including multiple windows, communication between the app's processes, plugins, security settings, performance checks, and error recovery.

In plain words
What is it for?
Use it when building Electron apps with multiple windows, typed process communication, plugin systems, strict security controls, or recovery from errors.
Why use it?
It gives developers consistent patterns for handling Electron's separate processes and reduces common security, reliability, and performance mistakes.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

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/adonai-labs/agent-runway/advanced-patterns
Clone the repo
git clone --depth 1 https://github.com/adonai-labs/agent-runway

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 advanced-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/adonai-labs/agent-runway/advanced-patterns.svg)](https://agentmods.dev/rules/adonai-labs/agent-runway/advanced-patterns)
Your own site
<a href="https://agentmods.dev/rules/adonai-labs/agent-runway/advanced-patterns"><img src="https://agentmods.dev/badge/rules/adonai-labs/agent-runway/advanced-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 1,701 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.1 $0.00000 $0.01701
Opus 5 $0.00000 $0.00851
Sonnet 5 $0.00000 $0.00340
Haiku 4.5 $0.00000 $0.00170

Measured 2d ago against content hash 1f19b6c383d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

advanced-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 2d 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.

src/stacks/typescript/advanced-patterns.mdc · 151 lines

How it starts

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

Advanced Patterns for Electron Development

Directives for building complex, scalable Electron applications. Apply when implementing multi-window apps, typed IPC, plugins, or enterprise-level features.


Security Best Practices

  • Context isolation: Always enable contextIsolation: true and nodeIntegration: false in webPreferences
  • Preload scripts: Expose only the minimal API surface via contextBridge.exposeInMainWorld; never expose raw ipcRenderer or require
  • CSP: Implement strict Content Security Policy headers; restrict script sources to trusted domains; use nonces or hashes for inline scripts when unavoidable
  • IPC validation: Validate all IPC messages (type, format, length) before processing; reject invalid payloads explicitly
  • Origin verification: Verify message origin for sensitive IPC channels
  • For detailed security guidance (auth, encryption, input validation), defer to security.mdc and engineering-security.mdc
// Minimal BrowserWindow security
webPreferences: { nodeIntegration: false, contextIsolation: true, preload: path.join(__dirname, 'preload.js') }

Multi-Window Management

  • Use a centralised window manager — a single module or class that owns creation, lookup, and teardown of all BrowserWindow instances
  • Persist window state (bounds, maximised/minimised) on close; restore on reopen; ensure restored bounds stay within screen
  • Cleanup on close: Remove windows from the manager map on closed; clear references to avoid leaks
  • Unique IDs: Assign a stable ID per window; use it for IPC routing and state persistence
  • Parent-child relationships: Set parent where appropriate; ensure child windows close with parent
  • Do not create windows ad hoc from multiple places; route all creation through the manager

Advanced IPC Patterns

  • Typed request-response: Use a request ID, correlate responses, and support invoke-style async calls; avoid fire-and-forget for operations that need a result
  • Timeout handling: Set a timeout (e.g. 5s) for each request; reject and clean up pending requests on timeout
  • Batching: For high-frequency IPC, consider batching multiple operations into a single round-trip where latency allows
  • Validation: Validate payload shape and size before processing; return structured errors (code, message) rather than raw exceptions
  • Channel naming: Use a consistent naming scheme (e.g. module:action) and document the contract
  • Define shared TypeScript interfaces for request/response shapes in a shared/types module

Read the full file on GitHub · 151 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. 2d ago First seen · 151 lines · 0 tokens per session scan A 1f19b6c383d9

Subscribe to this mod's changes

advanced-patterns is a cursor rule published in the GitHub repository adonai-labs/agent-runway (2 stars, last pushed 15d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,701 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-09-03.