| name | electron-ipc-patterns |
| description | Electronプロセス間通信(IPC)パターンの設計と実装専門知識。 安全で効率的なMain-Rendererプロセス通信、contextBridge、型安全なAPI設計を提供。 Anchors: • Electron Security / 適用: contextBridge/preload設計 / 目的: セキュアなIPC実装 • Clean Architecture / 適用: Main/Renderer境界設計 / 目的: 責務分離と保守性 • Type Safety / 適用: TypeScript型契約 / 目的: IPC通信の型安全性確保 Trigger: Use when implementing IPC communication patterns, setting up contextBridge, designing typed IPC handlers, securing renderer-main communication, or structuring bidirectional messaging flows. ipcMain, ipcRenderer, contextBridge, invoke, handle, preload, typed IPC |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Electron IPC Patterns
概要
Electronプロセス間通信(IPC)パターンの設計と実装専門知識を提供。 Main-Rendererプロセス間の双方向通信、型安全なAPI設計、セキュアなcontextBridge実装を支援する。
ワークフロー
Phase 1: 要件分析とパターン選択
目的: IPC通信要件を整理し適切なパターンを選択
アクション:
- 通信方向(単方向/双方向/イベント駆動)を特定
- セキュリティ要件(context isolation必須)を確認
references/pattern-catalog.mdから適切なパターンを選択- 必要に応じて
agents/analyze-requirements.mdを参照
Phase 2: 型定義とAPI設計
目的: 型安全なIPC契約を設計
アクション:
assets/ipc-types-template.tsを使用してAPI型を定義- チャネル命名規則を適用(例:
app:feature:action) - 入力検証スキーマを設計
- 必要に応じて
agents/design-typed-api.mdを参照
Phase 3: 実装
目的: IPCハンドラとクライアントコードを実装
アクション:
assets/preload-template.tsを使用してcontextBridgeを実装- Mainプロセスハンドラを実装
- Rendererクライアントを実装
- 複雑な実装は
agents/implement-ipc-layer.mdを参照
Phase 4: セキュリティ検証
目的: セキュリティベストプラクティスを検証
アクション:
references/security-checklist.mdでセキュリティ確認- 必要に応じて
agents/security-review.mdを参照 scripts/log_usage.mjsで記録
Task仕様ナビ
| Task | 起動タイミング | 入力 | 出力 |
|---|---|---|---|
| analyze-requirements | IPC要件分析時 | 通信要件 | パターン推奨 |
| design-typed-api | API設計時 | 機能要件 | 型定義・契約 |
| implement-ipc-layer | 実装時 | API設計 | 実装コード |
| security-review | セキュリティ検証時 | 実装コード | セキュリティ報告 |
詳細仕様: 各Taskの詳細は agents/ ディレクトリの対応ファイルを参照
ベストプラクティス
すべきこと
- context isolation有効化: contextBridgeを必ず使用
- 型定義: TypeScriptでIPC契約を型定義
- 命名規則: チャネル名に一貫した規則(
app:feature:action) - invoke/handle: Promise-basedパターンを優先
- 入力検証: Mainプロセス側で必ず検証
- エラーハンドリング: 適切なタイムアウトと例外処理
避けるべきこと
- nodeIntegration有効化: セキュリティリスク
- ipcRenderer直接公開: Rendererからの直接アクセスを禁止
- any型使用: 型安全性を無視しない
- sendSync使用: 同期IPCは避ける
- 入力信頼: 外部入力は常にバリデーション
リソース参照
references/(詳細知識)
| リソース | パス | 用途 |
|---|---|---|
| IPCパターンカタログ | See references/pattern-catalog.md | パターン選択・比較 |
| セキュリティチェックリスト | See references/security-checklist.md | セキュリティ検証 |
scripts/(決定論的処理)
| スクリプト | 用途 | 使用例 |
|---|---|---|
log_usage.mjs |
フィードバック記録 | node scripts/log_usage.mjs --result success --phase "Phase 4" |
assets/(テンプレート)
| テンプレート | 用途 |
|---|---|
ipc-types-template.ts |
IPC型定義テンプレート |
preload-template.ts |
Preloadスクリプトテンプレート |
変更履歴
| Version | Date | Changes |
|---|---|---|
| 2.0.0 | 2026-01-01 | 18-skills.md仕様完全準拠、構造最適化 |
| 1.0.0 | 2025-12-31 | 初版作成 |