State Management

v1.0.0

Deep workflow for client (and hybrid) state—modeling domain vs UI state, server cache vs client store, async and consistency, DevTools, persistence, and test...

0· 135·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for clawkk/state-management.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "State Management" (clawkk/state-management) from ClawHub.
Skill page: https://clawhub.ai/clawkk/state-management
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install state-management

ClawHub CLI

Package manager switcher

npx clawhub@latest install state-management
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
The name and description (deep state-management workflow) match the SKILL.md content. All guidance is about modeling client/server/UI state, libraries, and testing; no unexplained dependencies, credentials, or unrelated capabilities are requested.
Instruction Scope
SKILL.md is pure advisory content (design stages, rules, checklists). It does not instruct the agent to read files, access environment variables, call external endpoints, or transmit data outside the user's context. The instructions are scoped to interviewing the user, choosing patterns, and giving implementation advice.
Install Mechanism
No install specification or code files are present. This is the lowest-risk form: nothing is written to disk and no third-party packages are pulled in.
Credentials
The skill declares no required environment variables, credentials, or config paths. That is proportionate for a purely instructional design/architectural workflow.
Persistence & Privilege
always:false (default) and autonomous invocation is allowed (platform default). This is normal. One minor provenance note: the skill lists no homepage and the source is unknown; that reduces trust but does not create a technical incoherence.
Assessment
This skill is an instruction-only design guide for frontend state management and appears internally consistent and low-risk: it doesn't request creds, install code, or access files. Before installing, consider that the skill has no listed homepage or known source—if provenance matters for your team, prefer skills from trusted authors or inspect SKILL.md yourself. Also remember that although the skill can't execute code itself, an agent using it may suggest code changes or commands—avoid granting the agent repository write/push or cloud credentials unless you intend it to act on your codebase. If you want more assurance, ask the publisher for source or a homepage, or copy the guidance into an internal doc instead of installing the skill.

Like a lobster shell, security has layers — review code before you run it.

latestvk977gsyvdkd9m4a2dhezavd8v583g2d0
135downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

State Management (Deep Workflow)

Most “state bugs” are ownership and lifecycle bugs: who writes, when it syncs, and what happens on failure. Guide users to explicit models instead of ad-hoc globals.

When to Offer This Workflow

Trigger conditions:

  • Prop drilling pain, inconsistent UI, duplicate sources of truth
  • Stale data after mutations; optimistic UI gone wrong
  • Choosing a library vs Context vs server-state library (React Query, SWR, Apollo)
  • SSR/hydration + client state mismatches

Initial offer:

Use six stages: (1) inventory state kinds, (2) assign ownership, (3) server vs client boundaries, (4) async & updates, (5) persistence & URLs, (6) testing & DevTools. Confirm framework and data fetching approach.


Stage 1: Inventory State Kinds

Goal: Classify what state exists before picking tools.

Categories

  • Remote/server state: API responses, pagination, staleness—often not Redux-shaped
  • URL state: filters, tabs, selection when shareable/bookmarkable
  • Session UI state: modals, toggles, transient form drafts
  • Client-derived: sorted/filtered views of remote data—avoid storing both raw and derived as writable truths
  • Global cross-cutting: auth user, theme, feature flags—with clear read-only vs mutable rules

Exit condition: Table of state slicessource of truthconsumers.


Stage 2: Assign Ownership

Goal: One writer per piece of truth (or strict reducer pattern).

Rules of Thumb

  • Colocate state where it’s used if not shared—don’t globalize prematurely
  • Lift only when multiple subtrees need it or prop chains hurt and ownership is clear
  • Avoid copying server entities into multiple stores without sync rules

Exit condition: For each slice: who sets, who reads, invalidation story.


Stage 3: Server vs Client Boundaries

Goal: Prefer server-state libraries for remote data; use client stores for true client concerns.

Guidance

  • React Query / SWR / RTK Query: caching, dedupe, refetch, background refresh—use for HTTP JSON
  • GraphQL clients: normalized cache + mutations with update policies
  • Redux: great for predictable global client state + middleware—not every fetch response

Anti-patterns

  • Storing full API JSON in Redux without normalization when Apollo/Query would fit
  • Double fetch: SSR then client refetch without coordination—use hydration patterns

Exit condition: Remote data has defined cache keys, stale time, and mutation flow.


Stage 4: Async & Consistency

Goal: Loading, error, empty, and retry are first-class; optimistic updates are safe or scoped.

Practices

  • Optimistic UI: rollback path; idempotent mutations; server reconciliation
  • Ordering: serial vs parallel requests; race cancellation (AbortController)
  • Pagination/infinite scroll: cursor stability; dedupe pages

Concurrency

  • Last write wins awareness; versioning or ETags if server supports

Exit condition: User-visible failure modes handled; no silent stale success.


Stage 5: Persistence & URL

Goal: Decide what survives refresh, what is shareable, and security.

Options

  • URL query for filters/tabs when users share links
  • localStorage/sessionStorage for drafts—mind XSS risk (sensitive data → not localStorage)
  • IndexedDB for offline—complexity tax

Exit condition: Sensitive data never persisted client-side inappropriately.


Stage 6: Testing & DevTools

Goal: State logic is unit-testable; time-travel/debug when needed.

Practices

  • Pure reducers / small hooks for rules
  • Integration tests for critical flows with MSW or mock server
  • DevTools: Redux/Query panels—ensure team knows how to inspect cache

Final Review Checklist

  • State classified: remote vs UI vs URL vs derived
  • Single owner per truth; invalidation clear
  • Server cache strategy chosen for API data
  • Async/error/empty/optimistic paths specified
  • Persistence/security boundaries respected

Tips for Effective Guidance

  • Start minimal: Context + server-state library solves many “Redux-sized” problems.
  • Always ask: “What is the source of truth after mutation returns?”
  • Mention React Strict Mode double-invoke when debugging weird effect behavior.

Handling Deviations

  • Legacy Redux everywhere: incremental migration—feature modules first, remote data to Query next.
  • Non-React: map patterns to signals/stores (Vue Pinia, Svelte stores) with same ownership discipline.

Comments

Loading comments...