refui
FreeRuns bundled scriptsNot checkedBuild, debug, and migrate rEFui applications using a self-contained guide to retained-mode signals, component lifecycles, memo/keepAlive factories, lists…
About this skill
rEFui
Overview
Apply rEFui’s retained-mode + signals model correctly, choose the right JSX mode and renderer, and fix reactivity or lifecycle issues without importing assumptions from other UI frameworks. This file is the operative guide: do not require repository documentation, a linked local checkout, MCP documentation, or the bundled reference files to complete ordinary rEFui work.
Core Pitfalls (skim)
- JSX is evaluated once;
{signal.value}in JSX is static. Use{signal}or a derived$(() => ...). - In-place array/object mutation requires
sig.trigger()(or replace with a new value). - A reactive scope that writes a signal it also reads can schedule itself repeatedly. Audit this as a possible feedback loop, not an automatic error: guarded or convergent updates may be intentional.
- Context values are stable; provide signals in context if consumers must react.
- Passing a signal/computed directly to rEFui control-flow is correct:
<If condition={sig}>and<If condition={computed}>are intended usage. The pitfall is conditional.valuereads inside JS/derived code that skip later dependencies. - Prefer lazy
Ifbranches when setup and cleanup should follow branch visibility:<If condition={flag}>{() => <Page />}</If>. Eager children are valid when their earlier evaluation and parent ownership are intentional. Ifconsumes its first two children as true/false branches. To show several siblings in one branch, return one Fragment from one function; do not pass those siblings as separate children.
General guide
Mental model (retained mode)
- Component bodies are setup: they run once; they do not “re-render”.
- JSX is evaluated once; signals update the already-built UI incrementally.
- If something “doesn’t update”, you almost always read
.valuetoo early (non-reactively) or mutated in place withouttrigger().
Signals & reactivity
- State:
const count = signal(0) - Reactive JSX:
{count}(not{count.value}) - Derived:
const label = $(() =>Count: ${count.value})and then{label} - In-place mutation: call
sig.trigger()after mutating arrays/objects.
import { signal, $ } from 'refui'
const Counter = () => {
const count = signal(0)
return (
<button on:click={() => count.set(count.value + 1)}>
{$(() => `Count: ${count.value}`)}
</button>
)
}
Effects & cleanup
- Reactive effect:
watch(() => { ...reads signals... }) - Setup/cleanup:
useEffect(() => { ...; return () => cleanup }) - Teardown-only:
onDispose(() => cleanup) EffectScopeis the ownership basis for components, effects, and disposer scopes. Work created inside a live scope is automatically released with that owner.connect(signals, callback)andsignal.connect(callback)subscribe only to the explicitly supplied signals. Reads inside their callbacks are intentionally untracked; createwatch()explicitly when a callback needs discovered dependencies.useActionlisteners are event handlers, not reactive effects. Signal reads and writes inside a listener do not subscribe the listener; listener registration is still disposed with its outer scope.- Review writes to a scope's own signal dependencies for repeated scheduling and termination. A guard, stable value, or convergent update can make this intentional. Warn when the intent is unclear; do not block or rewrite an understood design, or keep repeating an acknowledged warning.
peek/untrackreads and deferred event callbacks have different tracking semantics. - Scheduling: if you need “after updates applied”,
await nextTick().
Control flow components
- Conditional UI:
<If condition={cond}>{() => <Then />}{() => <Else />}</If> - Branch functions defer evaluation into the selected branch's scope. Direct children are evaluated before
If; their setup can belong to the enclosing owner and outlive branch visibility. Choose the form that matches the intended lifetime, accounting for the renderer and JSX/HMR mode. - Two branch children mean true and false, not two true-branch siblings. Use
<If condition={cond}>{() => <><First /><Second /></>}</If>when both belong to the true branch. - Lazy branches are a recommendation, not a hard requirement. Preserve intentional eager construction; discuss the ownership tradeoff only when it matters to the observed behavior.
- Lists:
<For entries={items} track="id">{({ item, index }) => ...}</For>; its child is an item method, not a component boundary. - Inline dynamic subtree with lifecycle:
<Fn ctx={something}>{(ctx) => ...}</Fn> Forhas nofallback; for empty states, wrap with<If>.- If the condition already exists as a signal/computed, pass it directly. Do not “fix”
<If condition={someSignal}>into extra.valueplumbing.
Memoization and retained subtrees
memo(fn)caches only the immediate result of the firstfn(...)call in its captured owner scope.- Components are two-stage:
Page(props)returns a render fun
Install refui in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the refui skill do?
Build, debug, and migrate rEFui applications using a self-contained guide to retained-mode signals, component lifecycles, memo/keepAlive factories, lists, async UI, DOM/HTML/Reflow renderers, JSX modes, directives, and HMR. Use when library source or separate local documentation may be unavailable.
How do I install the refui skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the refui skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic