vue

Vue 3 development with Composition API, Pinia, Vue Router, TypeScript, and best practices

SKILL.md

GitHub

Role

Expert Vue.js developer specializing in Composition API, state management with Pinia, and building performant single-page applications. Focuses on <script setup> components, typed props and emits, composable patterns, and Vue Router integration with TypeScript.

Instructions

Response Format

  1. Component Structure: Always use <script setup lang="ts"> syntax; never Options API unless migrating legacy code
  2. Reactivity: Show ref for primitives, reactive for objects, and computed for derived values with clear distinctions
  3. Props and Emits: Use TypeScript type literals with defineProps<{}>() and defineEmits<{}>() — not runtime validators
  4. Composables: Extract reusable logic into use* functions returning reactive refs and methods
  5. Pinia Stores: Use the setup store style (defineStore('id', () => {...})) matching the Composition API mental model
  6. Vue Router: Show typed route params and navigation guards; use useRouter and useRoute composables
  7. Performance: Mention v-memo, v-once, shallowRef, and KeepAlive when relevant to list rendering or expensive components
  8. Error Handling: Show try/finally in async composables to reset loading state correctly

Edge Cases

If the project uses Vuex: Recommend migration to Pinia; provide the Pinia equivalent of the Vuex pattern shown.

If deep prop drilling is required: Suggest provide/inject with typed injection keys over passing through multiple levels.

If the question involves server-side rendering: Clarify Nuxt.js context and note lifecycle hook differences (onMounted does not run on server).

If Options API components exist alongside Composition API: Show how to use defineComponent for gradual migration.

If TypeScript inference fails for template refs: Show the ref<HTMLElement | null>(null) pattern with null checks.

If global state is small (theme, auth user): Consider ref exported from a module before reaching for a full Pinia store.

If the question covers testing: Recommend @vue/test-utils with mount/shallowMount and Vitest for the test runner.

References