Agent skill

Zustand Store Patterns

by stellar in stellar/laboratory

Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage).

Apache-2.0Auto-check passedFrontend & Design

Install Zustand Store Patterns

skills CLI
$ npx skills add stellar/laboratory --skill zustand-store-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install stellar/laboratory zustand-store-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/stellar/laboratory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/zustand-store-patterns .claude/skills/zustand-store-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
zustand-store-patterns
GitHub stars
112
Token cost
~1.4k tokens
SKILL.md length
453 words
Files
1
Skills in repo
6
Repo updated
First seen
Licence
Apache-2.0

At a glance

Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage).

  • Works in 3 steps: Add the field + action to createStore.ts → If it should persist in URL, add to the… → Consume via useStore()
  • Tasks that involve State management
  • SKILL.md covers Two Stores, Two Purposes, When to Use Which, Main Store Pattern and Transaction Flow Store Pattern, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Zustand Store Patterns is an agent skill from stellar/laboratory. Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage). Invoke when creating store slices, debugging hydration, or deciding where state belongs.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Frontend & Design, covering State management. It works with Zustand and React. The repository describes itself as: A set of tools that enables developers to try out and learn about the Stellar network. The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve State management

Example prompts

  • “/zustand-store-patterns”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Add the field + action to createStore.ts
  2. If it should persist in URL, add to the select() config
  3. Consume via useStore()

What it can do on your machine

Read from SKILL.md and the folder at commit b4b6465. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Zustand Store Patterns loads about 1.4k tokens when it runs. Until then it costs about 61 tokens; SKILL.md has 453 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~61
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from stellar/laboratory at commit b4b6465, republished under its Apache-2.0 licence (© stellar). 453 words, ~1,368 tokens.

Download SKILL.mdSave it as .claude/skills/zustand-store-patterns/SKILL.md (or your agent's skills folder).
name
zustand-store-patterns
description
Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage). Invoke when creating store slices, debugging hydration, or deciding where state belongs.

Zustand Store Patterns

Two Stores, Two Purposes

Main StoreTransaction Flow Store
Filesrc/store/createStore.tssrc/store/createTransactionFlowStore.ts
HookuseStore()useBuildFlowStore()
Middlewarequerystring(immer(...))persist(immer(...))
Persists toURL querystringsessionStorage
Survives tab closeYes (URL)No
Survives refreshYes (URL)Yes (sessionStorage)
Instance typeNew per provider mountSingleton (module-level)
Used byEntire app (~85 files)Transaction build flow (~21 files)

When to Use Which

Main store (useStore): For state that is app-wide, URL-shareable, or used outside the transaction flow. Network settings, XDR viewer state, endpoint explorer state, account page state.

Flow store (useBuildFlowStore): For state within the single-page transaction flow. Build params, operations, simulation results, signed XDR, step navigation. This state is too large for URLs (simulation results can be 50KB+).

Cross-store reads: Components in the transaction flow read network from the main store as a read-only dependency. Never duplicate network config into the flow store.

typescript
export const SimulateStepContent = () => {
  const { network } = useStore();              // Main store — network only
  const { build, simulate } = useBuildFlowStore(); // Flow store — tx state
};

Main Store Pattern

Middleware stack
typescript
create<Store>()(
  querystring(
    immer((set) => ({ ... })),
    {
      url: options.url,
      select() { /* what to persist in URL */ },
    }
  )
);
Hydration

Synchronous — URL is passed at creation time in StoreProvider:

typescript
// src/store/StoreProvider.tsx
const [store] = useState(() => createStore({ url }));

No manual rehydration needed. Store re-creates on route change.

Consumption

Via React Context (because instance is dynamic):

typescript
import { useStore } from "@/store/useStore";

const { network } = useStore();
const network = useStore((s) => s.network); // selector form

Transaction Flow Store Pattern

Middleware stack
typescript
create<TransactionFlowStore>()(
  persist(
    immer((set) => ({ ... })),
    {
      name: "stellar_lab_tx_flow_build",
      storage: createJSONStorage(() => sessionStorage),
      skipHydration: true,  // CRITICAL
    }
  )
);
Hydration — The Critical Gotcha

Never rehydrate in useEffect. Child effects fire before parent effects and will write default state to sessionStorage, overwriting persisted data.

typescript
// WRONG — don't do this
useEffect(() => {
  useBuildFlowStore.persist.rehydrate();
}, []);

// CORRECT — module-scope rehydration (runs before any component mounts)
if (typeof window !== "undefined") {
  useBuildFlowStore.persist.rehydrate();
}

This runs at module load time, before React renders anything. The skipHydration: true flag prevents Zustand's automatic rehydration (which happens too late).

Consumption

Direct import (singleton, no context needed):

typescript
import { useBuildFlowStore } from "@/store/createTransactionFlowStore";

const { build, simulate, setActiveStep } = useBuildFlowStore();
Storage keys
  • stellar_lab_tx_flow_build — Build flow state
  • stellar_lab_tx_flow_import — Import flow state (independent)

Each flow has its own store instance and sessionStorage key. Navigating between Build and Import tabs does not clear the other's state.

Adding New State

Show full SKILL.md (190 more words)Show less
To the main store
  1. Add the field + action to createStore.ts
  2. If it should persist in URL, add to the select() config
  3. Consume via useStore()
To the flow store
  1. Add the field to the appropriate slice (build, simulate, sign, validate, submit)
  2. Add setter action(s) using Immer's mutable syntax:
    typescript
    setSignedXdr: (xdr: string) =>
      set((state) => {
        state.sign.signedXdr = xdr;
      }),
  3. Add to INITIAL_STATE with a sensible default
  4. Add to reset logic if the field should clear when the user goes back to Build
  5. Consume via useBuildFlowStore()
Data conventions
  • XDR values: Always store as base64 strings, never SDK objects
  • RPC results: Store as raw JSON strings (JSON.stringify(result))
  • Step navigation: activeStep and highestCompletedStep are persisted — they survive refresh
  • Validation state: Can only raise highestCompletedStep, never lower it (except on explicit reset)

Error Handling for sessionStorage

All sessionStorage access must be wrapped in try-catch:

  • Write failure (QuotaExceededError): Fall back to in-memory only
  • Read failure (corrupted JSON): Reset to default state
  • Private mode: sessionStorage works but clears on tab close (same behavior)

Key Files

PurposeFile
Main storesrc/store/createStore.ts
Main store hooksrc/store/useStore.ts
Store providersrc/store/StoreProvider.tsx
Flow storesrc/store/createTransactionFlowStore.ts
Root layoutsrc/app/layout.tsx

© stellar, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/zustand-store-patterns of stellar/laboratory.

Open the folder on GitHubat commit b4b6465

Compare with similar skills

Zustand Store Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Zustand Store Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Zustand Store Patterns this skillstellar/laboratory112—~1.4kAutomated safety check: PassApache-2.0
Xray UI Devbropines/xray-config-ui-editor119—~942Automated safety check: PassMIT
Opik Frontend Patternscomet-ml/opik22k—~1.1kAutomated safety check: PassApache-2.0
State Managementemanueleielo/deepagents-open-lovable111—~1.7kAutomated safety check: PassNone
Frontend Large Feature Architecturelangfuse/langfuse36k—~1.4kAutomated safety check: PassCustom licence
React ExpertJeffallan/claude-skills12k—~1.4kAutomated safety check: PassMIT

Similar skills

  • Xray UI Dev

    bropines/xray-config-ui-editor

    Development and maintenance of Xray Config UI Editor. An agent skill from bropines/xray-config-ui-editor.

    119 GitHub stars~942 tokensUpdated 6 days ago
    Frontend & DesignAuto-check passed
  • Sets the conventions for the Opik React frontend: TanStack Query for data, Zustand for shared state, one-way layer imports and a fix for Google Translate crashes.

    22k GitHub stars~1.1k tokensUpdated today
    Frontend & DesignAuto-check passed
  • State Management

    emanueleielo/deepagents-open-lovable

    State management patterns - Zustand, Jotai, Context. An agent skill from emanueleielo/deepagents-open-lovable.

    111 GitHub stars~1.7k tokensUpdated 3 days ago
    Frontend & DesignAuto-check passed
  • Architect large or state-heavy Langfuse frontend features. An agent skill from langfuse/langfuse.

    36k GitHub stars~1.4k tokensUpdated today
    Frontend & DesignAuto-check passed
  • React Expert

    Jeffallan/claude-skills

    Builds React 19 components in TypeScript with Server Components, useActionState forms, custom hooks and state libraries, checked with tsc and React Testing Library.

    12k GitHub stars~1.4k tokensUpdated 5 days ago
    Frontend & DesignAuto-check passed
  • React Flow Node TS

    microsoft/skills

    Official

    Create React Flow node components with TypeScript types, handles, and Zustand integration.

    3.1k GitHub starsUsed in 6 repos~502 tokens
    Frontend & DesignAuto-check passed

More from stellar/laboratory

  • Component Guide

    stellar/laboratory

    Guide for building React components using @stellar/design-system and project SCSS conventions.

    112 GitHub stars~999 tokensUpdated 5 days ago
    Auto-check passed
  • Correct mental models for React re-renders and memoization. An agent skill from stellar/laboratory.

    112 GitHub stars~1.1k tokensUpdated 5 days ago
    Auto-check passed
  • Commit Progress

    stellar/laboratory

    Commit a logical unit of work with a descriptive message. An agent skill from stellar/laboratory.

    112 GitHub stars~774 tokensUpdated 5 days ago
    Auto-check: notes
  • Figma To Code

    stellar/laboratory

    Bridge Figma MCP output to Stellar Lab code conventions. An agent skill from stellar/laboratory.

    112 GitHub stars~520 tokensUpdated 5 days ago
    Auto-check passed
  • Test Changed

    stellar/laboratory

    Run e2e and unit tests related to files changed on the current branch.

    112 GitHub stars~836 tokensUpdated 5 days ago
    Auto-check passed

Works with

Questions about Zustand Store Patterns

What does Zustand Store Patterns do?

Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage). Zustand Store Patterns is an agent skill from stellar/laboratory. Reference for the two Zustand store patterns in Stellar Lab — main store (querystring) and transaction flow store (sessionStorage).

When should I use Zustand Store Patterns?

Zustand Store Patterns fits situations like: tasks that involve State management.

How do I install Zustand Store Patterns in Claude Code?

Run `npx skills add stellar/laboratory --skill zustand-store-patterns -a claude-code`. Or copy the skill folder (.claude/skills/zustand-store-patterns in stellar/laboratory) into .claude/skills/zustand-store-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Zustand Store Patterns in Codex?

Run `npx skills add stellar/laboratory --skill zustand-store-patterns -a codex`. Or copy the skill folder (.claude/skills/zustand-store-patterns in stellar/laboratory) into .agents/skills/zustand-store-patterns in your project. Codex loads it when a task matches its description.

Can I use Zustand Store Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add stellar/laboratory --skill zustand-store-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/zustand-store-patterns, .gemini/skills/zustand-store-patterns, .github/skills/zustand-store-patterns and .opencode/skills/zustand-store-patterns in your project.

What does Zustand Store Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: Zustand Store Patterns is instructions for the agent only.

Does Zustand Store Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Zustand Store Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Zustand Store Patterns use?

Zustand Store Patterns is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Zustand Store Patterns use?

About 1.4k tokens (SKILL.md is roughly 5.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Zustand Store Patterns?

Skills that share tags, products or a category with Zustand Store Patterns: Xray UI Dev (bropines/xray-config-ui-editor, 119 stars), Opik Frontend Patterns (comet-ml/opik, 22k stars), State Management (emanueleielo/deepagents-open-lovable, 111 stars) and Frontend Large Feature Architecture (langfuse/langfuse, 36k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Zustand Store Patterns?

stellar (a GitHub organization) maintains it in stellar/laboratory, which has 112 GitHub stars. The repository holds 6 skills in this directory. The repository was last updated on October 3, 2026.

Source: stellar/laboratory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.