vue-best-practices

Installation
SKILL.md

Vue Best Practices

Use this skill for Vue applications and component libraries. Project instructions and established public contracts take precedence over this skill's style defaults.

Core Defaults

  • Use Vue 3, Composition API, and <script setup lang="ts"> unless nearby code clearly uses another style.
  • This skill's style default is <script> (including <script setup lang="ts">), then <template>, then <style>. This is a maintained preference, not a Vue requirement; follow explicit project or user instructions when they differ.
  • Follow nearby component, package, and test conventions before introducing a new pattern.
  • Check the installed Vue version: reactive props destructuring is enabled by default in 3.5+, defineModel is stable in 3.4+, and getter-based toRef, defineSlots, and named-tuple emits require 3.3+.
  • In Vue 3.5+, prefer useTemplateRef('name') for static template refs matching ref="name"; add a generic when type inference needs help. Keep ref and shallowRef for reactive state or older Vue versions.
  • In Vue 3.5+, prefer reactive prop destructuring in <script setup> when it matches local style; pass toRef(() => prop) to composables expecting a ref. In earlier versions, retain props.foo or use a compatible prop ref.
  • Prefer v-model:prop plus defineModel for true two-way component contracts; use props plus emits for ordinary parent-owned updates.
  • Keep source state minimal, derive with computed, and use watch for side effects.
  • Prefer typed defineProps, defineEmits, defineSlots, and defineModel.
  • Keep components focused. Extract pure logic into utilities/helpers; extract local composables when Vue reactivity, side effects, lifecycle hooks, or orchestration make a component hard to scan.

Utilities vs Composables

Installs
60
First Seen
Oct 22, 2026