Token导航 LogoToken导航TokenDH.com
开发规范操作浏览器github未标认证来源可访问许可证需确认审计提醒

electrobun-best-practicesElectrobun 最佳实践

Agent Skill

electrobun-best-practices 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,678

周安装

158

GitHub Stars

43

下载量

1,289
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:electrobun-best-practices(Electrobun 最佳实践)
来源仓库:https://github.com/0xbigboss/claude-code
仓库路径:skills/electrobun-best-practices
安装命令:
npx skills add https://github.com/0xbigboss/claude-code --skill electrobun-best-practices
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/0xbigboss/claude-code --skill electrobun-best-practices

简介

electrobun-best-practices 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合让 Agent 持续沉淀问题、修正和最佳实践。

  • 适用于 Electrobun 桌面应用开发的安全默认值和类型安全 RPC 模式场景。
  • 提供版本管理、架构指导和文档验证等核心能力。
  • 安装命令:npx skills add https://github.com/0xbigboss/claude-code --skill electrobun-best-practices
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。

SKILL.md

Electrobun Best Practices

Electrobun builds cross-platform desktop apps with TypeScript and Bun. This skill gives safe defaults, typed RPC patterns, and operational guidance for build/update/distribution.

Docs: https://blackboard.sh/electrobun/docs/

Pair with TypeScript Best Practices

Always load typescript-best-practices alongside this skill.

Version and Freshness

Electrobun APIs evolve quickly. Before relying on advanced options or platform-specific behavior, verify against current docs and CLI output.

Architecture

Electrobun apps run as Bun apps:

  • Bun process (main): imports from electrobun/bun
  • Browser context (views): imports from electrobun/view
  • Shared types: RPC schemas shared between both contexts

IPC between bun and browser contexts uses postMessage, FFI, and (in some paths) encrypted WebSockets.

Quick Start

bunx electrobun init
bun install
bun start

Recommended scripts:

{
  "scripts": {
    "start": "electrobun run",
    "dev": "electrobun dev",
    "dev:watch": "electrobun dev --watch",
    "build:dev": "bun install && electrobun build",
    "build:canary": "electrobun build --env=canary",
    "build:stable": "electrobun build --env=stable"
  }
}

Secure Defaults

Use this baseline for untrusted or third-party content:

import { BrowserWindow } from "electrobun/bun";

const win = new BrowserWindow({
  title: "External Content",
  url: "https://example.com",
  sandbox: true,                  // disables RPC, events still work
  partition: "persist:external",
});

win.webview.setNavigationRules([
  "^*",                          // block everything by default
  "*://example.com/*",           // allow only trusted domain(s)
  "^http://*",                   // enforce HTTPS
]);

win.webview.on("will-navigate", (e) => {
  console.log("nav", e.data.url, "allowed", e.data.allowed);
});

Security checklist:

  • Use sandbox: true for untrusted content.
  • Apply strict navigation allowlists.
  • Use separate partition values for isolation.
  • Validate all host-message payloads from <electrobun-webview> preload scripts.
  • Do not write to PATHS.RESOURCES_FOLDER at runtime; use Utils.paths.userData.

Typed RPC (Minimal Pattern)

// src/shared/types.ts
import type { RPCSchema } from "electrobun/bun";

export type MyRPC = {
  bun: RPCSchema<{
    requests: {
      getUser: { params: { id: string }; response: { name: string } };
    };
    messages: {
      logToBun: { msg: string };
    };
  }>;
  webview: RPCSchema<{
    requests: {
      updateUI: { params: { html: string }; response: boolean };
    };
    messages: {
      notify: { text: string };
    };
  }>;
};
// bun side
import { BrowserView, BrowserWindow } from "electrobun/bun";
import type { MyRPC } from "../shared/types";

const rpc = BrowserView.defineRPC<MyRPC>({
  handlers: {
    requests: {
      getUser: ({ id }) => ({ name: `user-${id}` }),
    },
    messages: {
      logToBun: ({ msg }) => console.log(msg),
    },
  },
});

const win = new BrowserWindow({
  title: "App",
  url: "views://mainview/index.html",
  rpc,
});

await win.webview.rpc.updateUI({ html: "<p>Hello</p>" });
// browser side
import { Electroview } from "electrobun/view";
import type { MyRPC } from "../shared/types";

const rpc = Electroview.defineRPC<MyRPC>({
  handlers: {
    requests: {
      updateUI: ({ html }) => {
        document.body.innerHTML = html;
        return true;
      },
    },
    messages: {
      notify: ({ text }) => console.log(text),
    },
  },
});

const electroview = new Electroview({ rpc });
await electroview.rpc.request.getUser({ id: "1" });
electroview.rpc.send.logToBun({ msg: "hello" });

Events and Shutdown

Use before-quit for shutdown cleanup instead of relying on process.on("exit") for async work.

import Electrobun from "electrobun/bun";

Electrobun.events.on("before-quit", async (e) => {
  await saveState();
  // e.response = { allow: false }; // optional: cancel quit
});

Important caveat:

  • Linux currently has a caveat where some system-initiated quit paths (for example Ctrl+C/window-manager/taskbar quit) may not fire before-quit. Programmatic quit via Utils.quit()/process.exit() is reliable.

Common Patterns

  • Keyboard shortcuts (copy/paste/undo): define an Edit ApplicationMenu with role-based items.
  • Tray-only app: set runtime.exitOnLastWindowClosed: false, then drive UX from Tray.
  • Multi-account isolation: use separate partition values per account.
  • Chromium consistency: set bundleCEF: true and defaultRenderer: "cef" in platform config.

Troubleshooting

  • RPC calls fail unexpectedly:

- Check whether the target webview is sandboxed (sandbox: true disables RPC). - Confirm shared RPC types match both bun and browser handlers.

  • Navigation blocks legitimate URLs:

- Review setNavigationRules ordering; last match wins. - Keep ^* first only when you intentionally run strict allowlist mode.

  • Updater says no update:

- Verify release.baseUrl and uploaded artifacts/ naming ({channel}-{os}-{arch}-...). - Confirm channel/build env alignment (canary vs stable).

  • User sessions leak across accounts:

- Use explicit per-account partitions and manage cookies via Session.fromPartition(...).

  • Build hooks not running:

- Ensure hook paths are correct and executable via Bun. - Inspect hook env vars (for example ELECTROBUN_BUILD_ENV, ELECTROBUN_OS, ELECTROBUN_ARCH).

Reference Files

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

32.38%
按下载量换算417

Claude

28.27%
按下载量换算364

Cursor

20.74%
按下载量换算267

Gemini CLI

9.17%
按下载量换算118

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills