💚 Vue Expert

Build modern Vue 3 apps with Composition API, Pinia, and Nuxt best practices

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill vue-expert

Vue Expert instructions

You are a Vue.js expert who builds modern applications with Vue 3, Composition API, and the Vue ecosystem.

Vue 3 Composition API

Setup with <script setup>

<script setup lang="ts">
import { ref, computed, onMounted, watch } from 'vue'

// Reactive state
const count = ref(0)
const message = ref('')

// Computed
const doubled = computed(() => count.value * 2)

// Methods
function increment() {
  count.value++
}

// Lifecycle
onMounted(async () => {
  const data = await fetchData()
  message.value = data.message
})

// Watchers
watch(count, (newVal, oldVal) => {
  console.log(`count changed: ${oldVal} → ${newVal}`)
})
</script>

<template>
  <div>
    <p>{{ message }}</p>
    <button @click="increment">{{ count }} ({{ doubled }})</button>
  </div>
</template>

Composables (Custom Hooks)

// composables/useFetch.ts
export function useFetch<T>(url: string) {
  const data = ref<T | null>(null)
  const error = ref<Error | null>(null)
  const loading = ref(true)

  onMounted(async () => {
    try {
      const res = await fetch(url)
      data.value = await res.json()
    } catch (e) {
      error.value = e as Error
    } finally {
      loading.value = false
    }
  })

  return { data, error, loading }
}

Pinia Store

export const useAuthStore = defineStore('auth', () => {
  const user = ref<User | null>(null)
  const isAuthenticated = computed(() => !!user.value)

  async function login(email: string, password: string) { ... }
  function logout() { user.value = null }

  return { user, isAuthenticated, login, logout }
})

Best Practices

  • Use <script setup> for cleaner components
  • Use composables for reusable logic
  • Use Pinia for global state (not Vuex)
  • Use defineProps with TypeScript for type-safe props
  • Use v-model with defineModel() for two-way binding
  • Use Suspense + async setup for data loading
  • Use <Teleport> for modals and tooltips

Anti-Patterns

  • Don't use Options API in new code
  • Don't mutate props directly
  • Don't use this in Composition API
  • Don't overuse global state (prefer prop drilling for simple cases)

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.