skills/pinia-options/SKILL.md
Pinia state management for Vue using Options API style — define stores with state, getters, actions, and use them in Options API components via mapState/mapWritableState/mapActions.
npx skillsauth add vuluu2k/skills pinia-optionsInstall 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.
This skill focuses on Option Stores and using them inside Options API components.
| Topic | Description | Reference | |-------|-------------|-----------| | Option Stores | Define stores with state, getters, actions | core-option-stores | | Using in Options API | mapState, mapWritableState, mapActions | using-in-options-api |
// stores/counter.ts
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', {
state: () => ({
count: 0,
name: 'My App'
}),
getters: {
doubled: (state) => state.count * 2,
},
actions: {
increment() {
this.count++
},
async fetchData() {
const data = await api.getData()
this.name = data.name
}
}
})
import { mapState, mapWritableState, mapActions } from 'pinia'
import { useCounterStore } from '@/stores/counter'
export default {
computed: {
...mapState(useCounterStore, ['doubled']), // readonly
...mapWritableState(useCounterStore, ['count']) // writable
},
methods: {
...mapActions(useCounterStore, ['increment'])
}
}
state must be a function returning an object — same as data() in Vue.getters are equivalent to computed — cached, receive state as parameter.actions are equivalent to methods — can be async, use this to access state.mapState / mapWritableState / mapActions to connect to stores.useStore() at module scope — only call it inside a function or method.development
Vue 3 Composition API — <script setup>, reactivity (shallowRef/ref), props without destructure, computed, watch, provide/inject, and composables. Use when the project uses modern Vue 3 Composition API style.
development
Vue 3 Options API — data, props, computed, methods, watch, emits, provide/inject, lifecycle hooks, and mixins. Use when the project uses Options API style (Vue 2 legacy or explicit Vue 3 Options API preference).
tools
Best practices for mixing Ant Design Vue components with Tailwind CSS utility classes. Use this skill to keep styling consistent without custom CSS files.
development
Pinia state management for Vue 3 using Composition API (Setup Stores) — TypeScript-first, storeToRefs for reactivity, focused stores, and API calls in composables. Use when the project uses Vue 3 Composition API / <script setup>.