Agent skill
solid-core-control-flow
SolidJS control flow: Show for conditionals, Switch/Match for multiple conditions, For/Index for lists, Dynamic for dynamic components, Suspense for async data.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/solid-core-control-flow
SKILL.md
SolidJS Control Flow
Show Component
Renders children when when condition is true. Use fallback prop for false condition.
import { Show } from "solid-js";
<Show when={data()} fallback={<div>Loading...</div>}>
<div>{data().name}</div>
</Show>
// Nested Show
<Show when={user()}>
<Show when={user().admin}>
<AdminPanel />
</Show>
</Show>
Switch and Match
Use for multiple, mutually exclusive conditions:
import { Switch, Match } from "solid-js";
<Switch fallback={<div>Default</div>}>
<Match when={status() === "loading"}>
<Loading />
</Match>
<Match when={status() === "error"}>
<Error />
</Match>
<Match when={status() === "success"}>
<Content />
</Match>
</Switch>
<Switch>wraps multiple<Match>components- First
<Match when={condition}>that is true renders its children <Switch fallback={...}>for no matching conditions
For and Index
For
Use when order/length may change frequently (complex data):
itemis valueindexis signal:index()
import { For } from "solid-js";
<For each={items()}>
{(item, index) => (
<div>
{item.name} - {index()} {/* index is signal */}
</div>
)}
</For>
Index
Use when order/length is stable, content changes frequently (primitives, inputs):
itemis signal:item()indexis number
import { Index } from "solid-js";
<Index each={inputs()}>
{(input, index) => (
<input value={input()} onInput={...} />
// input is signal, index is number
)}
</Index>
When to use:
<For>: Dynamic lists where items may be added/removed/reordered<Index>: Stable lists where content changes (e.g., form inputs, primitives)
Dynamic Component
Render components dynamically:
import { Dynamic } from "solid-js";
<Dynamic component={componentName()} props={props()} />
Suspense
Handles async data and lazy-loaded components:
import { Suspense } from "solid-js";
<Suspense fallback={<Loading />}>
<AsyncComponent />
</Suspense>
// Nested Suspense
<Suspense fallback={<PageSkeleton />}>
<Suspense fallback={<TitleSkeleton />}>
<Title />
</Suspense>
<Content />
</Suspense>
Best practices:
- Wrap async data fetching components
- Use nested Suspense for independent loading states
- Provide meaningful fallback UI
Error Boundaries
Catch errors in component tree:
import { ErrorBoundary } from "solid-js";
<ErrorBoundary fallback={(err, reset) => (
<div>
Error: {err.message}
<button onClick={reset}>Retry</button>
</div>
)}>
<Component />
</ErrorBoundary>
fallbackprop renders UI on errorresetfunction to retry rendering
Best Practices
- Use
<Show>for simple conditionals - Use
<Switch>/<Match>for multiple mutually exclusive conditions - Use
<For>for dynamic lists (items may change) - Use
<Index>for stable lists (content changes, not order) - Always wrap async components with
<Suspense> - Use
<ErrorBoundary>for error handling - Provide meaningful fallback UI
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?