본문으로 건너뛰기
cccskills
무료GitHub에 공개

fec-state-management

Use when choosing, implementing, reviewing, or refactoring frontend state ownership across React, Vue, Next.js, Nuxt, URL state, server state, form state, browser persistence, or global stores. Prefer narrower skills for TanStack Query cache details, browser storage persistence, or form validation internals; Chinese triggers include state management, state ownership, store selection.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

실행 점수 미검증

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.5 KB
  • references/state-patterns.md3.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Front-end status management

Purpose

Determine clear ownership of front-end state to avoid global store bloat, duplicate caching, and derived state synchronization errors.

Procedure

1. Classify status sources first

Don't choose Redux, Zustand, Pinia or Context first. First mark each state to its unique owner, and then decide on the tool.

Status TypeTypical ExampleDefault Attribution
Local UI statePop-up window switch, tab, expand row, hover editing stateIn-component state / ref
Form statusInput value, dirty field, validation error, submittingForm library or form component
Server statusList, details, paging results, remote errorsRequest cache library
URL statusSearch terms, filter, sort, page number, selected tabRouting parameters / search params
Global client statusLogin users, topics, permission snapshots, shopping cart draftsGlobal store
Browser persistent stateDrafts, preferences, offline queues retained across refreshesStorage layer + state adapter
type ReportsStateMap = {
  search: "url";
  selectedReportId: "url";
  reports: "server-state-cache";
  isFilterPanelOpen: "local-ui";
  draftColumns: "browser-persistence";
};

2. Keep it minimal

Do not save a new copy of a value that can be inferred from props, server state, URL, or existing state.

interface Invoice {
  id: string;
  status: "draft" | "sent" | "paid";
}

function InvoiceList({ invoices }: { invoices: Invoice[] }) {
  const paidInvoices = invoices.filter((invoice) => invoice.status === "paid");

  return <span>{paidInvoices.length}</span>;
}

3. Select the React global state solution

Priority is given to localization and combination in React; the global store is only introduced when cross-page, cross-feature or unified actions are required.

import { create } from "zustand";

interface WorkspaceState {
  activeWorkspaceId: string | null;
  setActiveWorkspaceId: (workspaceId: string) => void;
}

export const useWorkspaceStore = create<WorkspaceState>((set) => ({
  activeWorkspaceId: null,
  setActiveWorkspaceId: (activeWorkspaceId) => set({ activeWorkspaceId }),
}));

Decision order:

  1. Use only in one component or a small subtree: useState / useReducer.
  2. Low-frequency global configuration or dependency injection: Context.
  3. Moderately complex business status: Zustand or Jotai, priority will be given based on the existing selection of the warehouse.
  4. Large applications, strict action flow, auditing or time travel debugging: Redux Toolkit.
  5. Remote data: Use the data acquisition skill to manage query keys, cache and invalidation policies.

4. Select Vue global state solution

In Vue 3, use provide/inject for local cross-level transfer; use Pinia or the existing store of the project for global business status.

import { computed, readonly, ref } from "vue";
import { defineStore } from "pinia";

export const useSessionStore = defineStore("session", () => {
  const userId = ref<string | null>(null);
  const isSignedIn = computed(() => userId.value !== null);

  function signIn(nextUserId: string) {
    userId.value = nextUserId;
  }

  return {
    userId: readonly(userId),
    isSignedIn,
    signIn,
  };
});

5. Clarify status boundaries and migration steps

When reconstructing the state, first make a state list, and then gradually move the read and write entries. Each step should keep the behavior verifiable.

interface StateMigrationItem {
  name: string;
  currentOwner: "component" | "context" | "store" | "query-cache" | "url";
  targetOwner: "component" | "context" | "store" | "query-cache" | "url";
  verification: string;
}

const migrationPlan: StateMigrationItem[] = [
  {
    name: "dashboard filters",
    currentOwner: "store",
    targetOwner: "url",
    verification: "refreshing the page preserves filters through search params",
  },
];

Detailed reference

Load references/state-patterns.md when you need Store shape examples, selector patterns, URL state synchronization, persistence adapters, SSR boundaries, or review checklists.

Constraints

  • Do not copy the server response to the global store; caching, invalidation and retries belong to the data acquisition layer.
  • Do not promote each field of the form to the global store; cross-step sharing is also handled first by the form context or submit draft adapter.
  • No need to use Context to carry large objects that change frequently; it will expand the re-rendering range.
  • Persistence state must specify field whitelist, version number, expiration policy and sensitive data exclusion.
  • In SSR scenarios, do not create a singleton store with user data at the top level of the module.

Expected Output

Output status attribution list, selection reasons, store/API boundaries and verification steps. Key behaviors such as loading/error/empty, refresh, rollback, cross-routing, and permission changes should be retained during implementation.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

用于审查或改进前端无障碍、语义结构、键盘支持、焦点管理、ARIA 标签、屏幕阅读器行为、WCAG 2.2 问题、触控无障碍或辅助技术回归;中文触发词包括 无障碍、accessibility、a11y、WCAG、屏幕阅读器。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

Use when reviewing or improving frontend accessibility, semantic structure, keyboard support, focus management, ARIA labels, screen reader behavior, WCAG 2.2 issues, touch accessibility, or assistive-technology regressions; Chinese triggers include accessibility, accessibility, a11y, WCAG, screen reader.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

Use when absorbing ideas, capabilities, workflows, architecture, quality systems, ecosystem extensions, or engineering practices from any reference system into the current project through original, project-native redesign rather than copying.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

用于从参考系统中吸收想法、能力、工作流、架构、质量体系、生态扩展或工程实践,并通过原创的项目内重设计转化为当前项目能力,而不是复制原实现。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

用于设计、实现或审查前后端 API 集成、类型化 API client、REST/tRPC/OpenAPI 客户端选型、认证刷新、API 错误映射、上传流程、SSE/WebSocket/轮询选择、CORS 相关前端行为或跨边界 loading/error 状态。不要用于纯后端服务架构或仅 TanStack Query 缓存策略;中文触发词包括 API 集成、前后端联调、typed API client、接口错误处理、SSE、WebSocket。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

Use when designing, implementing, or reviewing frontend-to-backend API integration, typed API clients, REST/tRPC/OpenAPI client choices, auth refresh, API error mapping, upload flows, SSE/WebSocket/polling choices, CORS-facing frontend behavior, or cross-boundary loading/error states. Do not use for backend-only service architecture or TanStack Query cache policy alone; Chinese triggers include API integration, front-end and back-end joint debugging, typed API client, Interface error handling, SSE, WebSocket.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

bovinphang/frontend-craft222026년 9월 26일 업데이트

bovinphang의 스킬 모두 보기

이 스킬의 문제 신고