Skip to content
cccskills
FreePublished on GitHub

erpc-communication

Guides using eRPC (electron-tRPC) for inter-process communication (IPC) between Electron main and renderer processes. Triggered when handling Electron IPC or tRPC-based systems.

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md2.4 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

eRPC Communication Guide

This skill provides mandatory instructions for implementing type-safe IPC using eRPC in this project.

1. Main Process Implementation

  • Route Definition: Must use the project's provided router utility to define tRPC routes.
  • Handler Initialization: Must use createIPCHandler from erpc/main to bind the router to Electron windows.
  • Context Injection: Should provide necessary instances (e.g., BrowserWindow or Tray) through createContext.
// Always initialize createIPCHandler within the app ready lifecycle
import { createIPCHandler } from 'erpc/main'

import { routers } from './rpcs'

createIPCHandler({
	createContext: async () => ({ win: mainWindow, tray: appTray }),
	router: routers,
	windows: [mainWindow]
})

2. Preload Script Configuration

  • Expose Bridge Interface: Must call exposeElectronTRPC() provided by erpc/main in the preload script.
  • Lifecycle: Should be called inside process.once('loaded').
import { exposeElectronTRPC } from 'erpc/main'

process.once('loaded', () => {
	exposeElectronTRPC()
})

3. Renderer Process Usage

  • Client Creation: Create tRPC client using ipcLink from erpc/renderer.
  • Type Safety: Always import Router type from main process to ensure complete end-to-end type safety.
import { createTRPCClient } from '@trpc/client'
import { ipcLink } from 'erpc/renderer'

import type { Router } from '@desktop/rpcs' // Import Router type from main process

export const trpc = createTRPCClient<Router>({
	links: [ipcLink()]
})

4. Routes and Endpoints Best Practices

  • Single Responsibility: Each route should correspond to a specific service in the main process (e.g., window, file, dialog).
  • Parameter Validation: It is strictly prohibited to write complex business logic in Router. Router is only responsible for validating input and output parameters; business logic must be delegated to Service (e.g., calling WindowService.open()).
  • Type Reference: For complex object parameters, type definitions must be placed under the packages/erpc package and shared between both ends, avoiding direct cross-package imports of entity logic.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Guides the generation, reading, and updating of agentmap.md files. This skill ensures a consistent and up-to-date codebase map for AI Agents.

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

Maintain package-level `agentmap.md` files as outline-level maps of the real file tree and core responsibilities. Use when package structure or responsibility boundaries change and the corresponding `agentmap.md` must be created or updated.

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

Interacts with local browser via Chrome DevTools Protocol (only triggered after user explicitly requests to inspect, debug, or interact with pages open in Chrome)

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

css

Free

Guides styling implementation using TailwindCSS + CSS Modules. Triggered when handling component styles, layout design, or CSS patterns.

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

Specialized for translating document files and their content into English. Triggered when localization, translation, or converting Chinese documents to English is requested.

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

i18n

Free

Guides internationalization (i18n) implementation using i18next with TypeScript. Triggered when handling localization, translation files, or multilingual support.

The English summary is being prepared. Showing the original description.

MatrixAges/polywise662Updated Jun 11, 2026

See all skills by MatrixAges

Report a problem with this skill