Skip to main content
prompt GP ChatGPT

React State Management taste — ChatGPT and Claude.ai prompt

A ruleset for picking React state tools: when to use useState, Zustand, Context and TanStack Query. Helps avoid overbuilt global stores and duplicated state.

Open on GitHub

What React State Management taste does

This prompt lays out rules for choosing state management in a React app. It starts with local useState, lifting state only when two sibling components genuinely need it. Server data gets treated as a cache through TanStack Query, not dumped into a global store.

Filters, tabs and pagination belong in search params. Shared client state that outgrows a single component tree goes to Zustand. Redux is not recommended for new projects unless the team already relies on its devtools and middleware.

Separate rules cover async status (one union instead of several booleans), forms (React Hook Form with a zod schema), optimistic updates and rollbacks. The prompt pushes for explicit typing of stores and context values with no any. It is an opinionated checklist with confidence scores from 0.70 to 0.95.

What it helps with

  • decide between useState, Zustand and Context for a feature
  • stop keeping server data in a global store
  • move filters and pagination into the URL
  • remove state duplicated through useEffect
  • type stores without any

Example prompts for the agent

  • Paste the prompt into ChatGPT and ask which store to use for a shopping cart
  • Give the prompt to Claude.ai and describe a component with filters: where should filter state live
  • Ask the assistant to review my code against these rules and point out where state is misplaced

How to install React State Management taste

How to use

Paste the text at the start of a chat or into project instructions

Questions about React State Management taste

How do I install React State Management taste in Claude Code?

Add the prompt to .claude/commands/prompts.csv.md. The prompts.csv command then becomes available in Claude Code.

What does React State Management taste do?

It is a collection of rules for choosing React state tools: when to use local useState, Context, Zustand or TanStack Query. Each rule carries a confidence score.

Can I use this prompt in ChatGPT?

Yes, the prompt works with ChatGPT and Claude.ai. Paste it at the start of a conversation so the assistant follows these rules when giving React advice.

Source text

prompts.csv · CC0-1.0
# React State Management taste
- Start with local useState and lift state only when two siblings truly need it. Confidence: 0.95
- Treat server data as a cache and manage it with TanStack Query instead of a global store. Confidence: 0.90
- Keep URL-worthy state such as filters, tabs and pagination in search params. Confidence: 0.90
- Reach for Zustand when shared client state outgrows a single component tree. Confidence: 0.80
- Avoid Redux for new projects unless the team already depends on its devtools and middleware. Confidence: 0.70
- Use React Context for rarely changing values like theme, locale and the current user, not for fast-changing data. Confidence: 0.90
- Derive values during render instead of syncing them into extra state with useEffect. Confidence: 0.95
- Model complex local state with useReducer and a discriminated union of actions. Confidence: 0.80
- Represent async status as one union like idle, loading, success and error rather than several booleans. Confidence: 0.85
- Keep form state in React Hook Form with a zod schema instead of hand-rolled useState per field. Confidence: 0.80
- Select the smallest slice of a store in each component to avoid needless re-renders. Confidence: 0.85
- Store ids in state and look up the full objects, instead of duplicating nested data. Confidence: 0.80
- Use optimistic updates for quick user actions and roll back on error. Confidence: 0.75
- Never mutate state objects in place; return new objects or use Immer for deep updates. Confidence: 0.90
- Keep persisted state small and versioned when saving it to localStorage. Confidence: 0.75
- Reset component state by changing its key instead of writing reset effects. Confidence: 0.80
- Colocate stores with the feature that owns them rather than in one global store folder. Confidence: 0.75
- Type every store and context value explicitly and avoid any in state shapes. Confidence: 0.90

© f · CC0-1.0 · f/prompts.chat

Similar prompts

All prompts for Frontend and UI →

From the same set77

The whole set →
Kubernetes taste A prompt that hands your AI assistant a platform team's Kubernetes rules: GitOps, probes, resources, pod security. Useful when you ask a model to write or review manifests. GP ChatGPT ★ 174,597repo stars Git Workflow taste A prompt that gives an AI assistant trunk-based habits: short-lived branches, Conventional Commits, squash-merge and a protected main. GP ChatGPT ★ 174,597repo stars Monorepo taste A prompt that hands the agent a fixed set of monorepo conventions: pnpm workspaces, Turborepo, package boundaries and shared configs. Useful when repo structure keeps drifting. GP ChatGPT ★ 174,597repo stars Rust CLI taste A prompt that tells the model how to write a Rust command-line tool: argument parsing, error handling, output streams, tests. GP ChatGPT ★ 174,597repo stars Observability taste A prompt that tells an AI assistant how to wire traces, metrics and logs into a service. Handy when you ask a model to write instrumented code. GP ChatGPT ★ 174,597repo stars Python Packaging taste A prompt that hands the model a fixed set of Python packaging rules: pyproject.toml, src/, uv, Ruff. Useful when a new package needs one consistent style. GP ChatGPT ★ 174,597repo stars Open Source Release Checklist Builder (YAML) This prompt turns an upcoming open-source release into a YAML checklist for versions, tests, artifacts, security notes, rollback, and announcements. GP ChatGPT ★ 174,597repo stars Dockerfile and CI taste A prompt that lists rules for Dockerfiles and CI: multi-stage builds, non-root user, image scanning. Useful when you ask an AI to write or review a build config. GP ChatGPT ★ 174,597repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor