/electra-one:dev-electra-onefrom electra-one
Provides Electra One MIDI controller (MK2/Mini) Lua API quirks, project conventions, and mandatory pre-coding steps. Prevents silent rendering failures by enforcing HOWTO.md review before writing or modifying widget code.
Ships in electra-one. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are about to work on the Electra One MK2 MIDI controller — a programmable
device whose Lua API and firmware behave in several non-obvious ways. This
skill exists because we have lost hours, multiple times, rediscovering things
that are already documented in HOWTO.md or in this skill. Do not start
typing Lua before you've read the relevant material.
Trust the documented quirks. Most of them are silent failures: the widget renders as a default blue fader fallback, with no error in the browser console because the logger is off by default. By the time you "see" the problem, your only feedback is a bug-report-shaped silence.
electraone-widgets project workspace has a local mirror of
docs.electra.one at .electra-docs/md/ (79 pages, including the
entire Lua crash course) indexed by RTFM. Use
mcp__rtfm__rtfm_search "<query>" to find relevant sections,
mcp__rtfm__rtfm_expand to read them. The official docs ARE the
source of truth — most behaviours we previously thought were
"undocumented gotchas" turn out to be explicitly described once you
grep the right page.HOWTO.md sections 1 and 2 for the
workflow we use (custom-paint pattern, Firestore PATCH push).MEMORY.md entry project_e1_device_gotchas for any
firmware-specific quirks learned that aren't in the docs.If a piece of behaviour isn't covered in those documents and you have to
figure it out from scratch, add it back to HOWTO.md before
considering the work done. Don't invent gotchas from intuition — grep
the local doc mirror first.
These are the things the official docs at docs.electra.one/developers/luaext.html
either don't say or don't make obvious. Treat every one of these as a hard
constraint, not a recommendation — most cause silent fallback to the default
blue fader rendering.
graphics.print(x, y, text, width, alignment)
-- alignment ∈ { LEFT, CENTER, RIGHT } (global constants)
graphics.drawText does not exist. Calling it raises
attempt to call a nil value (field 'drawText') at paint time. For natural
LEFT-aligned text where you've already computed x, pass a large width
(e.g. 9999) so it never truncates.
Pass 0xRRGGBB 24-bit integers. The firmware (4.1.4+) handles the RGB565
conversion internally. Do not pre-convert to RGB565 — the v4.1.4 release
notes specifically fixed RGB888→RGB565 translation, so what worked before
might surprise you now.
Theme.ACCENT = 0xE5823E -- correct
-- Theme.ACCENT = 0xE407 -- WRONG, this is RGB565 reinterpreted as RGB888 → blue-ish
Every graphics.fillRect / drawRect / drawLine / fillCircle / drawCircle / print argument must be an integer. A float coordinate raises
number has no integer representation and aborts the paint callback. Any
expression involving a / N division produces a float — wrap it in
math.floor(...). The Theme.rect / outline / line helpers in
lib/theme.lua already do this internally; coordinates passed direct to
graphics.* do not.
local b = ctrl:getBounds()
local w, h = b[WIDTH], b[HEIGHT] -- WIDTH=3, HEIGHT=4, X=1, Y=2
Touch event types are global constants:
DOWN, MOVE, UP, CLICK, DOUBLECLICK. Yes, CLICK and
DOUBLECLICK are dispatched natively by the firmware — you don't need to
implement a click-detection state machine in Lua. Touch coordinates
event.x / event.y arrive in tile-local coordinates (origin at the
top-left of the tile's bounds).
ctrl:setPotCallback(function(ctrl, ev)
-- ev.id = 0-indexed pot number IN THE CALLBACK (0..11), even though
-- the doc and the JSON `inputs[].potId` use 1..12. This
-- off-by-one between doc and runtime is confirmed.
-- ev.type = DOWN | MOVE | UP (same constants as touch)
-- ev.delta = signed integer; 0 when no rotation (DOWN/UP frames)
end)
inputs[] is IGNORED for type:"custom" tiles. Tested 2026-05-25
on firmware 4.1.4: declaring 2 entries {potId: 1, valueId: "step"} +
{potId: 2, valueId: "edit"} on a custom tile produces NO Lua
callback events AND no USB MIDI traffic when the user rotates those
extra pots. The multi-input mechanism documented for ADSR/fader
controls (see presetformat.md "an ADSR control with multiple values
assigned") does NOT apply to custom controls. This is the exact
blocker for the NewIgnis spec — feature request #4172.
Each custom tile receives exactly one pot. Which pot it is depends
on the tile's slotId. Observed mapping on a default-configured MK2:
slotId: 0 (top row, full-width) → receives ev.id = 6
(= leftmost pot of the bottom physical row)slotId: 6 (second row, full-width) → receives ev.id = 0
(= leftmost pot of the top physical row)So the firmware delivers each tile's pot from the OPPOSITE physical row. The other 10 pots produce nothing for this tile (no callback, no MIDI). If "top pot controls top lane" matters for UX, route the action manually in your potCallback (cross-dispatch):
local sourceId = ctrl:getId()
local targetId = (sourceId == 1) and 2 or 1
-- operate on lanes[targetId] / selectedStep[targetId]
Encoder press not distinguishable from rotation start.
events.onPotTouchChange(potId, controlId, touched) fires on
capacitive touch but cannot tell "pressed without turning" from
"started to turn". Forum threads #4116 and #4185 confirm: no
onPotClick. For a click-without-rotation gesture, track a
rotatedDuringTouch flag (set true on MOVE, reset on DOWN) and treat
UP-without-MOVE as click. Even this is fiddly — the user has to be
quite gentle to avoid an accidental tiny rotation.
parameterMap.onChange is a global function you DEFINE (like
preset.onLoad), not one you call:
function parameterMap.onChange(valueObjects, origin, midiValue)
for i, vo in ipairs(valueObjects) do
local ctrl = vo:getControl()
print(string.format("changed: %s.%s = %d",
ctrl:getName(), vo:getId(), midiValue))
end
end
Trying to call parameterMap.onChange(vo, callback) raises
"attempt to call a nil value (field 'onChange')" — there is no such
method. The dispatch is automatic: the firmware invokes the global
when any ParameterMap entry changes (from MIDI in, from a pot mapped
via inputs, from parameterMap.set, etc.).
origin is one of the documented enum values (ORIGIN_LUA,
ORIGIN_MIDI, etc. — see .electra-docs/md/developers/luaext.md for
the full list). Use it to skip echoing your own writes.
setTouchCallback fires reliably when the tile occupies the slot the
firmware expects. If you reposition a tile via setBounds to a different
visual area, the firmware still dispatches touches by slotId, not by the
new bounds. event.x / event.y will then arrive in the original slot's
coordinate space, hit-tests calculated against ctrl:getBounds() (which
returns your overridden bounds) will miss, and tap-to-select silently does
nothing. Resolution: pick slotId values that match where you want the
tile, and only use setBounds to enlarge (e.g. to stretch a 1-slot tile
to fullpage), not to relocate.
The project's scripts/bundle-preset.js concatenates lib/theme.lua +
selected lib/primitives/*.lua + the widget's widget.lua into the
preset's lua field for device upload. Key rules learned the hard way:
Theme = (function() local Theme = {} ... return Theme end)()
fails silently on device: closures inside the IIFE lose their upvalues
after the load chunk completes, callbacks fall back, blue bar appears.
Use flat concatenation: theme.lua declares Theme = Theme or {} at the
top, drops return Theme, and primitives rewrite local function name
to function Theme.name.local g = graphics at module top level. Same closure problem.
Reference graphics directly inside each helper.>> << & | (Lua < 5.3). If you need the
RGB565 conversion, precompute the values in the bundler in Python/JS.paintLane, touchLane, potLane must be declared as top-level globals
(function paintLane(ctrl) ... end), not as local closures captured by a
factory or IIFE. A control:setPaintCallback(localFn) where localFn is a
closure with upvalues falls back to default fader rendering after the chunk
loads. Per-tile state lives in global tables keyed by ctrl:getId():
lanes = { [1] = {...}, [2] = {...} }
selectedStep = { [1] = 1, [2] = 1 }
dragging = { [1] = nil, [2] = nil }
muted = { [1] = {}, [2] = {} }
Clone XT envelopes (GK6wmbgvwM6S3GanpoN7) as a template — its single
custom tile renders correctly on device. Minimum tile fields:
{
"id": "<uuid>",
"reference": 1,
"slotId": 0,
"type": "custom",
"deviceId": 1,
"color": "F45C51",
"name": "MyTile",
"categoryId": "control",
"values": [{"message": {"type":"virtual","deviceId":1,"parameterNumber":99}}],
"visible": true,
"span": "6",
"vspan": 1
}
Device JSON needs instrumentId: "generic-controls":
"devices": [{"id":1, "name":"Generic MIDI", "instrumentId":"generic-controls", "port":1, "channel":1}]
slotId is 0-indexed. Top-left = slotId: 0; second row left =
slotId: 6 on the MK2 6×6 grid.span:"6" (string) only reliably enlarges the FIRST custom tile in
the JSON. A second tile with span:"6" often renders as a single slot.
Workaround: call ctrl:setBounds({...}) for every tile in preset.onLoad.print(...) is the only way to write to the Lua tab's log window. The
logger is OFF by default ("for performance reasons", per the docs) —
the user has to enable it in the Lua tab UI before any print or fatal-
error stack trace will appear. Firmware 4.1.4 added a fatal-error handler
that prints debug + stack trace to the logger; harvest those when
diagnosing silent failures.
controller.uptime() returns ms since boot — the only time API. Use it
for double-click detection between events, debouncing, etc.
This is the fast path to test changes on hardware. The full step-by-step
is in HOWTO.md section 2; the short version:
# 1. Extract the public Firebase API key from a fresh app.electra.one bundle
FIREBASE_API_KEY=$(for js in $(curl -s https://app.electra.one/presets/ | grep -oE '/_nuxt/[a-z0-9]+\.js' | sort -u); do
curl -s "https://app.electra.one$js" | grep -oE 'AIza[0-9A-Za-z_-]{35}'
done | sort -u | head -1)
# 2. Auth (use $ELECTRA_PASSWORD env var, do NOT commit the password)
TOKEN=$(curl -s -X POST \
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=$FIREBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-raw "{\"email\":\"$ELECTRA_EMAIL\",\"password\":\"$ELECTRA_PASSWORD\",\"returnSecureToken\":true}" \
| python3 -c "import sys,json;print(json.load(sys.stdin)['idToken'])")
# 3. PATCH the preset (scratch preset id is in MEMORY.md / HOWTO.md)
curl -s -X PATCH \
"https://firestore.googleapis.com/v1/projects/electra-one-716c4/databases/(default)/documents/projects/$PRESET_ID?updateMask.fieldPaths=project&updateMask.fieldPaths=name&updateMask.fieldPaths=schemaVersion&updateMask.fieldPaths=revision" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
--data-binary @payload.json
Then the user hard-refreshes app.electra.one/preset/$PRESET_ID (Ctrl+Shift+R
— the Nuxt cache is stubborn) and clicks Upload.
Bump the project's revision integer each push. Put a WIDGET_REV constant
at the top of the widget Lua so the on-screen header shows which version is
currently loaded — saves a round of "did the upload actually happen" questions.
Theme.ELEVATED background + Theme.TEXT
outline + a 2-px Theme.TEXT top edge as the signature marker. This is
consistent across step-seq-16, modern-adsr, eq-3band, etc.Theme.TEXT_DIM UPPERCASE on the
left, hairline Theme.line(..., Theme.BORDER) underneath, live state /
value readout on the right in the lane's accent colour.If you're adding a new widget, copy the structure of an existing one
(step-seq-16 is the canonical reference for grids; modern-adsr for
graph-based widgets) before improvising.
rtfm_search "<term>" on the project workspace. The
official Electra One docs are mirrored locally at
.electra-docs/md/ (scraped from docs.electra.one, 79 pages) and
indexed by RTFM. Faster and more complete than going through
WebFetch (which often returns the SPA shell with no content).widgets/<slug>/widget.lua — example implementations, all rendered in
the emulator. widgets/note-list-16/ is the one device-validated
custom-paint widget at firmware 4.1.4.widgets/xt-envelopes/ — single custom tile, known to also work on
device. Useful as a minimal reference for preset JSON structure.docs.electra.one/developers/luaext.html and the rest of the
developers/ section — official API. Mirror in .electra-docs/md/
is grep-able and complete.docs.electra.one/luacourse/ — MIDI & Lua crash course (chapters on
dec/hex, MIDI messages, RPN/NRPN, SysEx, bit operations, Lua values /
conditions / loops / tables / functions / modules / objects). Often
the best place to learn the idioms the API expects, not just what
exists. Mirror in .electra-docs/md/luacourse/.forum.electra.one — limits and gotchas not in the official docs.
Key threads: #4172 (multi-value custom controls — partially
implemented, web editor doesn't expose yet), #4116 / #4185 (encoder
press not detectable), #4058 (silent Lua compilation failure at
~265 KB on firmware 4.1.2), #4259 (firmware 4.1.4 release notes:
added fatal-error Lua handler, fixed RGB888→RGB565 translation,
fixed memory leak in controls.get()).The MCP can push any widget in this repo to the device with a single command:
python3 server/win_bridge.py upload-preset \
--preset widgets/step-seq-16/demo.preset.json \
--port "MIDIOUT3 (Electra Controller)" \
--bank 0 --slot 0 --mode simple
What happens under the hood (the pipeline mirrors what app.electra.one does internally):
tiles schema → call preset_converter.split_preset_for_upload() to produce (preset_json_bytes_in_controls_schema, lua_bytes).09 08 bank slot Switch Preset Slot — arm target.01 01 <preset.json> Upload Preset — small (< 1 KB once Lua is stripped), goes in one SysEx without fragmentation issues.01 0C <main.lua> Upload Lua Script — the entire bundled Lua (~40 KB for step-seq-16).09 08 bank (slot XOR 1) then 09 08 bank slot. 08 08 Reload Preset Slot NACKs on firmware 4.1.4 in our tests, so we use this trick instead to force a cold re-init.Each step waits for ACK on the CTRL input port; NACK aborts.
The converter (server/preset_converter.py) is a Python port of projectToPreset from app.electra.one's JS bundle (0c61af0.js, offset ~127000–131000) plus the MK2 6×12 layout math (slotIdToBounds, slotIdToPot, slotIdToSet, slotIdToPageId) at offset ~159200. Verified byte-identical against a live sniff (slotId=1, span=undef → bounds=[181,6,158,16], potId=8).
The widget files in electraone-widgets/widgets/*/demo.preset.json use a "new" schema (schemaVersion, tiles[], targetDevice, firstPageId, categoryId). None of those keys appear in presetformat.html. The device firmware parses the documented schema only: version (numeric) + pages + devices + overlays + groups + controls[]. Pushing the raw "tiles" JSON via 01 01 ACKs at the transport level but the preset parser silently rejects the structure, and the screen stays empty.
MIDIOUT3 (Electra Controller) ↔ MIDIIN3 (Electra Controller) = USB port 3 = CTRL (admin, file transfer, events).MIDIOUT2 / MIDIIN2 = port 2; bare Electra Controller = port 1.MHDR_DONE races the driver write-back → reads return F0 followed by zeros. Use CALLBACK_FUNCTION with WINFUNCTYPE so the driver only hands you a complete buffer.hdr.lpData as c_char_p truncates at the first NUL. Electra SysEx contains 0x00 right after F0. Keep the ctypes.create_string_buffer allocations Python-side and slice buffers[i].raw[:n] directly.See server/win_bridge.py in electra-one-mcp for the full impl.
01 01 Upload Preset works fine for our converted presets (< 1 KB without inlined Lua).01 0C Upload Lua with ~40 KB Lua source works in a single SysEx on this hardware over MIDIOUT3 — driver behaviour varies by host, see HOWTO for caveats.01 2D / 2E / 2F / 04 2D) is implemented but not the recommended path for preset+lua: the docs scope it to firmware / lua modules / multi-file atomic deploys; preset commit silently rolls back. Forum #592 reaches the same conclusion.08 08 Reload Preset Slot returns NACK on 4.1.4 — use the slot-flip trick instead.7E 02 bank slot and 7E 08 bank events on the CTRL port. The MCP will expose a device_state tool for this once Phase C of the rollout ships.Port to Windows MIDI Services 1.0 (in-box service Microsoft shipped to Win 11 24H2 in Feb 2026; replaces winmm.dll) via winsdk/pywinrt. Not blocking — the current pipeline works — but it sidesteps USB-MIDI 1.0 fragmentation entirely.
When the user asks to do anything against a real device, prefer the MCP tools below over raw SysEx — they handle the WSL↔Windows bridge, ACK verification, and error reporting.
| Need | Tool | Typical call |
|---|---|---|
| Push a widget to the device | push_to_device | push_to_device(preset_path="widgets/X/demo.preset.json", bank=0, slot=0) |
| Run a Lua snippet (REPL) | execute_lua | execute_lua("print(parameterMap.get(99))") |
| Read current device state | device_state | device_state(seconds=2) — returns last-known bank/slot/page + recent events + log |
| Download main.lua from a slot | get_lua_source | get_lua_source(bank=0, slot=0) |
| Subscribe to richer events | subscribe_events | subscribe_events(["pots", "touch", "button"]) |
| Capture device state back to repo | pull_preset | pull_preset(bank=0, slot=0, out_path="widgets/X/demo.preset.json") |
| Upload secondary files | upload_devices_overrides / upload_persisted_data / upload_performance | path to JSON |
| Upload reusable Lua module | upload_lua_module | upload_lua_module(path, namespace="roomi", name="theme") |
| Clear a slot | clear_preset_slot | clear_preset_slot(bank=0, slot=0) |
| Query firmware/serial | device_status | — |
| Tail device log | get_device_logs | get_device_logs(seconds=5) |
| Bundle theme+primitives+widget | bundle_widget | — |
| Validate a preset offline | validate_preset | — |
| Search official docs | search_docs / get_api / list_constants | — |
| Look up any SysEx command | get_sysex_command | get_sysex_command(query="snapshot") — 62 commands |
| Render preset to PNG via emulator | screenshot_widget | — |
Typical iteration loop while developing a widget:
bundle_widget (offline, generates the Lua blob)validate_preset (offline, catches schema/coord errors before push)push_to_device → reload happens automatically (slot-flip trick)device_state + execute_lua to inspect/debugwidget.lua → loop back to step 1pull_preset when device state has drifted ahead of reporev X (your WIDGET_REV constant) but interactions do
nothing → callbacks attached but firmware isn't dispatching events to
them. Most likely cause: tile was repositioned via setBounds away
from its slotId, or the tile only has one values[] entry so only one
pot is mapped.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
Generated from the plugin's indexed repository (roomi-fields/electra-one-mcp) — no native marketplace selected
npx claudepluginhub p/roomi-fields-electra-one