원클릭으로
data-state-management
Specifications for Zustand stores, React Query hooks, and the Service-Hook-Type pattern with optimistic updates.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Specifications for Zustand stores, React Query hooks, and the Service-Hook-Type pattern with optimistic updates.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
ZGO API development standards including pagination, error handling, and RESTful design
Test patterns, mocking strategies, and organization best practices
Standardized error format, error code clusters, and API client usage for consistent error handling.
Strict rules for environment variable management using Zod validation and src/config/env.ts.
Guidelines for managing internationalization (i18n) in the project using next-intl and unified translation patterns.
High-level overview of project structure, mock API architecture, and authentication flow.
| name | data-state-management |
| description | Specifications for Zustand stores, React Query hooks, and the Service-Hook-Type pattern with optimistic updates. |
This skill outlines the state management architecture of the project. It focuses on the separation of concerns between stateless services, React Query hooks for server state, and Zustand for global UI state.
src/store/auth-store.ts (Zustand + persist). Stores user data and system features.src/store/ui-store.ts (Zustand). Temporary/global UI states.All data handling must follow this layered architecture:
src/types/*.ts)Strictly type all domain models, DTOs, and query schemas.
src/services/*.ts)Pure functional objects that wrap HTTP requests. They do not hold state or use hooks.
import request from '@/http/request';
export const userService = {
get: () => request.get('/user'),
update: (id: string, data: UserUpdate) => request.patch(`/user/${id}`, data)
};
src/hooks/*.ts)Manage React Query state and side effects. Implement full CRUD with optimistic updates.
export function useUpdateExample() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }) => exampleService.update(id, data),
onMutate: async ({ id, data }) => {
await queryClient.cancelQueries({ queryKey: exampleKeys.detail(id) });
const prev = queryClient.getQueryData(exampleKeys.detail(id));
if (prev) queryClient.setQueryData(exampleKeys.detail(id), { ...prev, ...data });
return { prev };
},
onError: (err, { id }, context) => {
queryClient.setQueryData(exampleKeys.detail(id), context.prev);
toast.error(err.message);
},
onSettled: (data, err, { id }) => {
queryClient.invalidateQueries({ queryKey: exampleKeys.detail(id) });
}
});
}
[!TIP] Stateless Services: Always use the appropriate request instance (e.g.,
requestvsfileRequest) fromsrc/http/request.ts.