update-openclaw-bundle
Skill325 starsChanged 7 months agoMITView on GitHub
Update and maintain the Electron desktop OpenClaw bundle script (prepare-openclaw-bundle.mjs). Use when openclaw core dependencies change, new native/CJS packages are added, esbuild bundling breaks, or the bundle size grows unexpectedly.
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 11 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 46
Use policy for stable/manual intent.
- Distinctive: line 47
Use generated for auto-learned externals from real build failures.
- Distinctive: line 52
Purpose: Remove large unused packages before bundling.
- Distinctive: line 54
Only prune packages that are optional peerDeps or dev-only tools.
- Very specific: line 64
Purpose: Remove docs/tests/configs from node_modules.
- Very specific: line 77
Verify already prepared bundle: npm run verify:openclaw-bundle
- Distinctive: line 97
Check whether adaptive externals were logged.
- Distinctive: line 100
If still failing, add a stable wildcard or package to policy.
- Very specific: line 110
Check generated externals and policy coverage for X.
- Distinctive: line 111
If missing, refresh generated externals.
- Very specific: line 112
If recurrent, promote X to policy.
- Distinctive: line 119
Avoid pruning runtime-critical packages.
- Very specific: line 124
Do NOT modify files outside apps/electron-desktop/
- Distinctive: line 126
Keep policy small and intentional.
- Distinctive: line 127
Prefer generated refresh over manual list edits when possible
- Distinctive: line 128
When manual changes are required, document why the package must stay external
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Updating prepare-openclaw-bundle.mjs
This skill guides you through updating the bundle preparation script at
apps/electron-desktop/scripts/prepare-openclaw-bundle.mjs after OpenClaw
core dependency changes.
Architecture Overview
The script builds a self-contained OpenClaw bundle for the Electron desktop app:
- Build —
pnpm build+pnpm ui:build - Deploy —
pnpm deploycopies production deps tovendor/openclaw/ - Hoist — lifts
.pnpm/node_modules/to root (Windows NSIS compat) - Prune — removes heavy unused packages (node-llama-cpp, koffi, typescript)
- Strip — removes docs/tests/typedefs from node_modules
- Bundle entry.js — esbuild inlines most deps into a single file using adaptive externals fallback
- Analyze dist/ subdirs — parser-based esbuild graph pass discovers package usage and top-level chunk references
- Tree-shake node_modules — removes
.pnpmentries not reachable from externals - Bundle extensions — each extension becomes a single file (skipped in safe mode)
- Verify — post-bundle runtime checks ensure the bundle is executable and critical packages resolve
Key design: only external packages remain in node_modules. External resolution is now:
- manual policy (
ESBUILD_EXTERNALS_POLICY) - generated list (
openclaw-bundle-generated-externals.json) - adaptive externals learned during bundling
Source of Truth
1. Externals policy + generated list
Policy location: apps/electron-desktop/scripts/lib/openclaw-bundle-config.mjs
Generated location: apps/electron-desktop/scripts/lib/openclaw-bundle-generated-externals.json
A package must be external if it matches any of:
- Contains native
.nodebinaries (e.g.sharp,sqlite3,node-pty) - Uses dynamic
require()that breaks when bundled (e.g.yaml,grammy,jiti) - Has complex module structure esbuild can't handle (e.g.
express,zod)
Use policy for stable/manual intent. Use generated for auto-learned externals from real build failures.
2. PRUNE_PREFIXES / PRUNE_LINK_NAMES / PRUNE_SCOPED_NAMES
Location: apps/electron-desktop/scripts/lib/openclaw-bundle-config.mjs
Purpose: Remove large unused packages before bundling.
Only prune packages that are optional peerDeps or dev-only tools.
3. NODE_BUILTINS
Location: apps/electron-desktop/scripts/lib/openclaw-bundle-config.mjs
Purpose: Node.js built-in modules. Update only on Node major version change.
4. STRIP_* lists
Location: apps/electron-desktop/scripts/lib/openclaw-bundle-config.mjs
Purpose: Remove docs/tests/configs from node_modules. Almost never needs updating.
5. ALWAYS_KEEP_PACKAGES / CRITICAL_RUNTIME_PACKAGES / SMOKE_COMMANDS
Location: apps/electron-desktop/scripts/lib/openclaw-bundle-config.mjs
Purpose: Guardrails for runtime safety after aggressive pruning/bundling.
Commands
- Prepare bundle (default):
npm run prepare:openclaw - Prepare bundle in strict CI mode (fails on adaptive externals):
npm run prepare:openclaw:ci - Verify already prepared bundle:
npm run verify:openclaw-bundle - Refresh generated externals file from real build behavior:
npm run refresh:openclaw-externals
Environment Flags
OPENCLAW_BUNDLE_SAFE_MODE=1
Skip aggressive prune and extension rebundling.OPENCLAW_BUNDLE_SKIP_VERIFY=1
Skip final runtime verification.OPENCLAW_BUNDLE_WRITE_GENERATED_EXTERNALS=1
Persist adaptive externals to generated JSON.OPENCLAW_BUNDLE_STRICT_EXTERNALS=1
Fail if adaptive externals were required (used in CI).
Diagnosis Workflows
Case A: esbuild fails while bundling entry.js
- Check whether adaptive externals were logged.
- Run
npm run refresh:openclaw-externals. - Re-run
npm run prepare:openclaw:ci. - If still failing, add a stable wildcard or package to policy.
Case B: strict CI fails with adaptive externals
- Run
npm run refresh:openclaw-externals. - Commit
openclaw-bundle-generated-externals.json. - Re-run CI mode.
Case C: app crashes with "Cannot find module X"
- Check generated externals and policy coverage for
X. - If missing, refresh generated externals.
- If recurrent, promote
Xto policy. - Verify with
npm run verify:openclaw-bundle.
Case D: bundle size grows unexpectedly
- Audit heavy entries under
.pnpm. - Confirm the package is truly optional before adding to
PRUNE_*. - Avoid pruning runtime-critical packages.
- Re-run verification.
Important Notes
- Do NOT modify files outside
apps/electron-desktop/ - The script is idempotent — safe to re-run
- Keep policy small and intentional; generated list handles drift
- Prefer generated refresh over manual list edits when possible
- When manual changes are required, document why the package must stay external
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- extensions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- extensions/CLAUDE.mdCLAUDE.md
- openclaw-ghsa-maintainerSkill
- openclaw-parallels-smokeSkill
- openclaw-pr-maintainerSkill
- openclaw-qa-testingSkill
- openclaw-release-maintainerSkill
- openclaw-test-heap-leaksSkill
- parallels-discord-roundtripSkill
- security-triageSkill
- 1passwordSkill
- apple-notesSkill
- apple-remindersSkill
- bear-notesSkill
- blogwatcherSkill
- blucliSkill
- bluebubblesSkill
- camsnapSkill
- canvasSkill
- clawhubSkill
- coding-agentSkill
- discordSkill
- eightctlSkill
- geminiSkill
- gh-issuesSkill
- gifgrepSkill
- githubSkill
- gogSkill
- goplacesSkill
- healthcheckSkill
- himalayaSkill
- imsgSkill
- mcporterSkill
- model-usageSkill
- nano-pdfSkill
- node-connectSkill
- notionSkill
- obsidianSkill
- openai-whisper-apiSkill
- openai-whisperSkill
- openhueSkill
- oracleSkill
- ordercliSkill
- peekabooSkill
- sagSkill
- session-logsSkill
- sherpa-onnx-ttsSkill
- skill-creatorSkill
- slackSkill
- songseeSkill
- sonoscliSkill
- spotify-playerSkill
- summarizeSkill
- taskflow-inbox-triageSkill
- taskflowSkill
- things-macSkill
- tmuxSkill
- trelloSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

