template/.claude/skills/pinia-store/SKILL.md
Pinia Store 架構規範。Use when creating app/stores/**/*.ts files, working with defineStore, managing global state, or building Pinia stores. Always use this skill for store design patterns, naming conventions, and state management architecture.
npx skillsauth add charles5277/nuxt-supabase-starter pinia-storeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
app/stores/
├── userPreferences.ts # 使用者偏好設定
├── auth.ts # 認證狀態
└── ui.ts # UI 全域狀態
使用 Composition API 語法:
import { defineStore } from 'pinia'
export const useMyStore = defineStore('my-store', () => {
const items = ref<Item[]>([])
const isLoading = ref(false)
const error = ref<Error | null>(null)
const itemCount = computed(() => items.value.length)
async function loadItems() {
isLoading.value = true
error.value = null
try {
const data = await $fetch('/api/v1/items')
items.value = data
} catch (e) {
error.value = e as Error
} finally {
isLoading.value = false
}
}
return {
items: readonly(items),
isLoading: readonly(isLoading),
error: readonly(error),
itemCount,
loadItems,
}
})
use<Name>Storekebab-case// ✅
export const useUserPreferencesStore = defineStore('user-preferences', ...)
// ❌
export const userPreferencesStore = defineStore('preferences', ...)
<script setup lang="ts">
const store = useMyStore()
// 解構保持響應性
const { items, isLoading } = storeToRefs(store)
const { loadItems } = store
</script>
readonly() 保護回傳的狀態,通過 action 修改useState,使用 ref 替代| 檔案 | 內容 | | ------------------------------------------------ | -------------------------------------- | | references/patterns.md | Plugin 自動初始化、Composable 包裝模式 |
defineStore('id', () => {...}))use<Name>Storereadonly() 保護狀態useStatedevelopment
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.
tools
Push interfaces past conventional limits with technically ambitious implementations. Whether that's a shader, a 60fps virtual table, spring physics on a dialog, or scroll-driven reveals — make users ask "how did they do that?"
content-media
Improve interface performance across loading speed, rendering, animations, images, and bundle size. Makes experiences faster and smoother.
content-media
Design or improve onboarding flows, empty states, and first-time user experiences. Helps users get started successfully and understand value quickly.