ai/skills/aidd-react/SKILL.md
Enforces React component authoring best practices. Use when creating React components, binding components, presentations, useObservableValues, or when the user asks about React UI patterns, reactive binding, or action callbacks.
npx skillsauth add paralleldrive/aidd aidd-reactInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
React components live in the components/ layer per structure. Consume Observe and void actions from plugins per service. Use @adobe/data-react for useDatabase, useObservableValues, and DatabaseProvider.
Constraints {
Binding components must call useDatabase to obtain the main service context
Do not access any other React context
All other services and state reachable from database (db.services, db.observe, db.transactions)
Single context is sufficient
}
Binding components must call useDatabase to obtain the main service context. Do not access any other React context. Additional contexts create a context waterfall and hurt performance. All other services and state are reachable from the database — e.g. db.services, db.observe, db.transactions — so a single context is sufficient.
BindingComponent {
injects: "observed values via useObservableValues"
triggers: "re-render when those values change"
binds: "action callbacks to the presentation"
}
Presentation {
type: "pure function (no hooks)"
receives: "data and action callbacks as props"
returns: "JSX"
constraint: "Keep reactive logic in binding component; presentation stays pure"
}
Do not pass values from parent except when needed to identify which entity in the database to bind to.
When multiple instances exist (e.g. table rows), the parent passes an identifying value such as entity so the child knows which record to observe.
// Parent: passes entity so child knows which record to bind to
{values.sprites.map((entity) => (
<Sprite key={entity} entity={entity} />
))}
// Child: uses entity prop to observe the right record
function Sprite({ entity }: { entity: Entity }) {
const db = useDatabase();
const values = useObservableValues(
() => ({ sprite: db.observe.entity(entity, db.archetypes.Sprite) }),
[entity],
);
// ...
}
Most binding components use a single useObservableValues call. Collect all observed values in one object.
Observe only what you need — the minimal values required for rendering. For values that may resolve slowly, wrap with Observe.withDefault so you can render a skeleton (or placeholder) immediately while waiting. See observe.
function Counter() {
const db = useDatabase(counterPlugin);
const values = useObservableValues(() => ({
count: db.observe.resources.count,
}));
if (!values) return null;
return presentation.render({ ...values, increment: db.transactions.increment });
}
Constraints {
Presentation files ONLY export render (and localization bundles where appropriate)
Nothing else
For render args type externally (storybook, testing): use Parameters<typeof render>[0]
}
PresentationCallbacks {
are: "action calls, not events"
semantics: "verbNoun — not onClick/onToggle/onSignOut style"
bindingComponent: "passes action callbacks (e.g. toggleView, signOut) as props"
presentation: "invokes them when user intent occurs"
passFunctionReferencesDirectly: true
reason: "All actions are pure functions with no this binding"
}
// Binding component: pass the function reference (no arrow wrapper)
increment: db.transactions.increment
// When the action needs arguments, wrap to supply them
toggleSprite: () => db.transactions.toggleSpriteActive({ entity })
// Presentation: receives and invokes when user acts
<button onClick={props.increment}>Increment</button>
Testing {
presentation: "add *-presentation.test.tsx when appropriate; unit test the presentation"
bindingComponent: "not unit tested — no business logic; uses Database service (already unit tested)"
}
fn whenCreatingOrModifyingReactComponent() {
Constraints {
Call useDatabase for main service context; do not use any other React context
Split into binding component (reactive) and presentation (pure)
Use single useObservableValues in binding component; Observe only minimal values; use Observe.withDefault for slow-resolving values
Pass observed values and action callbacks to presentation; pass function references directly when signature matches; wrap only when supplying arguments
Pass entity (or identifying value) from parent only when child must bind to specific database record
Keep presentation pure — no hooks
Presentation exports only render (and localization bundles where appropriate)
Add *-presentation.test.tsx for presentation when appropriate; do not unit test binding components
Never include business logic within binding components — move into computed values or action handlers
Good binding components should be extremely small
}
}
IMPORTANT! Make absolutely certain that all hooks are executed in the same order every call. DO NOT have any early exits or returns preceding any hooks!
documentation
Top tier author skill for delivering essential truths with the persuasive power to inspire positive change. Use when writing, reviewing, editing, or scoring any content.
development
Guide for crafting high-quality AIDD skills. Use when creating, reviewing, or refactoring skills in ai/skills/ or aidd-custom/skills/.
testing
Reflective Thought Composition. Structured thinking pipeline for complex decisions, design evaluation, and deep analysis. Use when quality of reasoning matters more than speed of response.
tools
Teaches agents how to write correct riteway ai prompt evals (.sudo files) for multi-step flows that involve tool calls. Use when writing prompt evals, creating .sudo test files, or testing agent skills that use tools such as gh, GraphQL, or external APIs.