Reactive state primitives via @fozy-labs/rx-toolkit — Signal.state / compute / effect, LocalSignal, RxJS interop and the useSignal React hook.
Ships in fozy-labs. 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.
Read when SKILL.md points to them.
Value-based reactive primitives (SolidJS / Angular Signals in spirit), built on RxJS. Reference version: 0.13.0.
Use for local synchronous state — server state goes through createResource (see fozy-labs-rx-api).
Two layers:
Signal, the State / Computed / Effect / FromSignal classes, Batcher). Works in Node, workers, tests, any framework.useSignal, from @fozy-labs/rx-toolkit/react (nothing React is at the package root since 0.13.0). React ≥ 19 (declared peer), client-only.Reactivity is by value, not by event: every write dedupes with Object.is, so writing an equal value notifies nobody.
Convention: every signal field ends with a $ suffix (matches the RxJS observable convention).
Signal.state — mutable reactive valueimport { Signal } from "@fozy-labs/rx-toolkit";
class FiltersStore {
readonly query$ = Signal.state("");
readonly user$ = Signal.state<UserDto | null>(null);
readonly isOpen$ = Signal.state(false, "FiltersStore/isOpen$"); // 2nd arg = devtools key
markSeen() {
this.user$.update((u) => (u ? { ...u, seen: true } : u));
}
}
| Call | Tracked | Notes |
|---|---|---|
s$() / s$.get() | yes | Registers a dependency when read inside a compute / effect. |
s$.peek() | no | Current value, no subscription. |
s$.set(v, actionName?) | — | Silently ignored when Object.is(v, current). |
s$.update(fn, actionName?) | — | set(fn(peek())) — the read inside update is not tracked. |
s$.obs | — | Observable<T>; see references/rxjs-interop.md. |
s$.dispose() | — | Completes the signal; see references/disposal-and-leaks.md. |
setting the same reference is a no-op — the Object.is guard swallows it. Always set a new reference.set / update already opens a batch; Batcher.run is only for grouping several writes.Signal.compute — derived, lazy, read-onlyclass OrderListStore {
private readonly _session = inject(SessionStore);
readonly orders$ = Signal.state<OrderDto[]>([]);
readonly archivedIds$ = Signal.state<string[]>([]);
readonly isAuthenticated$ = Signal.compute(() => this._session.user$() !== null);
readonly archivedKeys$ = Signal.compute(() => new Set(this.archivedIds$()));
readonly visible$ = Signal.compute(() =>
this.orders$().filter((o) => !this.archivedKeys$().has(o.id)),
);
}
obs, useSignal) starts an internal effect that keeps it warm, and stops it when the last subscriber leaves.Object.is, or by your equals. Signal.compute(fn, { equals }) compares the recomputed value with the previous one; on equal it keeps the previous reference — obs subscribers and dependents are not notified. Reads inside equals are not tracked; a throwing equals logs and falls back to Object.is. Without it, a compute that builds a fresh object / array / Set on every run notifies on every run — a legitimate result, not a bug, but it is what makes React re-render. See references/extra-recomputes.md.computeFn throws with subscribers on, the error becomes the computed's value: reads rethrow it (without recomputing) until a dependency changes — then it recovers. Dependents restart and see the error on read; obs subscribers get error and the subscription ends.SignalCycleError naming the chain (A → B → A).DisposableSignal<T> — no set / update.async — a promise is not a value. Use createResource (fozy-labs-rx-api).Signal.effect — side effect on dependency changeconst stop = Signal.effect(() => {
const id = this.resourceId$(); // tracked — read synchronously
const mode = this.mode$();
const ws = openSocket(id, mode);
return () => ws.close(); // teardown: before the next run and on unsubscribe
});
stop.unsubscribe(); // stop it; `stop.closed` is true afterwards
await, inside .then, or in a timer callback establishes nothing — capture it before the async hop.effectFn must return a teardown or nothing — an arrow body returning a value is a type error; write a block body.Signal.effect. A throw on a later run does not: the effect stays subscribed to what it read before the throw, reruns when those change, and the error rethrows from the write that scheduled the run (usually set()). A teardown that throws is not called again. Unsubscribe explicitly an effect that must not survive a failure.useEffect, DI onScopeInit), never in a constructor. See references/disposal-and-leaks.md.Signal.from — RxJS Observable → signalreadonly online$ = Signal.from(navigatorOnline$, { default: true });
readonly clicks$ = Signal.from(clickStream$, { keepAlive: "forever" }); // stateful pipeline
One shared upstream subscription behind a replay cache: while it is hot every read is a cache hit, not a
re-subscription. keepAlive ("none" | "microtask" | "task" | "forever" | number, default "microtask") decides how
long that subscription outlives the last consumer.
DisposableSignal<T> — dispose() freezes the last value and drops the upstream.default, or throws Error: No value emitted when no default was given..obs delivers one value per batch, at the end of it — a synchronous burst on connect (of(1, 2, 3)) delivers just 3. State.obs still delivers every write.keepAlive, error and complete behaviour: references/rxjs-interop.md.// Signal.from(), SourceSignal.create()
interface ReadonlySignal<T> {
readonly obs: Observable<T>;
peek(): T;
get(): T;
(): T;
}
// Signal.compute(), Signal.from()
interface DisposableSignal<T> extends ReadonlySignal<T>, Disposable {
dispose(): void;
}
// Signal.state()
interface StateSignal<T> extends DisposableSignal<T> {
set(value: T, actionName?: string): void;
update(updater: (value: T) => T, actionName?: string): void;
}
Signal.effect returns an Effect, not a signal — an RxJS SubscriptionLike with unsubscribe() and closed.LocalSignal.state returns LocalStateSignal<T>: ReadonlySignal + set / update / clear, and notably no
dispose() (references/persisted-state.md).import { DefaultOptions, reduxDevtools } from "@fozy-labs/rx-toolkit";
if (import.meta.env.DEV) {
DefaultOptions.update({ DEVTOOLS: reduxDevtools() });
}
Signal.state(0, "counter") — the string is the key of SignalOptions. There is no name field.count$.set(0, "reset") → action UPDATE: reset; a bare set → UPDATE.+ in CREATE → RECREATE → UPDATE → CLEAR order, then the names collected (the first per key,
deduped, five at most, then +N more) — CREATE+UPDATE: reset, increment. Which keys moved is in the Diff tab.RECREATE, not a collision: the newcomer owns the key,
and late events from the superseded instance — its dispose(), its GC finaliser — are ignored. Never dispose() a
signal merely to keep devtools clean.{scope} inside a key is replaced by DefaultOptions.update({ getScopeName }) — wire it to the DI scope name for keys like "{scope}/CounterStore/value$". {base} expands to State / Computed.Signal.state(secret, { isDisabled: true }).SignalOptions.hooks (onInit / onChange / onDispose) is honoured by Signal.state only — Signal.compute drops it.Signal.compute for async values — use createResource (see fozy-labs-rx-api if exist).await / microtask callbacks and expect tracking.set the same reference — the write is dropped.try/catch a set() to intercept a compute/effect error — catch it at the read site or in an ErrorBoundary.$ suffix on every signal field.Load these only when the specific situation applies — do not preload.
| Situation | File |
|---|---|
Rendering signals in React — useSignal, component-local signals, StrictMode, SSR | references/use-in-react.md |
| Signals outside React — Node, workers, tests, Angular/Svelte/Solid, class style | references/use-outside-react.md |
A compute/effect runs too often, too rarely, or out of order; Batcher | references/extra-recomputes.md |
| Deciding what must be disposed, effect teardown, leaks, DI scope interaction | references/disposal-and-leaks.md |
An RxJS Observable on either side — obs, Signal.from, keepAlive, SourceSignal | references/rxjs-interop.md |
State that must survive a reload — LocalSignal, storage layout, GC, drivers | references/persisted-state.md |
| One big object or a keyed collection wakes every reader (experimental APIs) | references/fine-grained-state.md |
Modelling a lifecycle, not a value — state machines (unstable_MachineSignal.state) | references/statechart.md |
Existing code uses a name this skill does not describe (signalize, zodSchema, LocalState) or imports useSignal from the package root | references/migrations.md |
Pick one of use-in-react.md / use-outside-react.md — the one matching the host. Loading both variants of the same topic is redundant.
references/disposal-and-leaks.md (opens in a new tab)references/extra-recomputes.md (opens in a new tab)references/fine-grained-state.md (opens in a new tab)references/migrations.md (opens in a new tab)references/persisted-state.md (opens in a new tab)references/rxjs-interop.md (opens in a new tab)references/statechart.md (opens in a new tab)references/use-in-react.md (opens in a new tab)references/use-outside-react.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/fozy-labs:fozy-labs-signalsfrom fozy-labs
npx claudepluginhub fozy-labs/astp --plugin fozy-labs4 skills in this plugin
/fozy-labs-diDependency injection for js/ts projects based on @fozy-labs/simplest-di package.
/fozy-labs-fsdFeature-Sliced Design (FSD) v2.1 — deciding which layer, slice and segment a piece of frontend code belongs to, plus the fozy-labs conventions.
/fozy-labs-rx-apiServer-state layer for js/ts projects based on the Query module of @fozy-labs/rx-toolkit (createApi / createResource / createCommand) — caching, SWR, optimistic updates, React hooks.