tanstack-store
Skill4 starsChanged 20 days agoMITView on GitHub
TanStack Store client-state management. Use when implementing or reviewing @tanstack/store or its framework adapters, immutable updates, derived stores, selectors, subscriptions, batching, scoped SSR state, or migrations from legacy Store/Derived/Effect APIs.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- dvaJi/argostheir own version, first seen Sep 9, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- dvaJi/argos★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- authoringSkill
- chrome-devtoolsSkill
- gamificationSkill
- imagegenSkill
- improve-architectureSkill
- instructionsSkill
- monorepoSkill
- reverse-engineerSkill
- runbookSkill
- security-reviewSkill
- setup-harnessSkill
- skillsSkill
- unslopSkill
- video-reportSkill
- youtube-transcriptSkill
- code-reviewSkill
- debugSkill
- interviewSkill
- prototypeSkill
- researchSkill
- workSkill
- adsenseSkill
- astryxSkill
- cloudflare-cliSkill
- dokploy-best-practicesSkill
- extract-themeSkill
- nextjsSkill
- payload-cmsSkill
- shadersSkill
- swrSkill
- tanstack-querySkill
- tanstack-routerSkill
- tanstack-startSkill
- tauriSkill
- vite-plusSkill
- web-assets-optimizationSkill
- web-extensionSkill
- zodSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Read the installed core and adapter versions, lockfile resolutions, existing store definitions, and consumers before choosing an API.
- Very specific: line 68
Keep update functions pure and synchronous.
- Distinctive: line 115
After awaited work, batch only the synchronous writes that must notify together.
- Distinctive: line 128
Legacy maintenance or an explicitly requested upgrade: read legacy.md; migrate lifecycle and consumers together.
- Distinctive: line 140
Use the project's existing typecheck and nearest tests.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TanStack Store
1. Establish the API generation and state owner
Read the installed core and adapter versions, lockfile resolutions, existing
store definitions, and consumers before choosing an API. This skill's modern
examples target core and React 0.11.1, verified on 2026-09-17. TanStack
still labels Store alpha; resolve newer or intermediate versions against their
installed declarations rather than assuming that all 0.x releases agree.
| Evidence in the project | Path |
| Core 0.11.1, React 0.11.1 | Use the modern examples below. |
| Core 0.9–0.10 | Signals rewrite, but newer adapter hooks may be absent; verify exports. |
Core through 0.8, explicit Derived / Effect | Read legacy.md before changing code. |
| Multiple core versions, including transitive dependencies | Follow the package resolved by each consumer; retain unrelated library internals. |
Choose ownership before adding a store:
| State | Preferred owner |
| One component's temporary UI state | Framework-local state |
| Shared client-owned state or reactive calculations | TanStack Store |
| Shareable navigation, filters, pagination | Router URL/search state |
| Remote data, freshness, retries, mutations | Existing server-state cache, such as TanStack Query |
| Synchronized collections and relational live queries | Existing data layer, such as TanStack DB |
Finish this step with the resolved API generation, state owner, store lifetime, and affected consumers identified. Preserve the project's existing state layer unless the requested behavior needs a change.
2. Implement the state transition
createStore(value) creates writable state. setState(updater) replaces the
whole value with the updater's return value; it does not merge object fields.
Return new references along changed paths and retain unchanged branches.
import { createStore } from '@tanstack/store'
type Filters = {
query: string
status: 'all' | 'open' | 'closed'
}
export function createFiltersStore() {
const store = createStore<Filters>({ query: '', status: 'all' })
function setQuery(query: string) {
store.setState((state) =>
state.query === query ? state : { ...state, query },
)
}
return { store, setQuery }
}Keep update functions pure and synchronous. Use an explicit state type for
unions, nullable values, and empty collections. Core change detection uses
Object.is; mutating an object and returning the same reference can suppress
notifications. A direct .state or .get() read returns a snapshot, not a UI
subscription.
Reuse ordinary action functions like the example. When the installed API and
project use createStore(initialValue, actionsFactory), actions are exposed
through .actions; this is optional, not a reason to restructure existing stores.
Finish when each requested transition preserves unrelated state and has one authoritative write path.
3. Derive and observe
createStore(getter) creates a readonly computed store. Reads of other stores
inside its synchronous getter establish dependencies automatically, including
conditional dependencies. Read dependencies inside the getter rather than
closing over snapshots read beforehand.
import { batch, createStore } from '@tanstack/store'
const price = createStore(10)
const quantity = createStore(2)
const total = createStore(() => price.state * quantity.state)
const observedTotals: number[] = []
const subscription = total.subscribe((value) => observedTotals.push(value))
batch(() => {
price.setState(() => 12)
quantity.setState(() => 3)
})
subscription.unsubscribe()The final total is 36; the subscription receives that update, not an initial
value. Read .state separately when an initial snapshot is needed.
- Modern computed stores need no
.mount(). Keep getters pure: evaluation is lazy and subscription-driven, not an event log. A getter's optional previous value is the previous computation result, not a guarantee to process every write. subscribereceives the new value and returns{ unsubscribe }. Attach its cleanup to the owner's disposal/unmount lifecycle; use it for external effects.batchdelays notifications until the outermost synchronous batch ends. Writes still happen immediately; it is neither rollback nor an async transaction. After awaited work, batch only the synchronous writes that must notify together.- Store computations track Store reads, not arbitrary framework props. Bridge changing inputs explicitly through the existing framework integration.
Finish when derived values have no duplicated writable copy and every manual subscription has a cleanup owner.
4. Connect the framework and lifetime
- React selectors, component-owned stores, context, SSR, or persistence: read react.md. Subscribe to the slice rendered by the component.
- Other frameworks: inspect the adapter's official quick start and installed types. Vue refs, Solid accessors,
Svelte
.current, and Angular signals are different return contracts. - Legacy maintenance or an explicitly requested upgrade: read legacy.md; migrate lifecycle and consumers together.
- Atoms, async atoms, action factories, devtools, or disputed API behavior: inspect the installed implementation and matching official documentation before extending it. Verify exports; custom persistence and request caching are not implicit Store capabilities.
Finish when the store survives the intended renders, is disposed at the right boundary, and cannot leak request-specific state between server requests.
5. Validate the changed contract
Use the project's existing typecheck and nearest tests. Cover the paths changed:
- Consecutive updates use the latest state and preserve unrelated fields.
- A changed nested value gets new references; a no-op preserves its reference.
- Derived results update when active dependencies change, including branch switches.
- Batched writes expose the expected final notification; cleanup stops observation.
- A component reacts to its selected slice, including prop-dependent selectors; unrelated writes do not cause store-driven rerenders when selection is equal.
- Scoped instances remain independent; SSR hydration starts from matching data.
Report the resolved versions, checks run, and any untested runtime boundary.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

