The PR adds Zustand so a settings modal can keep an open flag. The repo already uses Redux (or Recoil, or a single React context plus React Query) for app state, and local useState for UI that does not need to be global. The new dependency is a second source of truth, a second devtools path, and a new pattern for the next agent to copy.
I’ve started treating a new state library in a feature PR as a scope break, even if the modal works. One widget is not a reason to change how the app holds state.
Why the extra library shows up
Many training examples reach for Zustand or Redux Toolkit as the default. The model will not audit package.json unless you say “we already have X; do not add Y.” A modal’s open flag also does not need a store at all.
You pay twice: bundle size, and a review surface where some flows go through the existing store and others go through the new one.
A simple state-library policy
- Use the existing state approach (the current store, server cache, or local state)
- Do not add Zustand, Redux, Jotai, Valtio, or a new context framework in a feature PR
- UI-only state stays local unless something distant already needs to read it
- A migration off the current library is its own PR, with a plan, not a side effect of a modal
If the existing store is painful for this case, say that in the PR. Do not quietly start a second one.
What to put in the prompt
Do not add a new state-management library. Use the existing store/helpers in src/store (or local useState) for this UI. A modal open flag should be local state unless another route already needs it. If the current store cannot express this, stop and explain; do not install a second library. Paste package.json dependencies and one existing store usage. In review, search the diff for new packages (zustand, jotai, recoil, a second Redux wrapper) and for a new createStore / createContext used only by the new widget.
Reject / send back
Reject
- A new state library added for one component
- Global store state for a purely local
open/tabflag - A second context “provider layer” that duplicates the existing store
- A partial migration that leaves both libraries in the tree
Accept
- Local state for widget-only UI
- A change that goes through the existing store or server cache
- A dedicated RFC or migration PR, not mixed into a feature
