pinia

Document Pinia setup store conventions for Vue projects.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/CloudyWing/ai-dotfiles --skill pinia-cloudywing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pinia
Source: https://github.com/CloudyWing/ai-dotfiles/tree/main/skills/pinia
Command: npx skills add https://github.com/CloudyWing/ai-dotfiles --skill pinia-cloudywing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pinia state management guidelines to enforce consistent store design, setup-store usage, cross-store interactions, and persistence across Vue projects, streamlining maintainability and collaboration.

Core Features & Use Cases

  • Setup Store 優先:始終使用 Setup Store(函式寫法)與 Composition API 風格,提升型別推斷與可維護性。
  • 交叉儲存互動:示例說明不同 Store 之間的資料共享與協調,避免循環依賴與狀態不一致。
  • 命名慣例與分工:清晰的 Domain 導向分組與檔案結構,方便團隊協作與可測性。
  • 持久化策略:指導僅持久化必要資料(如 Token),並提供使用 pinia-plugin-persistedstate 的實作要點。
  • 與元件整合:在元件中正確使用 store、解構注意事項與最佳實踐。

Quick Start

Create a sample setup store with defineStore and import it in a component to begin using Pinia.

Frequently Asked Questions about pinia

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Pinia setup stores for better type inference in Vue?

Pinia setup stores use Composition API functions to define state and actions, providing superior type inference and maintainability for Vue state management compared to Options stores.

What's the best way to handle cross-store interactions in Pinia without circular dependencies?

Cross-store interactions in Pinia require importing target stores within actions to share data and coordinate logic, preventing circular dependencies and state inconsistency across Vue modules.

How to persist only necessary data like tokens using Pinia persistence?

Pinia persistence should only store necessary data like authentication tokens by configuring specific paths within pinia-plugin-persistedstate, ensuring sensitive or transient Vue state remains unaffected.

Can I migrate my existing Vue Options stores to Pinia setup stores?

Migrating Options stores to Pinia setup stores involves refactoring state objects and methods into refs and functions, adopting a Composition API style for consistent store structure across modules.

How do I correctly destructure Pinia store properties inside Vue components?

Destructuring Pinia store properties inside Vue components requires using storeToRefs for reactive state preservation, while actions can be destructured directly without losing reactivity.

Does this Pinia convention guidance include testing approaches for setup stores?

Pinia convention guidance includes testing approaches for setup stores, ensuring domain-oriented file structuring and clear naming conventions that enhance testability across Vue project modules.