Write device skill

From inanimate-tech/resident · View interactive version

Write device skill is an AI agent skill from the GitHub repository inanimate-tech/resident. Use when authoring a DEVICE-SKILL.md for a new Resident-based firmware project. Walks the user through hardware, Lua module surface, examples, and constraints. Triggered when the user says "write a device skill", "set up DEVICE-SKILL.md", or invokes /resident:write-device-skill.

How to use this skill

Skill file

write-device-skill

Help the user produce a DEVICE-SKILL.md for a Resident-based firmware

project. The output is a single Markdown file at the firmware project root

that documents the device-specific Lua surface — hardware, modules,

examples, constraints. Sandbox-generic content (lifecycle callbacks, ctx,

log, time, store, events) is NOT in DEVICE-SKILL.md; it lives in

Resident's own docs and is loaded by the create-app skill.

Audience

DEVICE-SKILL.md is written for Lua app authors targeting

the device sandbox. The reader is someone composing a Lua app and

pushing it to a running device — they do not have

the firmware source open and cannot change it. Frame everything from

that perspective: the runtime contract (what modules and variables

exist, what they do, what ranges are valid). Do NOT describe the C++

firmware layer — no SandboxConfig fields, no driver registration, no

"to enable X the firmware would need to..." asides. If a capability

isn't exposed to Lua, just say so plainly and move on.

What you need

  1. Firmware project root — defaults to cwd. Ask if not in one.
  2. Device identity — short name (e.g. "M5StickC Plus2", "<My Hardware Startup> lamp").
  3. Driver surface — which Resident::Driver / Resident::Extension

subclasses the firmware registers, and what each one's name() and

Lua module functions are.

Workflow

  1. Read the template at

${CLAUDE_PLUGIN_ROOT}/skills/write-device-skill/tools/template.md.

${CLAUDE_PLUGIN_ROOT} is set by Claude Code to the absolute path of

the installed plugin — always use it to reference bundled files; the

CWD is the user's project, not the skill directory.

  1. Read the reference example at

${CLAUDE_PLUGIN_ROOT}/skills/write-device-skill/tools/example.md —

that's the seeded M5StickC Plus2 DEVICE-SKILL.md, useful as a quality

bar.

  1. Ask the user (one question at a time):

For each, ask for size/units/coordinate frames.

imu)? For each, ask the user to walk through the available

functions, signatures, and any defaults/ranges.

these from the hardware description; user confirms.

example.md for format). This makes validate-app produce realistic

getter return values instead of nil, so apps that compute against

screen.width() etc. validate cleanly. Skip if the device has no

numeric or multi-value getters.

  1. Write the result to <project-root>/DEVICE-SKILL.md. Do NOT include

sandbox-generic content (lifecycle, ctx, log/time/store/events).

  1. Show the user a diff/summary and confirm before writing.

Pointers when interviewing

in C++. If the user has firmware source open, point them at the Driver

subclass declarations.

staticMethod / constant calls in registerModule().

ax, ay, az), Lua-style multi-return is the convention.

and the sign conventions of any axis.

What NOT to put in DEVICE-SKILL.md

These are sandbox-generic and live in Resident's own docs (loaded by

create-app). DON'T duplicate them per device:

If the firmware exposes a device-specific module that overlaps with one

of these names, document it under Lua Modules — but don't restate the

universal modules.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.