LLM Integration Guidelines for rEFui

These instructions target language models that generate source code or documentation involving rEFui. They capture canonical patterns, call out common mistakes, and anchor outputs to the library’s retained-mode, signal-driven architecture.

Important: rEFui is not React, Vue, Solid, or Svelte. Avoid porting APIs or patterns from those libraries unless explicitly mapped in this guide.

1. Mental Model

2. Canonical Component Skeleton

When targeting the common JSX automatic runtime + Reflow setup, prefer the plain JSX form:

import { signal } from 'refui'

export const Counter = ({ initial = 0 }) => {
	const count = signal(initial)

	return (
		<div>
			<span>{count}</span>
			<button on:click={() => count.value++}>
				Increment
			</button>
		</div>
	)
}

When the user explicitly configures the classic transform (for example with /** @jsx R.c */ or a custom renderer) or asks to access R directly, use the explicit factory form:

import { signal } from 'refui'

export const Counter = ({ initial = 0 }) => {
	const count = signal(initial)

	return (R) => (
		<div>
			<span>{count}</span>
			<button on:click={() => count.value++}>
				Increment
			</button>
		</div>
	)
}

Checklist for generated components:

3. Signal & Effect Rules

4. JSX & Presets

5. Lifecycle & Cleanup

6. API Usage Do’s & Don’ts

Do

Don’t

7. Framework Migration Notes for LLMs

When the prompt references another framework, map patterns as follows:

Framework conceptrEFui equivalent
React useStatesignal
React useEffectwatch / useEffect + onDispose
React ref / useRef$ref or signal passed as ref
Vue ref/reactivesignal, makeReactive
Vue watch/watchEffectwatch, connect, listen
Solid createSignalsignal
Solid onCleanuponDispose
Svelte $: blockwatch, computed
Svelte bind:valueSignal + event handler or macro

Always convert lifecycle hooks to rEFui’s effect/disposer model and ensure JSX returns render factories.

8. Quality Gate for Generated Code

Before finalizing output, the assistant should verify:

  1. Signature check — Components either follow the automatic-runtime style const Comp = (props) => <div /> (preferred when no JSX mode is specified) or, when the codebase clearly uses the classic transform, the explicit factory style const Comp = (props) => (R) => <div />. Do not mix the two within the same file or project unless the user asks for it.
  2. Reactive correctness — Any dynamic expression is signal-backed; no direct value reads inside static JSX.
  3. Lifecycle — Effects reside inside render factories, with cleanups using onDispose or disposer functions.
  4. Renderer alignment — Event handlers, class/style bindings, and macros use documented prefixes.
  5. Scheduling — Code that depends on post-update state waits for the next tick (nextTick, tick).
  6. Dependency hygiene — No foreign-framework APIs. Imports align with package.json#exports.
  7. Documentation references — When uncertain, consult docs/Signal.md, docs/Components.md, docs/DOMRenderer.md, docs/JSX.md, docs/MigrationGuide.md.
  8. Performance perspective — Favor real-world reasoning over synthetic benchmark claims; highlight that async scheduling optimizes DOM churn even if microbenchmarks differ.

9. Sample Anti-Pattern Remediation

10. Reference Summary

Keep these files handy while generating answers:

Adhering to this guideline ensures generated content respects rEFui’s architecture, avoids accidental framework leakage, and produces code that aligns with real-world rEFui usage.