Community코딩 & 개발github.com

jezweb/zustand-state-management

React에서 Zustand로 타입 안전한 전역 상태를 구축합니다. TypeScript, persist 미들웨어, devtools, 슬라이스 패턴, Next.js SSR 및 하이드레이션 처리를 지원합니다. 6가지 문서화된 오류를 방지합니다. React 상태 설정, Redux/Context 마이그레이션, 또는 하이드레이션 오류, TypeScript 추론, 무한 렌더 루프, persist 경합 조건 문제 해결 시 사용하세요.

zustand-state-management란 무엇인가요?

이 스킬은 Zustand를 사용하여 React 애플리케이션에서 타입 안전한 전역 상태 관리를 구현하는 방법을 안내합니다. TypeScript를 완벽하게 지원하며, persist 미들웨어를 통한 상태 지속성, devtools를 통한 디버깅, slices 패턴을 통한 상태 분할, 그리고 Next.js SSR 환경에서의 하이드레이션 오류 처리를 포함합니다. Redux나 React Context에서 Zustand로 마이그레이션하려는 개발자에게 특히 유용하며, 일반적인 6가지 오류(하이드레이션 불일치, TypeScript 추론 실패, 무한 렌더 루프, persist 경합 조건 등)의 해결 방법을 문서화하고 있습니다. Claude Code, Cursor, Codex와 같은 AI 에이전트 플랫폼에서 이 스킬을 사용하면 안정적이고 성능 좋은 상태 관리 코드를 자동 생성할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jezweb/claude-skills/tree/main/skills/zustand-state-management

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

zustand-state-management은(는) 무엇을 하나요?

React에서 Zustand로 타입 안전한 전역 상태를 구축합니다. TypeScript, persist 미들웨어, devtools, 슬라이스 패턴, Next.js SSR 및 하이드레이션 처리를 지원합니다. 6가지 문서화된 오류를 방지합니다. React 상태 설정, Redux/Context 마이그레이션, 또는 하이드레이션 오류, TypeScript 추론, 무한 렌더 루프, persist 경합 조건 문제 해결 시 사용하세요.

주요 기능

  • 타입 안전한 상태: TypeScript로 완전한 타입 추론 지원
  • persist 미들웨어: localStorage, AsyncStorage 등에 상태 자동 저장 및 복원
  • devtools: Redux DevTools와 통합 가능 (디버깅 용이)
  • 슬라이스 패턴: 여러 개의 상태 조각을 하나의 store로 결합
  • Next.js SSR: 하이드레이션 오류를 방지하는 useHydration 훅 제공
  • 6가지 오류 방지: 일반적인 Zustand 사용 오류를 사전에 차단

사용법

기본 store 생성

import { create } from 'zustand'

interface BearStore {
  bears: number
  increase: () => void
  removeAll: () => void
}

export const useBearStore = create<BearStore>((set) => ({
  bears: 0,
  increase: () => set((state) => ({ bears: state.bears + 1 })),
  removeAll: () => set({ bears: 0 }),
}))

persist 미들웨어 사용

import { create } from 'zustand'
import { persist } from 'zustand/middleware'

interface ThemeStore {
  theme: 'light' | 'dark'
  toggleTheme: () => void
}

export const useThemeStore = create<ThemeStore>()(
  persist(
    (set) => ({
      theme: 'light',
      toggleTheme: () =>
        set((state) => ({
          theme: state.theme === 'light' ? 'dark' : 'light',
        })),
    }),
    {
      name: 'theme-storage', // localStorage 키 이름
    }
  )
)

devtools 통합

import { create } from 'zustand'
import { devtools } from 'zustand/middleware'

interface CounterStore {
  count: number
  increment: () => void
  decrement: () => void
}

export const useCounterStore = create<CounterStore>()(
  devtools(
    (set) => ({
      count: 0,
      increment: () => set((state) => ({ count: state.count + 1 })),
      decrement: () => set((state) => ({ count: state.count - 1 })),
    }),
    {
      name: 'counter-store', // devtools에 표시될 이름
    }
  )
)

슬라이스 패턴

import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'

// 각 슬라이스 정의
interface FishSlice {
  fishes: number
  addFish: () => void
}

interface BearSlice {
  bears: number
  addBear: () => void
}

const createFishSlice = (set: any) => ({
  fishes: 0,
  addFish: () => set((state: any) => ({ fishes: state.fishes + 1 })),
})

const createBearSlice = (set: any) => ({
  bears: 0,
  addBear: () => set((state: any) => ({ bears: state.bears + 1 })),
})

// store 생성 시 슬라이스 결합
export const useBoundStore = create<FishSlice & BearSlice>()(
  devtools(
    persist(
      (...a) => ({
        ...createFishSlice(...a),
        ...createBearSlice(...a),
      }),
      { name: 'bound-store' }
    )
  )
)

Next.js SSR에서 하이드레이션 처리

// hooks/useHydration.ts
import { useEffect, useState } from 'react'

export const useHydration = () => {
  const [hydrated, setHydrated] = useState(false)

  useEffect(() => {
    setHydrated(true)
  }, [])

  return hydrated
}
// components/MyComponent.tsx
import { useHydration } from '@/hooks/useHydration'
import { useThemeStore } from '@/stores/themeStore'

export default function MyComponent() {
  const hydrated = useHydration()
  const theme = useThemeStore((state) => state.theme)

  if (!hydrated) {
    return <div>Loading...</div> // 하이드레이션 전에는 기본값 표시
  }

  return <div>Current theme: {theme}</div>
}

방지되는 6가지 오류

  1. 하이드레이션 불일치: SSR에서 클라이언트 렌더링 시 텍스트/속성 불일치
  2. TypeScript 추론 실패: 제네릭 타입 누락으로 인한 any 타입 추론
  3. 무한 렌더 루프: 컴포넌트 내부에서 selector 없이 전체 store 구독
  4. persist 경합 조건: create와 persist 호출 순서 오류로 인한 상태 손실
  5. 구독 누수: 컴포넌트 언마운트 시 제거되지 않은 구독
  6. 불변성 위반: 상태를 직접 변경하여 예측 불가능한 동작 유발

추가 자료

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

jezweb/ai-image-generator

Generate AI images using Gemini or GPT APIs directly. Covers model selection (Gemini for scenes; GPT Image 2 for text rendering, batch variations, multi-reference compositing; GPT Image 1.5 for transparent icons), the 5-part prompting framework, API calling patterns, multi-turn editing, and quality assurance. Produces photorealistic scenes, icons, illustrations, OG images, posters, infographics, and product shots. Use when building websites that need images, creating marketing assets, or generating visual content. Triggers: 'generate image', 'ai image', 'create hero image', 'make an icon', 'generate illustration', 'create og image', 'poster', 'infographic', 'image variations', 'gpt-image-2', 'ai art', 'image generation'.

jezweb/aussie-business-english

Australian business English writing style for professional communications — warm, direct, EN-AU spelling (colour, organise, centre). Use whenever the user is writing for an Australian audience: emails, chat messages, proposals, client communications, blog posts, web copy, or any business writing. Apply to drafting, editing, and tone-checking professional text.

jezweb/claude-skills

Generate project documentation from codebase analysis — ARCHITECTURE.md, API_ENDPOINTS.md, DATABASE_SCHEMA.md. Reads source code, schema files, routes, and config to produce accurate, structured docs. Use when starting a project, onboarding contributors, or when docs are missing or stale. Triggers: 'generate docs', 'document architecture', 'create api docs', 'document schema', 'project documentation', 'write architecture doc'.

jezweb/claude-skills

Agent skill at plugins/social-media/skills/social-media-posts/SKILL.md

jezweb/claude-skills

Generate a complete, deployable landing page from a brief. Produces a single self-contained HTML file with Tailwind CSS (via CDN), responsive design, dark mode, semantic HTML, and OG meta tags. Sections: hero with CTA, features, social proof, pricing (optional), FAQ, footer. Use when building a marketing page, product launch page, coming soon page, or any standalone landing page. Triggers: 'landing page', 'create a page', 'marketing page', 'launch page', 'coming soon page', 'one-page site'.

jezweb/cloudflare-worker-builder

Scaffold and deploy Cloudflare Workers with Hono routing, Vite plugin, and Static Assets. Describe project, scaffold structure, configure bindings, deploy. Use whenever the user wants to create a Worker project, set up Hono on Cloudflare, configure D1 / R2 / KV / Queues bindings, or troubleshoot Worker export syntax, API route conflicts, HMR issues, or deployment failures.

jezweb/color-palette

Generate complete, accessible colour palettes from a single brand hex. Produces 11-shade scale (50-950), semantic tokens, dark mode variants, Tailwind v4 CSS output, WCAG contrast checks. Use whenever the user supplies a brand hex and asks for a palette, mentions setting up a design system, wants Tailwind theme colours from a brand colour, or asks to check colour accessibility / contrast.

jezweb/d1-drizzle-schema

Generate Drizzle ORM schemas for Cloudflare D1 databases with correct D1-specific patterns. Produces schema files, migration commands, type exports, and DATABASE_SCHEMA.md documentation. Handles D1 quirks: foreign keys always enforced, no native BOOLEAN/DATETIME types, 100 bound parameter limit, JSON stored as TEXT. Use when creating a new database, adding tables, or scaffolding a D1 data layer.

jezweb/elevenlabs-agents

Build conversational AI voice agents on the ElevenLabs platform. Configure agent + tools + knowledge base, integrate SDK (React / React Native / Swift / JS / server-side), test, deploy. Use whenever the user mentions ElevenLabs, building a voice agent, an AI phone system, an AI receptionist, conversational AI, or troubleshooting deprecated @11labs packages, webhook errors, CSP violations, localhost allowlist, or tool parsing errors.

jezweb/fastapi

Build Python APIs with FastAPI, Pydantic v2, and SQLAlchemy 2.0 async. Covers project structure, JWT auth, validation, and database integration with uv package manager. Prevents 7 documented errors. Use when: creating Python APIs, implementing JWT auth, or troubleshooting 422 validation, CORS, async blocking, form data, background tasks, or OpenAPI schema errors.

jezweb/favicon-gen

Generate custom favicons from logos, text, or brand colours. Produces favicon.svg, favicon.ico, apple-touch-icon.png, icon-192/512.png, and web manifest. Use whenever the user wants a favicon, mentions replacing a CMS default favicon, converting a logo into a favicon, creating branded initials icons, or troubleshooting favicon not displaying / iOS black square / missing manifest.

jezweb/github-release

Prepare and publish GitHub releases. Sanitizes code for public release (secrets scan, personal artifacts, LICENSE/README validation), creates version tags, and publishes via gh CLI. Trigger with 'release', 'publish', 'open source', 'prepare for release', 'create release', or 'github release'.

jezweb/google-apps-script

Build Google Apps Script automation for Sheets and Workspace. Custom menus, triggers (onEdit / time-driven / form submit), dialogs, sidebars, email batches, PDF export, external API. Use whenever the user wants to automate a Google Sheet, build a Sheets menu / sidebar / dialog, hit a Sheets row from email or a webhook, schedule a Sheets workflow, or asks 'how do I script this in Sheets'.

jezweb/google-chat-messages

Send Google Chat messages via incoming webhooks — text, rich cards (cardsV2), threaded replies. TypeScript types, card builder utility, widget reference inline. Use whenever the user wants to post to Google Chat from a script, build a chatbot reply, send a notification card, build a Google Chat webhook integration, or troubleshoot card / threading issues.

jezweb/hono-api-scaffolder

Scaffold Hono API routes for Cloudflare Workers. Produces route files, middleware, typed bindings, Zod validation, error handling, and API_ENDPOINTS.md documentation. Use after a project is set up with cloudflare-worker-builder or vite-flare-starter, when you need to add API routes, create endpoints, or generate API documentation.

jezweb/icon-set-generator

Generate cohesive, project-specific SVG icon sets for websites and applications. Use this skill whenever the user needs custom icons, an icon set for a website or app, icons for a client project, or mentions needing SVG icons that look consistent together. Also trigger when the user describes a project and icons would naturally be part of the deliverable — e.g. 'I'm building a site for a plumber' implies they'll need service icons. Trigger on: 'icons for', 'icon set', 'custom icons', 'SVG icons', 'make me icons', 'I need icons', 'website icons', 'project icons', or any request for consistent visual assets for a web project. Produces individual SVG files with a consistent style engine, not generic icon library lookups.

jezweb/image-processing

Process images for web development — resize, crop, trim whitespace, convert formats (PNG/WebP/JPG), optimise file size, generate thumbnails, create OG card images. Uses Pillow (Python) — no ImageMagick needed. Trigger with 'resize image', 'convert to webp', 'trim logo', 'optimise images', 'make thumbnail', 'create OG image', 'crop whitespace', 'process image', or 'image too large'.

jezweb/mcp-builder

Build MCP servers in Python with FastMCP. Define tools / resources / prompts, build the server, test locally, deploy to FastMCP Cloud or Docker. Use whenever the user mentions building an MCP server, exposing tools to LLMs, FastMCP, building a Claude integration, or troubleshooting FastMCP module-level server, storage, lifespan, middleware, OAuth, or deployment errors.

jezweb/nextjs

Build Next.js 16 apps with App Router, Server Components/Actions, Cache Components ("use cache"), and async route params. Includes proxy.ts and React 19.2. Prevents 25 documented errors. Use when: building Next.js 16 projects, or troubleshooting async params (Promise types), "use cache" directives, parallel route 404s, Turbopack issues, i18n caching, navigation throttling.

jezweb/project-health

All-in-one project configuration and health management. Sets up new projects (settings.local.json, CLAUDE.md, .gitignore), audits existing projects (permissions, context quality, MCP coverage, leaked secrets, stale docs), tidies accumulated cruft, captures session learnings, and adds permission presets. Uses sub-agents for heavy analysis to keep main context clean. Trigger with 'project health', 'check project', 'setup project', 'kickoff', 'bootstrap', 'tidy permissions', 'clean settings', 'capture learnings', 'audit context', 'add python permissions', or 'init project'.

관련 스킬