Add State Management
Workflow for introducing or extending state management
CLAUDE.md
When adding state management:
- Determine the scope: is this local component state, shared state between siblings, or global app state?
- Start with the simplest option. Use local state (useState) if only one component needs it.
- Lift state to the nearest common ancestor if siblings need to share it.
- Only reach for a global store (context, Zustand, Redux) when state is truly app-wide.
- Keep state close to where it’s used. Global state for local concerns causes unnecessary re-renders and complexity.
- Define the state shape as a type. Include loading and error states for async data.
- Write tests that verify state transitions, not internal store implementation.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.