本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)48k · #6244

zustand-store-ts

できること

このコードは、Zustandライブラリを使ってWebアプリケーション用のデータ「ストア」を作成するのに役立ちます。データの保存方法や、データへのアクセス・変更の仕組みを整理し、TypeScriptで正しく動作するようにします。

使う場面

  • ✓アプリの多くの部分で使われる情報を保存する必要があるとき
  • ✓プロジェクトの状態管理の仕組みを構築するとき
  • ✓時間とともに変化する共通データを整理したいとき

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/zustand-store-ts/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/zustand-store-ts/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ショッピングカートの状態を管理するストアを作成してください。商品と合計金額を含み、商品を追加・削除する関数も用意してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

保存する内容(状態)と、そのデータに対する操作(アクション)を定義するパターンを使います。また、データが変わったときに、必要な部分だけが更新されるようにします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Zustand Store

Create Zustand stores following established patterns with proper TypeScript types and middleware.

Quick Start

Copy the template from assets/template.ts and replace placeholders:

  • {{StoreName}} → PascalCase store name (e.g., Project)
  • {{description}} → Brief description for JSDoc

Always Use subscribeWithSelector

import { create } from 'zustand';
import { subscribeWithSelector } from 'zustand/middleware';

export const useMyStore = create<MyStore>()(
  subscribeWithSelector((set, get) => ({
    // state and actions
  }))
);

Separate State and Actions

export interface MyState {
  items: Item[];
  isLoading: boolean;
}

export interface MyActions {
  addItem: (item: Item) => void;
  loadItems: () => Promise<void>;
}

export type MyStore = MyState & MyActions;

Use Individual Selectors

// Good - only re-renders when `items` changes
const items = useMyStore((state) => state.items);

// Avoid - re-renders on any state change
const { items, isLoading } = useMyStore();

Subscribe Outside React

useMyStore.subscribe(
  (state) => state.selectedId,
  (selectedId) => console.log('Selected:', selectedId)
);

Integration Steps

  1. Create store in src/frontend/src/store/
  2. Export from src/frontend/src/store/index.ts
  3. Add tests in src/frontend/src/store/*.test.ts

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
よくある質問

「Zustand」とは何ですか?

Zustandは、Webアプリケーションでのデータ管理を簡単にするライブラリです。

「TypeScript」とは何ですか?

TypeScriptは、コードのエラーを防ぐために追加のチェック機能を備えたプログラミング言語です。

「ミドルウェア」とは何ですか?

ミドルウェアは、ストアに追加機能を加える「プラグイン」のようなものです。変更のログ記録や、非同期処理の管理などを行えます。

詳細

作者による元の説明

Create Zustand stores following established patterns with proper TypeScript types and middleware.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#6244
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル