Workflow Development

Add State Management

Workflow for introducing or extending state management

statefrontendarchitecture
CLAUDE.md

When adding state management:

  1. Determine the scope: is this local component state, shared state between siblings, or global app state?
  2. Start with the simplest option. Use local state (useState) if only one component needs it.
  3. Lift state to the nearest common ancestor if siblings need to share it.
  4. Only reach for a global store (context, Zustand, Redux) when state is truly app-wide.
  5. Keep state close to where it’s used. Global state for local concerns causes unnecessary re-renders and complexity.
  6. Define the state shape as a type. Include loading and error states for async data.
  7. 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.

get crystl