This skill helps you develop Vue 3 applications using the Composition API, reactivity, and best practices from official Vue documentation.
npx playbooks add skill yuann3/skills --skill vue
Vue.js 3 is a progressive JavaScript framework for building user interfaces. Core principle: Use Composition API with <script setup>, leverage composables for reusable logic, and follow one-way data flow.
Official Documentation: https://vuejs.org
When NOT to use:
| Pattern | Use Case | Syntax |
|---------|----------|--------|
| ref() | Primitives, reassignment | const count = ref(0) |
| reactive() | Objects only | const state = reactive({ count: 0 }) |
| computed() | Derived state | const double = computed(() => count.value * 2) |
| watch() | Specific sources | watch(source, callback) |
| watchEffect() | Auto-track deps | watchEffect(() => {...}) |
| Composables | Reusable logic | const { x, y } = useMouse() |
For complete API reference: See @reference.md
Use <script setup> for modern Vue components:
<script setup>
import { ref, computed } from 'vue'
const count = ref(0)
const doubled = computed(() => count.value * 2)
function increment() {
count.value++
}
</script>
<template>
<button @click="increment">Count: {{ count }}</button>
<p>Doubled: {{ doubled }}</p>
</template>
<style scoped>
button { font-weight: bold; }
</style>
More examples: See @examples.md for 20+ official examples
Use ref() for:
Use reactive() for:
// ✅ ref() for primitives
const count = ref(0)
count.value++ // Need .value in script
// ✅ reactive() for objects
const state = reactive({ count: 0 })
state.count++ // Direct access
// ⚠️ Don't destructure reactive()
const { count } = state // Loses reactivity!
<script setup>
// Props with validation
defineProps({
title: {
type: String,
required: true
},
count: {
type: Number,
default: 0
}
})
// Emits
const emit = defineEmits(['update', 'delete'])
function handleUpdate(value) {
emit('update', value)
}
</script>
Never mutate props - always emit events instead.
Reusable stateful logic following conventions:
// composables/useMouse.js
import { ref, onMounted, onUnmounted } from 'vue'
export function useMouse() {
const x = ref(0)
const y = ref(0)
function update(event) {
x.value = event.pageX
y.value = event.pageY
}
onMounted(() => window.addEventListener('mousemove', update))
onUnmounted(() => window.removeEventListener('mousemove', update))
return { x, y }
}
Composable conventions:
onUnmounted()Official guide: https://vuejs.org/guide/reusability/composables.html
// watch() - explicit sources
watch(count, (newVal, oldVal) => {
console.log(`${oldVal} → ${newVal}`)
})
// watchEffect() - auto-track dependencies
watchEffect(() => {
console.log('Count:', count.value)
})
ref() for primitives const count = ref(0) // ✅
let count = 0 // ❌ Not reactive
computed() for derived state const doubled = computed(() => count.value * 2) // ✅ Cached
const doubled = count.value * 2 // ❌ Recalculates every render
emit('update:count', props.count + 1) // ✅
props.count++ // ❌
<script setup> for cleaner code| Mistake | Fix |
|---------|-----|
| Destructuring reactive() | Use toRefs() or ref() |
| Forgetting .value in script | Refs need .value outside templates |
| Mutating props | Emit events instead |
| reactive() for primitives | Use ref() |
| Not cleaning up | Use onUnmounted() |
| Conditional composable calls | Always call at top level |
See @examples.md for 20+ official Vue.js examples:
Live examples: https://vuejs.org/examples/
See @reference.md for complete API documentation with links to:
Full API: https://vuejs.org/api/
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.