skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
ejirocodes/agent-skills225 installs

vue-best-practices

Vue 3 and Vue.js best practices for TypeScript, vue-tsc, Volar, and component patterns. Use when writing, reviewing, or refactoring Vue 3 components with TypeScript, configuring Volar/vueCompilerOptions, extracting component types, working with defineModel/withDefaults, setting up Pinia store tests, or debugging Vue tooling issues. Triggers on Vue components, props extraction, wrapper components, template type checking, strictTemplates, vueCompilerOptions, Volar 3, CSS modules, fallthrough attributes, defineModel, withDefaults, deep watch, vue-router typed params, Pinia mocking, HMR SSR, moduleResolution bundler, useTemplateRef, onWatcherCleanup, useId, generic components, reactive props destructure.

How do I install this agent skill?

npx skills add https://github.com/ejirocodes/agent-skills --skill vue-best-practices
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    This skill provides comprehensive best practices for Vue 3 development, including TypeScript integration, component design patterns, testing strategies using Pinia and Vitest, and tooling configuration for Vite and Volar. All referenced resources and packages are standard ecosystem tools from reputable sources.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

  • Runlayerwarn

    6/6 files flagged

  • ZeroLeakspass

    Score: 93/100 · 2 sections analyzed

What does this agent skill do?

Vue 3 Best Practices

Quick Reference

TopicWhen to UseReference
TypeScriptProps extraction, generic components, useTemplateRef, JSDoc, reactive props destructuretypescript.md
VolarIDE config, strictTemplates, CSS modules, directive comments, Volar 3.0 migrationvolar.md
ComponentsdefineModel, deep watch, onWatcherCleanup, useId, deferred teleportcomponents.md
ToolingmoduleResolution, HMR SSR, duplicate plugin detectiontooling.md
TestingPinia store mocking, setup stores, Vue Router typed paramstesting.md

Essential Patterns

Extract Component Props

import type { ComponentProps } from 'vue-component-type-helpers'
import MyButton from './MyButton.vue'

type Props = ComponentProps<typeof MyButton>

Reactive Props Destructure (Vue 3.5+)

<script setup lang="ts">
// Destructured props are reactive - preferred in Vue 3.5+
const { name, count = 0 } = defineProps<{ name: string; count?: number }>()
</script>

useTemplateRef (Vue 3.5+)

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

const inputRef = useTemplateRef('input')  // Auto-typed
onMounted(() => inputRef.value?.focus())
</script>
<template><input ref="input" /></template>

onWatcherCleanup (Vue 3.5+)

import { watch, onWatcherCleanup } from 'vue'

watch(query, async (q) => {
  const controller = new AbortController()
  onWatcherCleanup(() => controller.abort())
  await fetch(`/api?q=${q}`, { signal: controller.signal })
})

defineModel with Required

// Returns Ref<Item> instead of Ref<Item | undefined>
const model = defineModel<Item>({ required: true })

Deep Watch with Numeric Depth

// Vue 3.5+ - watch array mutations without full traversal
watch(items, handler, { deep: 1 })

Pinia Store Test Setup

import { createTestingPinia } from '@pinia/testing'
import { vi } from 'vitest'

mount(Component, {
  global: {
    plugins: [createTestingPinia({ createSpy: vi.fn })]
  }
})

Common Mistakes

  1. Using InstanceType<typeof Component>['$props'] - Use ComponentProps instead
  2. Missing createSpy in createTestingPinia - Required in @pinia/testing 1.0+
  3. Using withDefaults with union types - Use Reactive Props Destructure
  4. strictTemplates in wrong tsconfig - Add to tsconfig.app.json, not root
  5. ts_ls with Volar 3.0 - Use vtsls instead (Neovim)
  6. deep: true on large structures - Use numeric depth for performance
  7. Watching destructured props directly - Wrap in getter: watch(() => count, ...)
  8. Random IDs in SSR - Use useId() for hydration-safe IDs

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/ejirocodes/agent-skills/vue-best-practices">View vue-best-practices on skillZs</a>