pinia
できること
このスキルは、Vueの公式状態管理ライブラリであるPiniaを使って、Vueアプリの共有データを整理する方法を説明します。アプリの多くの部分で同じデータが必要な開発者のためのものです。
使う場面
- ✓多くのコンポーネントでデータを共有する必要があるVueアプリを作っているとき。
- ✓状態、ゲッター、アクションを持つストアを設定したいとき。
- ✓Piniaのストアをテストまたは拡張する必要があるとき。
スキルのリンク
https://github.com/antfu/skills/blob/main/skills/pinia/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“ショッピングカートの商品と合計金額をすべてのページで保持するPiniaストアを作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、共有データを保持するストアと、それを変更するアクションを設定します。型、テスト、拡張に関するPiniaの指針に従います。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Pinia
Pinia is the official state management library for Vue, designed to be intuitive and type-safe. It supports both Options API and Composition API styles, with first-class TypeScript support and devtools integration.
The skill is based on Pinia v4.0.3, generated at 2026-09-25.
Core References
| Topic | Description | Reference |
|---|---|---|
| Stores | Defining stores, state, getters, actions, storeToRefs, subscriptions | core-stores |
Features
Extensibility
| Topic | Description | Reference |
|---|---|---|
| Plugins | Extend stores with custom properties, state, and behavior | features-plugins |
Composability
| Topic | Description | Reference |
|---|---|---|
| Composables | Using Vue composables within stores (VueUse, etc.) | features-composables |
| Composing Stores | Store-to-store communication, avoiding circular dependencies | features-composing-stores |
Best Practices
| Topic | Description | Reference |
|---|---|---|
| Testing | Unit testing with @pinia/testing, mocking, stubbing | best-practices-testing |
| Outside Components | Using stores in navigation guards, plugins, middlewares | best-practices-outside-component |
Advanced
| Topic | Description | Reference |
|---|---|---|
| SSR | Server-side rendering, state hydration | advanced-ssr |
| Nuxt | Nuxt integration, auto-imports, SSR best practices | advanced-nuxt |
| HMR | Hot module replacement for development | advanced-hmr |
Key Recommendations
- Prefer Setup Stores for complex logic, composables, and watchers
- Use
storeToRefs()when destructuring state/getters to preserve reactivity - Actions can be destructured directly - they're bound to the store
- Call stores inside functions not at module scope, especially for SSR
- Add HMR support to each store for better development experience
- Use
@pinia/testingfor component tests with mocked stores
よくある質問
Piniaは Vue専用ですか?
はい。Vueアプリのために作られており、このスキルもそれを扱います。
ストアをテストできますか?
はい。ストアのテストとモックについても扱われています。
TypeScriptで使えますか?
はい。Piniaは型に安全に作られており、TypeScriptに対応しています。
詳細
作者による元の説明
Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.
repo: antfu/skills
人気
- GitHubのスター
- 6.0k
- ランキング
- #14442
- ライセンス
- MIT
- 更新日
- 2026/10/30
コメント
- …
このリポジトリの他のスキル
antfu-create-pr
6.0kブランチから、変更内容と理由をわかりやすくまとめたGitHubのプルリクエストを、エージェントが開けるよう支援します。
antfu-issue-triage
6.0k開いているGitHubのissueとプルリクエストを整理し、重複や修正済みのものを見つけて、操作の前に確認を取るようエージェントを支援します。
antfu-query
6.0k計画やアイデアについて一度に一つずつ質問し、二人で明確でテスト済みの理解に至るまでエージェントが問いかけます。
antfu-simplify
6.0kコードの変更を、必要な部分だけを残した最小限の正しい形に減らすようエージェントを支援します。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。