Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Build and bundle native Node.js addons for Electron with proper ABI compatibility, cross-compilation support, and rebuild automation
.claude/skills/a5c-ai-electron-native-addon-builder/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 28% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 29% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 73% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 30% | 0% |
Build and bundle native Node.js addons for Electron with proper ABI (Application Binary Interface) compatibility. This skill handles the complexity of native module compilation, cross-platform building, and ensuring modules work correctly with Electron's Node.js version.
json{ "type": "object", "properties": { "projectPath": { "type": "string", "description": "Path to the Electron project root" }, "nativeModules": { "type": "array", "description": "List of native modules to handle", "items": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "source": { "enum": ["npm", "local", "github"] } } } }, "electronVersion": { "type": "string", "description": "Target Electron version" }, "targetPlatforms": { "type": "array", "items": { "enum": ["win32", "darwin", "linux"] } }, "targetArchitectures": { "type": "array", "items": { "enum": ["x64", "arm64", "ia32"] } }, "useNAPI": { "type": "boolean", "description": "Use N-API for version-independent builds", "default": true }, "prebuildConfig": { "type": "boolean", "description": "Generate prebuild configuration", "default": false } }, "required": ["projectPath"] }
json{ "type": "object", "properties": { "success": { "type": "boolean" }, "configuration": { "type": "object", "properties": { "electronRebuild": { "type": "object" }, "nodeGyp": { "type": "object" }, "packageJson": { "type": "object" } } }, "scripts": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "command": { "type": "string" } } } }, "warnings": { "type": "array", "items": { "type": "string" } } }, "required": ["success"] }
json// package.json { "scripts": { "postinstall": "electron-rebuild", "rebuild": "electron-rebuild -f -w native-module-name" }, "devDependencies": { "@electron/rebuild": "^3.6.0" } }
bash# Set Electron headers for node-gyp export npm_config_target=28.0.0 export npm_config_arch=x64 export npm_config_target_arch=x64 export npm_config_disturl=https://electronjs.org/headers export npm_config_runtime=electron export npm_config_build_from_source=true npm install native-module
yaml# electron-builder.yml npmRebuild: true buildDependenciesFromSource: true nodeGypRebuild: false asarUnpack: - "**/*.node" - "**/node_modules/native-module/**"
N-API provides ABI stability across Node.js versions:
javascript// binding.gyp for N-API module { "targets": [ { "target_name": "native_module", "sources": ["src/native_module.cc"], "include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ], "dependencies": [ "<!(node -p \"require('node-addon-api').gyp\")" ], "defines": ["NAPI_VERSION=8", "NAPI_DISABLE_CPP_EXCEPTIONS"] } ] }
For distributing prebuilt binaries:
json// package.json { "scripts": { "prebuild": "prebuild -t 28.0.0 -r electron -a x64 -a arm64", "prebuild-upload": "prebuild --upload-all $GITHUB_TOKEN" }, "devDependencies": { "prebuild": "^12.1.0", "prebuild-install": "^7.1.1" } }
bash# Using electron-rebuild with wine npx @electron/rebuild --platform=win32 --arch=x64 # Or with prebuild prebuild -t 28.0.0 -r electron --platform=win32 --arch=x64
bash# Requires Xcode and arm64 toolchain npx @electron/rebuild --arch=arm64
bash# Using Docker docker run -v $(pwd):/project electron-builder-linux \ npx @electron/rebuild --platform=linux --arch=x64
| Module | Use Case | N-API Support | |--------|----------|---------------| | better-sqlite3 | SQLite database | Yes | | sharp | Image processing | Yes | | node-pty | Terminal emulation | Yes | | serialport | Serial communication | Yes | | robotjs | Desktop automation | Limited | | node-hid | USB HID devices | Yes |
Error: The module was compiled against a different Node.js versionSolution: Rebuild with correct Electron version:
bashnpx @electron/rebuild -v 28.0.0
Windows: Install Visual Studio Build Tools
bashnpm install -g windows-build-tools
macOS: Install Xcode Command Line Tools
bashxcode-select --install
Linux: Install build-essential
bashsudo apt-get install build-essential
bash# Specify Python version for node-gyp npm config set python /usr/bin/python3
electron-builder-config - Package native modules correctlyelectron-main-preload-generator - Secure native module usagecross-platform-test-matrix - Test native modules across platformselectron-architect - Architecture for native modulesdesktop-ci-architect - CI/CD for native module builds| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-06 | pass→pass | 11,433 | 10,156 | -11% | 1 | 1 | 0% | 2,233 | 3,870 | +73% | 0 | 0 | — |
case-01 | fail→pass | 15,285 | 14,758 | -3% | 1 | 1 | 0% | 3,289 | 4,513 | +37% | 0 | 0 | — |
case-02 | fail→pass | 15,262 | 12,781 | -16% | 1 | 1 | 0% | 3,299 | 4,225 | +28% | 0 | 0 | — |
case-03 | fail→pass | 13,952 | 8,070 | -42% | 1 | 1 | 0% | 2,832 | 3,660 | +29% | 0 | 0 | — |
case-04 | pass→pass | 16,470 | 10,924 | -34% | 1 | 1 | 0% | 3,233 | 4,208 | +30% | 0 | 0 | — |
case-05 | pass→pass | 15,824 | 11,406 | -28% | 1 | 1 | 0% | 2,715 | 4,268 | +57% | 0 | 0 | — |
case-07 | pass→pass | 13,923 | 7,454 | -46% | 1 | 1 | 0% | 2,788 | 3,450 | +24% | 0 | 0 | — |
case-08 | pass→pass | 9,422 | 6,551 | -30% | 1 | 1 | 0% | 1,753 | 3,055 | +74% | 0 | 0 | — |
case-09 | pass→pass | 7,640 | 4,806 | -37% | 1 | 1 | 0% | 1,628 | 2,865 | +76% | 0 | 0 | — |
case-10 | pass→pass | 15,086 | 4,965 | -67% | 1 | 1 | 0% | 1,234 | 2,911 | +136% | 0 | 0 | — |
case-11 | pass→pass | 6,744 | 3,503 | -48% | 1 | 1 | 0% | 1,032 | 2,499 | +142% | 0 | 0 | — |
case-12 | fail→fail | 6,039 | 5,377 | -11% | 1 | 1 | 0% | 1,011 | 2,661 | +163% | 0 | 0 | — |
case-13 | pass→pass | 3,858 | 1,937 | -50% | 1 | 1 | 0% | 626 | 2,186 | +249% | 0 | 0 | — |
case-14 | pass→pass | 2,601 | 2,343 | -10% | 1 | 1 | 0% | 379 | 2,248 | +493% | 0 | 0 | — |
case-15 | pass→pass | 7,683 | 6,119 | -20% | 1 | 1 | 0% | 1,488 | 2,931 | +97% | 0 | 0 | — |
case-16 | pass→pass | 10,878 | 5,843 | -46% | 1 | 1 | 0% | 1,907 | 3,024 | +59% | 0 | 0 | — |
case-17 | pass→pass | 11,476 | 7,070 | -38% | 1 | 1 | 0% | 2,007 | 3,215 | +60% | 0 | 0 | — |
case-18 | pass→pass | 14,567 | 11,710 | -20% | 1 | 1 | 0% | 2,616 | 4,053 | +55% | 0 | 0 | — |
case-19 | pass→pass | 10,221 | 7,571 | -26% | 1 | 1 | 0% | 1,973 | 3,309 | +68% | 0 | 0 | — |
case-20 | pass→pass | 8,033 | 3,819 | -52% | 1 | 1 | 0% | 1,408 | 2,553 | +81% | 0 | 0 | — |
case-21 | pass→pass | 5,250 | 3,535 | -33% | 1 | 1 | 0% | 944 | 2,543 | +169% | 0 | 0 | — |
case-22 | pass→pass | 4,742 | 2,871 | -39% | 1 | 1 | 0% | 851 | 2,475 | +191% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.