Provides guidance on using @muxmuxmux/core and @muxmuxmux/react for state-dependent methods on observable stores. Helps write, review, or test code with controller-based UI state modeling.
Ships in muxmuxmux. 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.
controller from @muxmuxmux/core combines two things:
get(), set(state), subscribe(listener).undefined.In React, use useController from @muxmuxmux/react. In Svelte, use the controller directly as a store.
Quick test: if every handler calls set before any await and starts no timer, stay on core.
A handler may still await and then call set on core. That is safe when no other call can leave the state meanwhile, as in the example below. Otherwise, use @muxmuxmux/machine. Leaving one of its states aborts that state's work, so a cancel wins over a late result. Its skill holds the full guide to choosing: install the package, then read node_modules/@muxmuxmux/machine/skills/muxmuxmux-machine/SKILL.md.
Write each state's methods. A method changes state by calling set on the controller's variable.
import { controller } from "@muxmuxmux/core";
const upload = controller("idle", {
idle: { start: (file: File) => send(file) },
uploading: {},
failed: { start: (file: File) => send(file), dismiss: () => upload.set("idle") },
});
async function send(file: File) {
upload.set("uploading");
try {
await post(file);
upload.set("idle");
} catch {
upload.set("failed");
}
}
Leave a state's object empty when nothing should happen in it, as uploading does.
upload.get(); // "idle" | "uploading" | "failed"
const unsubscribe = upload.subscribe((state) => render(state));
subscribe calls the listener right away with the current state, then on every change. set with the current state notifies nobody.
In Svelte, $upload is the current state.
A method's return type is the union across states, plus undefined when some state lacks the method.
const counter = controller("idle", {
idle: { read: () => 0, reset: () => true },
busy: { read: () => "busy" },
});
const value = counter.read(); // number | string
const done = counter.reset(); // boolean | undefined
if (done === undefined) {
// the call ran in "busy", which has no reset
}
inspectMethods returns the methods object, so tests can assert on spies.
import { controller, inspectMethods } from "@muxmuxmux/core";
const ctrl = controller("idle", { idle: { start: vi.fn() }, running: {} });
ctrl.start();
expect(inspectMethods(ctrl).idle.start).toHaveBeenCalled();
❌ Don't store data in the state. The store's value is a state name only, so set({ status, data }) fails to compile. Keep data in your own variables or stores.
❌ Don't expect if (ctrl.get() === "idle") to narrow method types. TypeScript keeps the full union inside the branch. Check the call's result instead.
❌ Don't assume a call did something. In a state without the method, the call returns undefined and changes nothing.
❌ Don't give one method incompatible parameters across states. Arguments must suit every state that defines the method, so (x: number) in one state and (x: string) in another makes the method uncallable.
❌ Don't name a method get, set or subscribe. The store owns those names. TypeScript reports "reserved by the store; rename this method", and plain JavaScript silently ignores the method.
❌ Don't reach the controller through this inside a method. Refer to the controller's variable, as in upload.set("idle").
❌ Don't create a controller inside a React component with controller(). It would be recreated on every render. Use useController from @muxmuxmux/react.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/muxmuxmux:muxmuxmuxfrom muxmuxmux
npx claudepluginhub vadirn/muxmuxmux --plugin muxmuxmuxOther plugins' skills for the same job