jotai
Installation
SKILL.md
Jotai
Overview
Use this skill to make Jotai code feel atomic, composable, and React-friendly. Prefer small state boundaries, derived atoms, write-only action atoms, stable atom references, and narrow subscriptions over store-shaped objects and broad component rerenders.
Workflow
- Inspect the target code before changing it. Identify existing state ownership, update paths, render hot spots, async behavior, and test coverage.
- Model state as atoms. Split values when they change independently, derive computed values with read-only atoms, and move commands into write-only atoms.
- Use the narrowest React hook. Prefer
useAtomValuefor reads anduseSetAtomfor writes; useuseAtomonly when the component genuinely needs both. - Keep atom configs stable. Define atoms at module scope when possible; if created during render, memoize them with
useMemo,useRef, oruseState. - Reach for utilities only when they match the shape of the problem. Prefer plain derived atoms first; use
splitAtom,focusAtom,atomWithStorage,atomWithReset,unwrap, or related helpers when they remove real complexity. - Verify behavior from the user-facing surface when possible. Add focused atom-level tests only for logic that is hard to exercise through components.
Reference Routing
Read only the files that match the task: