/lightkey-patcher:lightkey-patcherfrom Lightkey Patcher
Reads, inspects, and programmatically modifies macOS Lightkey lighting-control project files (.lightkeyproj), including the undocumented NSKeyedArchiver binary plist format. Includes Python helpers and CLI tools for building cues, presets, and control panels.
Ships in Lightkey Patcher. 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.
Programmatically read and modify .lightkeyproj files — the project format used by Lightkey, a macOS DMX lighting control app.
Lightkey's file format is not publicly documented. This captures a working understanding reverse-engineered from real project files, including the exact schemas, pitfalls, and patterns needed to generate files that Lightkey will actually open without crashing AND that render correctly in the Live panel.
Paths like docs/pitfalls.md and lightkey/resolve.py are relative to the root of this
plugin/repository — from this skill's own directory that is ../../docs/pitfalls.md and
../../lightkey/resolve.py. Read them with the Read tool as you need them; don't load all
five docs at once.
To use the Python from a working directory of your own, either add the repo root to
sys.path or copy lightkey/ next to your build script:
import sys; sys.path.insert(0, '<plugin-root>')
from lightkey.resolve import load, find_instances, classname
from lightkey.colour import pack_color, c8, unpack_rgb8
from lightkey.build import Builder, build_fpstore, mk_preset, mk_cue, mk_button
from lightkey.validate import Validator
Two CLI tools are bundled and should usually be your first move on a new file:
python3 tools/inspect_project.py <project>.lightkeyproj # structure, schema, groups
python3 tools/probe_colour.py <project>.lightkeyproj # prove the colour byte order
python3 tools/inspect_project.py <project>.lightkeyproj --midi # bindings, dead ones flagged
fpstore-format.md → Colour packing.pitfalls.md Bugs 21–23.patterns.md §21.Most requests after the first version are revisions: "change these colours", "this doesn't work",
"add two positions". Follow docs/update-workflow.md for those — ten stages, each with a gate:
pitfalls.md Bug 30).examples/revision/build_next.py.examples/revision/validate_next.py: structure, then
unchanged_except() (nothing you didn't name moved), then one check per claim.If the user wants hardware buttons for their cues, or the show already has a Stream Deck profile,
use the lightkey-streamdeck skill (skills/lightkey-streamdeck/SKILL.md,
docs/streamdeck-midi.md) after the show file is built. It reads every key's note, mode and latch
group from the show, so the deck can't disagree with it, and it refuses the key/trigger pairing that
crashed Lightkey on a rig. Don't build a profile unless asked.
.lightkeyproj (rename fixtures, restructure presets, replace the control panel).lightkeyproj, NSKeyedArchiver plist modification, DMX cue generation, native Lightkey effects, fpStoreThree phases per task. Follow them in order.
Always start by inspecting the user's existing .lightkeyproj before modifying it.
plistlib.load() (binary plist, plistlib handles it natively).lightkey/resolve.py — copy into your working directory and import resolve. lightkey/build.py is its write-side counterpart.umbrellaContainers (most files in the wild). Newer schema = containers/subcontainers (Effects Showcase). Flag to user if you encounter the newer schema — this documentation targets the old one.effects arrays. If yes, the file uses native Lightkey effects. You can clone those entries verbatim into new presets (see docs/fpstore-format.md). You cannot recolour them — the colours live in an opaque parameters blob. Build the user's own palette as a sequence instead (patterns.md §22).pitfalls.md Bug 22). Never reuse UIDs recorded in a previous session: Lightkey compacts $objects on save and every UID moves (Bug 23). Re-find everything by name.Read docs/archive-format.md first if you haven't worked with NSKeyedArchiver before.
Ask before building. The space of edits is huge. Typical axes:
Use whatever structured question tool your harness provides, if any. Present 2-4 concrete options per question — avoid open-ended asking.
For a redesign of an existing panel, the question that matters most is how much of their current arrangement to keep — offer "clean re-flow / keep my arrangement / full redesign" explicitly rather than assuming. Ask it even when the user says "make it better": muscle memory on a panel that gets run live is worth real money to them, and only they can price it.
The file being structurally correct is table stakes. What made the difference on a real venue rig:
patterns.md §18)Write a Python script that uses plistlib to load the archive, mutates $objects and $top, and writes back. Use the patterns from docs/patterns.md.
These were learned the hard way over many iteration cycles. Violate any of them and the file will either crash Lightkey on open or render an empty panel that looks broken.
Never overwrite top.rootPresetGroup. Lightkey uses the root tree to resolve panel buttons at runtime. Replacing it with an empty group makes the panel render as the empty-state placeholder. Preserve the original root; attach your new preset groups under a wrapper group prepended to its childNodes. See docs/pitfalls.md Bug 13.
Names are RAW STRINGS, not NSMutableString wrappers. The name field on every LXCue, LXPreset, LXPresetGroup, LXSequence, and LXControlPanel in real source files is a raw plist string (just archive['$objects'].append(text) — no class wrapper). Wrapping in NSMutableString causes Lightkey's strict decoder to silently reject the items. See docs/pitfalls.md Bug 14.
Never hardcode UID literals for cross-referenced objects (NSColor, NSAttributes dicts, NSFont, etc). UIDs are byte offsets into $objects and vary per source file. Walk for a real instance instead and reuse its UID. See docs/pitfalls.md Bug 15.
Reuse existing class definitions where possible. Don't mint duplicate $classname entries — every instance of LXCue should reference the same class def UID. Duplicating class defs causes NSKeyedUnarchiver to fail silently.
Reuse the empty NSArray and empty NSDictionary singletons that the source file already has. Creating fresh empty collections is harmless but introduces churn that makes diffing your output against the source much harder during validation.
activeSpeedModifiers is NSSet, not NSArray — even when empty. Same kind of strict-class-check bug as Bug 14.
metaModifiers and metaModifierDefaults should share a singleton — Lightkey writes them as the same empty NSDictionary UID, not two separate instances.
orphanPresetsGroup is unique per cue — mint a fresh LXRootPresetGroup for every cue you build; don't share it.
Adding NEW class definitions is risky but sometimes necessary. Only add a class def if (a) the class actually exists in Lightkey's codebase (verify by finding it in another reference project file), and (b) the instance can't be obtained any other way. Inventing class names that "sound right" silently crashes Lightkey on open.
Preserve the user's existing objects byte-for-byte where you can. On a reused LXCpanButton, rewrite rect and nothing else — never cue, behavior or colorName. See docs/pitfalls.md Bugs 21–22.
Add new presets to the user's EXISTING mutually-exclusive groups, not to parallel ones you create. Mutual exclusion ("rocker switch" behaviour) is a property of LXPresetGroup.presetsAreMutuallyExclusive, and it only applies within one group — a second group with the same intent does not interoperate. See docs/pitfalls.md Bug 25.
LXTextCanvasItem has no rect — it is center + unrotatedSize, and the text renders at its NSFont size regardless of the box you declare. Undersized boxes put text under your buttons. See docs/pitfalls.md Bug 24.
Every object reference you write must be a plistlib.UID instance. int(uid) is handy for dict keys, but a bare int written back into NS.objects (or cue, items, presets…) parses fine and makes Lightkey decode the whole array as empty — and it re-saves that emptiness if the user hits ⌘S. Validator.references_are_uids() is in structural_parity() now. See docs/pitfalls.md Bug 27.
One member per mutex group per cue. Exclusion is evaluated per preset, not per cue: two members of one cue in the same group can displace each other, members in different groups leave the cue half-active. Combined looks are one sequence/preset carrying all the values; a show block gets an EXIT cue with an exit member in every group it touched. See Bug 26 and docs/patterns.md §24.
Cues are referenced by UUID from MIDI/key bindings. Rebuilding a cue "fresh" silently disconnects the user's notes. Modify cues in place; check tools/inspect_project.py --midi before and after. See Bug 28.
Never append into a group whose childNodes is the shared empty-array singleton — build the member list first and mint the group last. See Bug 29.
LXCue.holdDuration finite → the cue releases itself (one-shots for MIDI/timeline senders). patterns.md §23.crossfadeDuration 0.0 sequences with ~60 ms steps run (hard-cut chases, strobe-by-sequence). §27.shutterState 2 + strobeSpeed = hardware strobe on fixtures whose personality has LXShutterStrobeCapability; 1 = open. There is no proven "closed" — off is intensity 0. fpstore-format.md.Structurally validate. Re-parse the output. Walk through and check:
LXCue / LXPreset / LXCpanButton / etc. has exactly the same key set as the source instance of that class.name fields on cues/presets/groups/sequences/panel are raw strings (use the script in docs/pitfalls.md Bug 14).top.rootPresetGroup is the SAME UID as in the source (it must not be replaced).Semantically validate — assert every claim you intend to make to the user. Structural parity says the file will open; it says nothing about whether it is usable. Re-parse the output and check geometry (zero overlap between button rects and label boxes), preservation (every source button still present with an unchanged cue), rockers (mutex flags still set, old group children still members), and colour (decode packed values back to RGB, bucket the hue, assert the family). docs/patterns.md §21 has the claim→assertion table. A 60+ assertion validator is proportionate for a file someone runs a live service on.
Never promise it will open in Lightkey. Structural validation catches some bugs but not all. Frame output as "should work, please test and send the crash log if it doesn't."
Ask for the crash log the first time something breaks. ~/Library/Logs/DiagnosticReports/Lightkey-*.ips. Thread 0 stack depth tells you whether it's an early decode failure (object shape wrong) or a late semantic failure (runtime logic).
Read docs/pitfalls.md before writing the first line of code — it's where the silent-failure bugs are documented.
Load these as needed — not all at once.
docs/archive-format.md — NSKeyedArchiver, $objects, $top, UID references. Always read this first before touching an archive.docs/class-schemas.md — Exact field schemas for every Lightkey class, plus MIDI/key bindings and fixture profiles/capabilities (how to tell from the file whether a fixture can strobe or has a white channel). Consult before building any of them. Note: as of this revision, the name field on LXCue / LXPreset / LXPresetGroup / LXSequence / LXControlPanel should be a RAW STRING UID (not an NSMutableString wrapper). The class-schemas doc may still show NSMutableString — defer to pitfalls.md Bug 14.docs/fpstore-format.md — The inner binary plist every LXPreset carries. Covers umbrellaContainers, the native effects array, colour packing (read this before any palette work), moving-head practicalities, the clone-and-retarget pattern.docs/patterns.md — Architectural patterns: radio groups, LTP layering, beat sequences, colour palettes, per-zone gradients, unified Stage Look mutex, priority stacks, momentary buttons, plus §17–§28: in-place redesign, mirror-pair gradients, collision-checked layout, composite event cues, output validation, palette-driven flows, one-shot cues, MIDI/timeline show blocks, twin flows, carving into an existing layout, strobes and hard-cut chases, moving-head position vocabulary.docs/pitfalls.md — Specific mistakes that have crashed Lightkey on open, made the panel render empty, or silently destroyed the user's own work. Read this BEFORE writing any code. Bugs 1–20 are decode/render failures; Bugs 21–29 are the ones that bite when rebuilding on a file the user has been editing (27: ints where UIDs belong, 28: bindings orphaned by rebuilt cues, 29: the shared empty-array singleton); Bugs 30–32 come from weekly revisions of a live show (30: a cue outranked by priority, 31: controller note-offs + "On/off" → feedback crash, 32: custom-capability index counted in array order).docs/update-workflow.md — The stage-by-stage loop for revising a show the user already runs: base file, diagnosis table, request → doc routing table, validation layers, hand-off.docs/streamdeck-midi.md — The Stream Deck add-on: how keys, the MIDI plugin, Lightkey's ports and feedback connect; which key mode pairs with which trigger behaviour; latch groups; the profile file format.lightkey/resolve.py — Reusable inspection library. find_instances(classname), resolve(uid, depth=N). Copy into your working directory and import resolve.lightkey/colour.py — pack_color / c8 / unpack_rgb8 (corrected byte order), anchor+variation palettes, sequence-step builders.lightkey/build.py — The Builder and every constructor this documentation's snippets call: build_fpstore, mk_preset, mk_seq_preset, mk_preset_group, mk_root_preset_group, mk_sequence, mk_cue, mk_button, mk_text_label, mk_cpan_frame. Appends to the source archive, reusing its class defs and empty-collection singletons; names are raw strings and no UID is hardcoded, so the rules above are satisfied by construction. Use this rather than re-deriving the key sets from class-schemas.md.lightkey/validate.py — Ready-made semantic validator (docs/patterns.md §21). Validator(src, out, panel=None) then structural_parity(), buttons_resolve(), preserved_buttons(), no_overlap(ignore_preexisting=True), labels_fit(), mutex_intact([...]), cue_in_group(), single_member_in(), one_shot(), fixtures_dark(), hues_within(), depth_stops(), movers_aim_high(), unchanged_except(presets, cues) (everything you didn't name is byte-for-byte the source), bindings_intact(), report(). Every check accumulates instead of raising, so one run shows every problem. Pass panel='Name' for files Lightkey 6 re-saved without selectedLivePanel. Verified against a real 92-button panel.lightkey/bindings.py — MIDI/keyboard bindings: list_bindings(), used_slots(), free_notes(), add_note_trigger() (clones a GUI-made binding; refuses a used note), set_behaviour(); TOGGLE/FLASH/ACTIVATE/DEACTIVATE. Channels are 1-based in this API.examples/revision/build_next.py + validate_next.py — Templates for a revision: refuse-to-overwrite, re-find by name scoped to a panel, edit in place, counted assertions; and the three-layer validator. Copy them to build_v<N>.py / validate_v<N>.py.tools/export_midi_map.py — The show's MIDI map as CSV (channel, note, cue, panel, group, behaviour, On/off, port); dead bindings show an empty cue.tools/inspect_project.py — CLI structure dump: object counts, fpStore schema flavour, native-effect histogram, preset groups with their mutex flags, cues, panels. --fixtures prints the short-name → UUID map; --panel details every button and label; --classes flags duplicate class definitions.tools/probe_colour.py — CLI that decodes every named colour preset under both byte orders and reports which one agrees with the preset names. Also flags presets whose stored colour contradicts their own name — those were written by a patcher with the wrong packing and render the wrong colour on real fixtures.tools/extract_effects.py — Pull native-effect blobs out of a reference project so they can be cloned verbatim.examples/build_dimmer_panel.py — Small end-to-end builder on top of lightkey/build.py: discovers fixtures, builds intensity-only presets, wires a mutually-exclusive group, attaches under the existing root, adds a panel. Read this before writing your own.import plistlib
from plistlib import UID
# 1. Load
with open('project.lightkeyproj', 'rb') as f:
archive = plistlib.load(f)
objects = archive['$objects']
top = archive['$top']
# 2. Inspect — find the existing control panel
panel_uid = int(top['selectedLivePanel'])
panel = objects[panel_uid]
items_ref = panel['items']
button_uids = objects[int(items_ref)]['NS.objects']
print(f'Panel has {len(button_uids)} items')
# 3. Inspect a sample preset's fpStore
preset = objects[int(button_uids[0])] # if it's a button
# ... navigate cue -> preset -> fpStore -> umbrellaContainers / effects
# 4. Modify — read docs/patterns.md for the patterns
# ...
# 5. Write
with open('output.lightkeyproj', 'wb') as f:
plistlib.dump(archive, f, fmt=plistlib.FMT_BINARY)
For anything beyond inspection, read docs/pitfalls.md (the silent failures) then docs/patterns.md (the design patterns).
top, objs = archive['$top'], archive['$objects']
b = Builder(archive) # from lightkey.build
def gs(u): # resolve a name reference to str
x = objs[int(u)] if isinstance(u, UID) else None
if isinstance(x, str): return x
if isinstance(x, dict):
sv = x.get('NS.string')
return gs(sv) if isinstance(sv, UID) else sv
def find_group(name): # by NAME — UIDs move on every save
for i, o in enumerate(objs):
if b._cn(o) == 'LXPresetGroup' and gs(o.get('name')) == name:
return i
def group_append(gi, uid): # join the EXISTING rocker group
cno = objs[int(objs[gi]['childNodes'])]
cno['NS.objects'] = list(cno.get('NS.objects', [])) + [uid]
panel = objs[int(top['selectedLivePanel'])] # keep the same panel object
for iu in objs[int(panel['items'])]['NS.objects']:
ob = objs[int(iu)]
if b._cn(ob) == 'LXCpanButton':
ob['rect'] = b.raw_str(f'{{{{{x}, {y}}}, {{{w}, {h}}}}}') # reposition ONLY
panel['items'] = b.ns_array(items) # reused button UIDs + new label/button UIDs
$classes chain. Lightkey strictly validates shape during unarchival; extra or missing keys cause silent crashes with no error message, just EXC_BREAKPOINT.top.rootPresetGroup and confirm your new preset groups are reachable from it.filename_v2.lightkeyproj, filename_v3.lightkeyproj) — the user will iterate; named versions make rollback easy.livePanels as a backup tab and point selectedLivePanel at the new one. Rolling back then costs the user one click instead of a file swap.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jimhoggey/lightkey-skill --plugin lightkey-patcher2 skills in this plugin
Other plugins' skills for the same job