migrate-state-management
하는 일
이 스킬은 React 앱의 상태 관리를 Redux와 React Context에서 벗어나도록 리팩터링하는 과정을 AI 에이전트에게 안내합니다. 프론트엔드 상태 코드를 현대화하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓Redux나 React Context를 없애고 데이터 조회 상태를 React Query로 옮기고 싶을 때.
- ✓필터나 기간을 공유할 수 있도록 URL에 두고 싶어 nuqs를 쓰고 싶을 때.
- ✓전역 클라이언트 상태에 더 단순한 자리가 필요해 Zustand로 옮기고 싶을 때.
스킬 링크
https://github.com/SigNoz/signoz/blob/main/frontend/.cursor/skills/migrate-state-management/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Redux 스토어의 API 데이터는 React Query로 옮기고, 필터는 URL에 유지해 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 각 상태를 서버 상태, URL 상태, 전역 클라이언트 상태로 분류한 뒤, 각 상태를 맞는 도구로 옮깁니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Migrate State: Redux/Context → React Query, nuqs, Zustand
Do not introduce or recommend Redux or React Context. Migrate existing usage to the stack below.
1. Classify the state
Before changing code, classify what the state represents:
| If the state is… | Migrate to | Do not use |
|---|---|---|
| From API / server (versions, configs, fetched lists, time-series) | React Query | Redux, Context |
| Shareable via URL (filters, time range, page, selected ids) | nuqs | Redux, Context |
| Global/client UI (dashboard lock, query builder, feature flags, large client objects) | Zustand | Redux, Context |
| Local to one component (inputs, toggles, hover) | useState / useReducer | Zustand, Redux, Context |
If one slice mixes concerns (e.g. Redux has both API data and pagination), split: API → React Query, pagination → nuqs, rest → Zustand or local state.
2. Migrate to React Query (server state)
When: State comes from or mirrors an API response (e.g. currentVersion, latestVersion, configs, lists).
Steps:
- Find where the data is fetched (existing
useQuery/API call) and where it is dispatched or set in Context/Redux. - Remove the dispatch/set that writes API results into Redux/Context.
- Expose a single hook that uses the query and returns the same shape consumers expect (use
useMemofor derived objects likeconfigsto avoid unnecessary re-renders). - Replace Redux/Context consumption with the new hook. Prefer generated React Query hooks from
frontend/src/api/generatedwhen available. - Configure cache/refetch (e.g.
refetchOnMount: false,staleTime) so behavior matches previous “single source” expectations.
Before (Redux mirroring React Query):
if (getUserLatestVersionResponse.isFetched && getUserLatestVersionResponse.isSuccess && getUserLatestVersionResponse.data?.payload) {
dispatch({ type: UPDATE_LATEST_VERSION, payload: { latestVersion: getUserLatestVersionResponse.data.payload.tag_name } })
}
After (single source in React Query):
export function useAppStateHook() {
const { data, isError } = useQuery(...)
const memoizedConfigs = useMemo(() => ({ ... }), [data?.configs])
return {
latestVersion: data?.payload?.tag_name,
configs: memoizedConfigs,
isError,
}
}
Consumers use useAppStateHook() instead of useSelector or Context. Do not copy React Query result into Redux or Context.
3. Migrate to nuqs (URL / shareable state)
When: State should be in the URL: filters, time range, pagination, selected values, view state. Keep payload small (e.g. Chrome ~2k chars); no large datasets or sensitive data.
Steps:
- Identify which Redux/Context fields are shareable or already reflected in the URL (e.g.
currentPage,timeRange,selectedFilter). - Add nuqs (or use existing):
useQueryState('param', parseAsString.withDefault('…'))(orparseAsInteger, etc.). - Replace reads/writes of those fields with nuqs hooks. Use typed parsers; avoid ad-hoc
useSearchParamsencoding/decoding. - Remove the same fields from Redux/Context and their reducers/providers.
Before (Context/Redux):
const { timeRange } = useContext(SomeContext)
const [page, setPage] = useDispatch(...)
After (nuqs):
const [timeRange, setTimeRange] = useQueryState('timeRange', parseAsString.withDefault('1h'))
const [page, setPage] = useQueryState('page', parseAsInteger.withDefault(1))
4. Migrate to Zustand (global client state)
When: State is global or cross-component client state: feature flags, dashboard state, query builder state, complex/large client objects (e.g. up to ~1.5–2MB). Not for server cache or local-only UI.
Steps:
- Create one store per domain (e.g.
DashboardStore,QueryBuilderStore). Onecreate()per module; for large state use slice factories and combine. - Put state properties first, then actions. Use
set(orsetState/getState()+set) for updates; never mutate state directly. - Replace Context/Redux consumption with the store hook and a selector so only the used slice triggers re-renders.
- Remove the old Context provider / Redux slice and related dispatches.
Selector (required):
const isLocked = useDashboardStore(state => state.isDashboardLocked)
Never use useStore() with no selector. Never do state.foo = x inside actions; use set(state => ({ ... })).
Before (Context/Redux):
자주 묻는 질문
왜 Redux를 유지하지 않나요?
스킬은 Redux나 React Context를 새로 도입하거나 추천하지 말고, 기존 사용도 옮기라고 말합니다.
nuqs는 무엇을 다루나요?
필터, 페이지, 선택한 항목처럼 URL로 공유되어야 하는 상태를 다룹니다.
로컬 상태는 어떻게 하나요?
한 컴포넌트에만 속한 상태는 useState나 useReducer를 써야 합니다.
상세 정보
작성자의 원본 설명
Migrate Redux or React Context to the correct state option (React Query for server state, nuqs for URL/shareable state, Zustand for global client state). Use when refactoring away from Redux/Context, moving state to the right store, or when the user asks to migrate state management.
repo: SigNoz/signoz
인기도
- GitHub 스타
- 33k
- 순위
- #9146
- 라이선스
- —
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
sbshot-visual-diff
33k에이전트가 Storybook 스토리의 변경 전후 스크린샷을 비교해, 리뷰어가 변경으로 화면에서 무엇이 달라졌는지 볼 수 있게 합니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.