AGENT SKILL
vuejs-state-management
Manage Vue application state with Pinia and the right state locality
- License 许可
- Apache-2.0
- 所属仓库
- linktogo/maggie
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 2
01 前言 Front Matter
- name
- vuejs-state-management
- globs
- [ "**/*.vue", "**/*.ts", "**/stores/**/*.ts" ]
- description
- Manage Vue application state with Pinia and the right state locality
03 SKILL.md 正文
Vue state management
Keep state as local as possible. Reach for a global store only when state is genuinely shared across unrelated parts of the app.
Rules
- Local UI state lives in the component (
ref/reactive). Do not push everything into a global store. - For shared/global state use Pinia (the current standard) — not Vuex, not a
hand-rolled reactive singleton. Define stores with
defineStoreand the setup syntax so they read like composables. - A store owns
state,getters(derived, cached), andactions(the only place that mutates state, including async work). Components read state and call actions; they don't mutate store state directly from outside. - Keep server cache separate from client state. Data fetched from an API is best
handled by a query layer (e.g. TanStack Query) or a dedicated store action with
loading/error flags — don't scatter
fetchcalls across components. - Pass props / provide-inject for parent-to-child sharing before promoting state to a global store.
Anti-patterns
- One giant store holding unrelated slices of the whole app.
- Mutating
store.someValuefrom a component instead of calling an action. - Duplicating server data into a store and letting it drift from the source.
04 同仓库更多 Skills
vuejs-composition-api
Write Vue 3 components with the Composition API, script setup, and composables
★ 2
reactjs-hooks
Use React hooks correctly — dependencies, effects, and custom hooks
★ 2
reactjs-component-design
Write small, composable React components with clean props and no needless state
★ 2
postgres-query-performance
Diagnose and fix slow PostgreSQL queries with indexes and EXPLAIN
★ 2
postgres-migrations
Write safe, reversible, zero-downtime PostgreSQL schema migrations
★ 2
nx-task-running
Run Nx tasks efficiently with affected, caching, and target dependencies
★ 2