[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CV4XFE9HNKEB5MSR8X1SGG":3,"skill-same:01M7CV4XFE9HNKEB5MSR8X1SGG":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7CV4XFE9HNKEB5MSR8X1SGG","vue-patterns",null,"Vue.js 3 Composition API patterns, component architecture, reactivity best practices, Pinia state management, Vue Router navigation, and Nuxt SSR patterns. Activates for Vue, Nuxt, Vite, or Pinia projects.","Henrique1601\u002FSkiilsToIAs","Henrique1601","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F92006691?v=4","01M7CRXVT0GVXVK80JT1GR687S","Henrique Bezerra Dos Santos","01M7CRXVTN5Y8TMWJ1MDSKCQ1T",0,"MIT","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fdevelopment\u002Fvue-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: vue-patterns\ndescription: Vue.js 3 Composition API patterns, component architecture, reactivity best practices, Pinia state management, Vue Router navigation, and Nuxt SSR patterns. Activates for Vue, Nuxt, Vite, or Pinia projects.\norigin: ECC\n---\n\n# Vue.js Patterns and Best Practices\n\nComprehensive guide for Vue.js 3 development using Composition API (`\u003Cscript setup>`), covering component design, reactivity, state management, routing, testing, and SSR patterns. Nuxt-specific guidance is included where it differs from vanilla Vue.\n\n## When to Activate\n\nActivate this skill when:\n- The project uses Vue.js (any version), Nuxt, Vite + Vue, or Pinia.\n- The user asks about Vue component architecture, composables, reactivity, or state management.\n- Reviewing Vue Single-File Components (`.vue` files).\n- Setting up Vue Router, Pinia stores, or Vite\u002FVitest configuration.\n- Discussing Vue-specific performance, security, or SSR patterns.\n\n---\n\n## 1. Project Structure\n\n### Recommended Layout (Feature-First)\n\n```\nsrc\u002F\n├── api\u002F              # API client and endpoint definitions\n├── assets\u002F           # Static assets (images, fonts, icons)\n├── components\u002F       # Shared\u002Freusable components\n│   ├── base\u002F         # Base UI primitives (Button, Input, Modal)\n│   └── features\u002F     # Feature-specific shared components\n├── composables\u002F      # Reusable Composition API logic\n├── layouts\u002F          # Page layouts (optional)\n├── pages\u002F            # Route-level page components\n├── router\u002F           # Vue Router configuration\n├── stores\u002F           # Pinia stores\n├── types\u002F            # TypeScript type definitions\n├── utils\u002F            # Pure utility functions\n└── App.vue           # Root component\n```\n\n### File Naming\n\n| Convention | When to Use |\n|-----------|-------------|\n| `PascalCase.vue` | All components (enforced by `vue\u002Fmulti-word-component-names`) |\n| `useCamelCase.ts` | Composables |\n| `camelCase.ts` | Utilities, API clients, types |\n| `kebab-case` directories | Route segments, feature folders |\n\n---\n\n## 2. Component Architecture\n\n### Single-File Component Order\n\n```vue\n\u003Cscript setup lang=\"ts\">\n\u002F\u002F 1. Imports (vue → ecosystem → absolute → relative)\n\u002F\u002F 2. Props & Emits & Slots\n\u002F\u002F 3. Composables\n\u002F\u002F 4. Local state (ref\u002Freactive)\n\u002F\u002F 5. Computed properties\n\u002F\u002F 6. Methods\n\u002F\u002F 7. Watchers\n\u002F\u002F 8. Lifecycle hooks\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003C!-- Template content -->\n\u003C\u002Ftemplate>\n\n\u003Cstyle scoped>\n  \u002F* Scoped styles *\u002F\n\u003C\u002Fstyle>\n```\n\n### Presentational vs Container\n\n- **Container components**: Own data fetching, state, and side effects. Render presentational components.\n- **Presentational components**: Receive props, emit events. No API calls, no store access. Pure rendering.\n\n### Props Best Practices\n\n```ts\n\u002F\u002F Type-based props with defaults\ninterface Props {\n  label: string;\n  variant?: \"primary\" | \"secondary\";\n  disabled?: boolean;\n  items: Item[];\n}\n\nconst props = withDefaults(defineProps\u003CProps>(), {\n  variant: \"primary\",\n  disabled: false,\n});\n```\n\n- Always provide `type`, and `required`\u002F`default` where appropriate.\n- Boolean props: `isXxx`, `hasXxx`, `canXxx`.\n- Never mutate props — emit events instead.\n- For v-model binding, use `defineModel()` (Vue 3.4+) or `modelValue` + `update:modelValue`.\n\n### Events\n\n```ts\nconst emit = defineEmits\u003C{\n  submit: [];\n  \"update:modelValue\": [value: string];\n  select: [id: string, index: number];\n}>();\n```\n\n- Use kebab-case in templates (`@update:model-value`).\n- Use camelCase in script (`emit(\"update:modelValue\", val)`).\n\n---\n\n## 3. Composables (Reusable Logic)\n\n### Structure\n\n```ts\n\u002F\u002F composables\u002FuseDebounce.ts\nexport function useDebounce\u003CT>(value: MaybeRef\u003CT>, delay: number): Ref\u003CT> {\n  const debounced = ref(toValue(value)) as Ref\u003CT>;\n\n  let timer: ReturnType\u003Ctypeof setTimeout>;\n  watch(\n    () => toValue(value),\n    (newVal) => {\n      clearTimeout(timer);\n      timer = setTimeout(() => { debounced.value = newVal; }, delay);\n    }\n  );\n\n  onUnmounted(() => clearTimeout(timer));\n  return readonly(debounced);\n}\n```\n\n### Rules\n\n- Must start with `use` prefix.\n- Return reactive values (`ref`, `computed`, `reactive`), never plain primitives.\n- Accept reactive inputs via `MaybeRef` \u002F `toRef()` \u002F `toValue()`.\n- Clean up side effects in `onUnmounted` or watcher `onCleanup`.\n- No module-scope side effects.\n\n### vs Mixins\n\nComposables replace Vue 2 mixins entirely:\n- **Mixins**: Opaque data flow, source-of-truth collisions, name conflicts.\n- **Composables**: Explicit imports, clear return values, composable and tree-shakable.\n\n---\n\n## 4. State Management\n\n### When to Use What\n\n| Pattern | Use Case |\n|---------|----------|\n| `ref()` \u002F `reactive()` | Local component state |\n| Props + Emits | Parent-child communication |\n| Provide \u002F Inject | Theme, config, plugin API |\n| Pinia store | Global, shared, complex state |\n| Server state composable | API data with caching (wrap `fetch`\u002FTanStack Query) |\n\n### Pinia Setup Store (Preferred)\n\n```ts\n\u002F\u002F stores\u002FuseCartStore.ts\nexport const useCartStore = defineStore(\"cart\", () => {\n  const items = ref\u003CCartItem[]>([]);\n  const isLoading = ref(false);\n\n  const totalPrice = computed(() =>\n    items.value.reduce((sum, i) => sum + i.price * i.quantity, 0)\n  );\n  const itemCount = computed(() =>\n    items.value.reduce((sum, i) => sum + i.quantity, 0)\n  );\n\n  async function addItem(productId: string) {\n    isLoading.value = true;\n    try {\n      const item = await fetchProduct(productId);\n      const existing = items.value.find(i => i.id === item.id);\n      if (existing) existing.quantity++;\n      else items.value.push({ ...item, quantity: 1 });\n    } finally {\n      isLoading.value = false;\n    }\n  }\n\n  return { items, isLoading, totalPrice, itemCount, addItem };\n});\n```\n\n- Use Setup Store syntax (not Options Store).\n- Prefer actions for business-level mutations and `$patch()` for grouped updates.\n- Every async action: handle loading + success + error.\n\n---\n\n## 5. Vue Router\n\n### Route Definitions\n\n```ts\nconst routes = [\n  {\n    path: \"\u002Fusers\u002F:id\",\n    name: \"user-detail\",\n    component: () => import(\"@\u002Fpages\u002FUserDetail.vue\"), \u002F\u002F lazy\n    props: true, \u002F\u002F pass params as props\n    meta: { requiresAuth: true },\n  },\n];\n```\n\n### Navigation Guards\n\n```ts\nrouter.beforeEach((to, from) => {\n  const { isLoggedIn } = useAuthStore();\n  if (to.meta.requiresAuth && !isLoggedIn) {\n    return { name: \"login\", query: { redirect: to.fullPath } };\n  }\n});\n```\n\n### Reactive Route Params\n\nWhen a component stays mounted but route params change:\n\n```ts\nconst route = useRoute();\nconst id = computed(() => route.params.id as string);\nwatch(id, (newId) => fetchItem(newId));\n```\n\n---\n\n## 6. Template Patterns\n\n### Template Syntax\n\n```vue\n\u003C!-- v-if\u002Fv-else-if\u002Fv-else -->\n\u003Cdiv v-if=\"isLoading\">Loading...\u003C\u002Fdiv>\n\u003Cdiv v-else-if=\"error\">Error: {{ error }}\u003C\u002Fdiv>\n\u003Cdiv v-else>{{ content }}\u003C\u002Fdiv>\n\n\u003C!-- v-show for frequent toggles -->\n\u003Cdiv v-show=\"isOpen\">Toggled content\u003C\u002Fdiv>\n\n\u003C!-- v-for with stable keys -->\n\u003Cdiv v-for=\"item in items\" :key=\"item.id\">{{ item.name }}\u003C\u002Fdiv>\n\n\u003C!-- Computed filtered list (not v-if + v-for on same element) -->\n\u003Cdiv v-for=\"item in activeItems\" :key=\"item.id\">{{ item.name }}\u003C\u002Fdiv>\n\n\u003C!-- Event handling -->\n\u003Cform @submit.prevent=\"handleSubmit\">\n  \u003Cbutton type=\"submit\">Save\u003C\u002Fbutton>\n\u003C\u002Fform>\n\n\u003C!-- v-model -->\n\u003Cinput v-model=\"name\" \u002F>\n\u003CCustomInput v-model=\"value\" v-model:title=\"title\" \u002F>\n```\n\n---\n\n## 7. Performance\n\n| Technique | When to Use |\n|-----------|-------------|\n| `v-memo` | List items that rarely change |\n| `v-once` | Content rendered once and static forever |\n| `shallowRef()` | Large data structures replaced wholesale |\n| `shallowReactive()` | Only top-level properties are reactive |\n| `v-show` over `v-if` | Frequent visibility toggles |\n| `\u003CKeepAlive :max=\"10\">` | Cache toggled views |\n| Lazy routes | `() => import(...)` for non-critical routes |\n| `Suspense` | Async component loading with fallback |\n\n---\n\n## 8. Testing\n\n### Stack\n\n- **Vitest** for unit and component tests\n- **Vue Test Utils** for mounting and interaction\n- **@pinia\u002Ftesting** for store mocking\n- **Playwright** for E2E\n\n### Component Test Pattern\n\n```ts\nimport { mount } from \"@vue\u002Ftest-utils\";\nimport { createPinia, setActivePinia } from \"pinia\";\nimport UserCard from \".\u002FUserCard.vue\";\n\nbeforeEach(() => { setActivePinia(createPinia()); });\n\nit(\"renders and emits\", async () => {\n  const wrapper = mount(UserCard, {\n    props: { user: { id: \"1\", name: \"Alice\" } },\n  });\n  expect(wrapper.text()).toContain(\"Alice\");\n  await wrapper.find(\"button\").trigger(\"click\");\n  expect(wrapper.emitted(\"select\")![0]).toEqual([\"1\"]);\n});\n```\n\n---\n\n## 9. Nuxt-Specific Patterns\n\n### Auto-Imports\n\nNuxt auto-imports `ref`, `computed`, `watch`, `useFetch`, `useAsyncData`, etc. Use them directly without importing. For non-Nuxt projects, always import explicitly.\n\n### useAsyncData \u002F useFetch\n\n```ts\nconst { data: user, pending, error, refresh } = await useAsyncData(\n  \"user\", \u002F\u002F unique key for caching\n  () => $fetch(`\u002Fapi\u002Fusers\u002F${id}`),\n);\n\nconst { data: posts } = await useFetch(\"\u002Fapi\u002Fposts\", {\n  query: { page: 1 },\n  key: \"posts-page-1\", \u002F\u002F dedupes requests\n});\n```\n\n### Server Routes\n\n```ts\n\u002F\u002F server\u002Fapi\u002Fusers\u002F[id].ts\nexport default defineEventHandler(async (event) => {\n  const { id } = await getValidatedRouterParams(event, z.object({\n    id: z.string().uuid(),\n  }).parse);\n  \u002F\u002F ... fetch and return\n});\n```\n\n### Runtime Config\n\n```ts\n\u002F\u002F nuxt.config.ts\nexport default defineNuxtConfig({\n  runtimeConfig: {\n    \u002F\u002F server-only\n    apiSecret: \"\",\n    \u002F\u002F public (exposed to client)\n    public: {\n      apiBase: \"https:\u002F\u002Fapi.example.com\",\n    },\n  },\n});\n```\n\n---\n\n## 10. Vue 3.5+ New APIs\n\n### Reactive Props Destructure\n\nVue 3.5 stabilized reactive props destructure — destructured variables from `defineProps()` are automatically reactive:\n\n```ts\n\u002F\u002F Vue 3.5+: destructured props are reactive (no need for toRefs)\nconst { count = 0, msg = \"hello\" } = defineProps\u003C{\n  count?: number;\n  msg?: string;\n}>();\n\n\u002F\u002F Limitation: cannot watch destructured prop directly\nwatch(() => count, (newVal) => { ... }); \u002F\u002F PASS getter required\n```\n\n### `useTemplateRef()`\n\nReplace name-matched plain refs with `useTemplateRef()` for template references:\n\n```ts\nimport { useTemplateRef } from \"vue\";\nconst inputEl = useTemplateRef\u003CHTMLInputElement>(\"input\");\n\u002F\u002F \"input\" matches the ref=\"input\" attribute in template, not the variable name\n```\n\nSupports dynamic ref IDs: `useTemplateRef(dynamicRefId)`.\n\n### `onWatcherCleanup()`\n\nGlobally importable watcher cleanup API (Vue 3.5+). It must be called synchronously inside the watcher callback:\n\n```ts\nimport { watch, onWatcherCleanup } from \"vue\";\n\nwatch(userId, async (newId) => {\n  const controller = new AbortController();\n  onWatcherCleanup(() => controller.abort());\n  \u002F\u002F ... fetch with signal\n});\n```\n\n### `useId()`\n\nSSR-stable unique ID generation for form elements and accessibility:\n\n```ts\nimport { useId } from \"vue\";\nconst id = useId();\n```\n\n### `defer` Teleport\n\n`\u003CTeleport defer>` allows teleporting to targets rendered in the same cycle:\n\n```vue\n\u003CTeleport defer to=\"#container\">Content\u003C\u002FTeleport>\n\u003Cdiv id=\"container\">\u003C\u002Fdiv>\n```\n\n### Lazy Hydration (SSR)\n\n`defineAsyncComponent()` now supports `hydrate` strategy:\n\n```ts\nimport { defineAsyncComponent, hydrateOnVisible } from \"vue\";\nconst AsyncComp = defineAsyncComponent({\n  loader: () => import(\".\u002FComp.vue\"),\n  hydrate: hydrateOnVisible(),\n});\n```\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why It's Wrong | The Fix |\n|-------------|---------------|---------|\n| Destructuring `defineProps()` (Vue \u003C 3.5) | Captures snapshot, loses reactivity | Access via `props.xxx` or use `toRefs()` |\n| `watch()` on destructured prop (Vue 3.5+) | Compile-time error — destructured props can't be watched directly | Use getter wrapper: `watch(() => count, ...)` |\n| `v-if` + `v-for` on same element | Ambiguous execution order | Use computed filtered array |\n| `v-for` key = index | Broken state on reorder | Use stable database IDs |\n| Mutating props | Violates one-way data flow | Emit events or use `v-model` |\n| `v-html` with user content | XSS vulnerability | Sanitize with DOMPurify |\n| Mixins in Vue 3 | Opaque, collision-prone | Replace with composables |\n| Module-scope side effects in composable | Shared across instances | Scope in `onMounted` + `onUnmounted` |\n| `reactive()` for replaceable state | Replacement breaks reactivity | Use `ref()` instead |\n| Watcher without cleanup | Memory leaks, race conditions | Use `onCleanup` or `onWatcherCleanup()` (Vue 3.5+) |\n| Options API in new Vue 3 code | Ecosystem move to Composition API | Use `\u003Cscript setup>` |\n| Plain ref for template references | No dynamic ref support, name-matching fragile | Use `useTemplateRef()` (Vue 3.5+) |\n\n## Related Skills\n\n- `accessibility` — ARIA, semantic HTML, focus management\n- `frontend-patterns` — Cross-framework frontend architecture\n- `typescript` — TypeScript best practices applied to Vue projects\n- `coding-standards` — General code quality standards\n","# Vue.js Patterns and Best Practices\n\nComprehensive guide for Vue.js 3 development using Composition API (`\u003Cscript setup>`), covering component design, reactivity, state management, routing, testing, and SSR patterns. Nuxt-specific guidance is included where it differs from vanilla Vue.\n\n## When to Activate\n\nActivate this skill when:\n- The project uses Vue.js (any version), Nuxt, Vite + Vue, or Pinia.\n- The user asks about Vue component architecture, composables, reactivity, or state management.\n- Reviewing Vue Single-File Components (`.vue` files).\n- Setting up Vue Router, Pinia stores, or Vite\u002FVitest configuration.\n- Discussing Vue-specific performance, security, or SSR patterns.\n\n---\n\n## 1. Project Structure\n\n### Recommended Layout (Feature-First)\n\n```\nsrc\u002F\n├── api\u002F              # API client and endpoint definitions\n├── assets\u002F           # Static assets (images, fonts, icons)\n├── components\u002F       # Shared\u002Freusable components\n│   ├── base\u002F         # Base UI primitives (Button, Input, Modal)\n│   └── features\u002F     # Feature-specific shared components\n├── composables\u002F      # Reusable Composition API logic\n├── layouts\u002F          # Page layouts (optional)\n├── pages\u002F            # Route-level page components\n├── router\u002F           # Vue Router configuration\n├── stores\u002F           # Pinia stores\n├── types\u002F            # TypeScript type definitions\n├── utils\u002F            # Pure utility functions\n└── App.vue           # Root component\n```\n\n### File Naming\n\n| Convention | When to Use |\n|-----------|-------------|\n| `PascalCase.vue` | All components (enforced by `vue\u002Fmulti-word-component-names`) |\n| `useCamelCase.ts` | Composables |\n| `camelCase.ts` | Utilities, API clients, types |\n| `kebab-case` directories | Route segments, feature folders |\n\n---\n\n## 2. Component Architecture\n\n### Single-File Component Order\n\n```vue\n\u003Cscript setup lang=\"ts\">\n\u002F\u002F 1. Imports (vue → ecosystem → absolute → relative)\n\u002F\u002F 2. Props & Emits & Slots\n\u002F\u002F 3. Composables\n\u002F\u002F 4. Local state (ref\u002Freactive)\n\u002F\u002F 5. Computed properties\n\u002F\u002F 6. Methods\n\u002F\u002F 7. Watchers\n\u002F\u002F 8. Lifecycle hooks\n\u003C\u002Fscript>\n\n\u003Ctemplate>\n  \u003C!-- Template content -->\n\u003C\u002Ftemplate>\n\n\u003Cstyle scoped>\n  \u002F* Scoped styles *\u002F\n\u003C\u002Fstyle>\n```\n\n### Presentational vs Container\n\n- **Container components**: Own data fetching, state, and side effects. Render presentational components.\n- **Presentational components**: Receive props, emit events. No API calls, no store access. Pure rendering.\n\n### Props Best Practices\n\n```ts\n\u002F\u002F Type-based props with defaults\ninterface Props {\n  label: string;\n  variant?: \"primary\" | \"secondary\";\n  disabled?: boolean;\n  items: Item[];\n}\n\nconst props = withDefaults(defineProps\u003CProps>(), {\n  variant: \"primary\",\n  disabled: false,\n});\n```\n\n- Always provide `type`, and `required`\u002F`default` where appropriate.\n- Boolean props: `isXxx`, `hasXxx`, `canXxx`.\n- Never mutate props — emit events instead.\n- For v-model binding, use `defineModel()` (Vue 3.4+) or `modelValue` + `update:modelValue`.\n\n### Events\n\n```ts\nconst emit = defineEmits\u003C{\n  submit: [];\n  \"update:modelValue\": [value: string];\n  select: [id: string, index: number];\n}>();\n```\n\n- Use kebab-case in templates (`@update:model-value`).\n- Use camelCase in script (`emit(\"update:modelValue\", val)`).\n\n---\n\n## 3. Composables (Reusable Logic)\n\n### Structure\n\n```ts\n\u002F\u002F composables\u002FuseDebounce.ts\nexport function useDebounce\u003CT>(value: MaybeRef\u003CT>, delay: number): Ref\u003CT> {\n  const debounced = ref(toValue(value)) as Ref\u003CT>;\n\n  let timer: ReturnType\u003Ctypeof setTimeout>;\n  watch(\n    () => toValue(value),\n    (newVal) => {\n      clearTimeout(timer);\n      timer = setTimeout(() => { debounced.value = newVal; }, delay);\n    }\n  );\n\n  onUnmounted(() => clearTimeout(timer));\n  return readonly(debounced);\n}\n```\n\n### Rules\n\n- Must start with `use` prefix.\n- Return reactive values (`ref`, `computed`, `reactive`), never plain primitives.\n- Accept reactive inputs via `MaybeRef` \u002F `toRef()` \u002F `toValue()`.\n- Clean up side effects in `onUnmounted` or watcher `onCleanup`.\n- No module-scope side effects.\n\n### vs Mixins\n\nComposables replace Vue 2 mixins entirely:\n- **Mixins**: Opaque data flow, source-of-truth collisions, name conflicts.\n- **Composables**: Explicit imports, clear return values, composable and tree-shakable.\n\n---\n\n## 4. State Management\n\n### When to Use What\n\n| Pattern | Use Case |\n|---------|----------|\n| `ref()` \u002F `reactive()` | Local component state |\n| Props + Emits | Parent-child communication |\n| Provide \u002F Inject | Theme, config, plugin API |\n| Pinia store | Global, shared, complex state |\n| Server state composable | API data with caching (wrap `fetch`\u002FTanStack Query) |\n\n### Pinia Setup Store (Preferred)\n\n```ts\n\u002F\u002F stores\u002FuseCartStore.ts\nexport const useCartStore = defineStore(\"cart\", () => {\n  const items = ref\u003CCartItem[]>([]);\n  const isLoading = ref(false);\n\n  const totalPrice = computed(() =>\n    items.value.reduce((sum, i) => sum + i.price * i.quantity, 0)\n  );\n  const itemCount = computed(() =>\n    items.value.reduce((sum, i) => sum + i.quantity, 0)\n  );\n\n  async function addItem(productId: string) {\n    isLoading.value = true;\n    try {\n      const item = await fetchProduct(productId);\n      const existing = items.value.find(i => i.id === item.id);\n      if (existing) existing.quantity++;\n      else items.value.push({ ...item, quantity: 1 });\n    } finally {\n      isLoading.value = false;\n    }\n  }\n\n  return { items, isLoading, totalPrice, itemCount, addItem };\n});\n```\n\n- Use Setup Store syntax (not Options Store).\n- Prefer actions for business-level mutations and `$patch()` for grouped updates.\n- Every async action: handle loading + success + error.\n\n---\n\n## 5. Vue Router\n\n### Route Definitions\n\n```ts\nconst routes = [\n  {\n    path: \"\u002Fusers\u002F:id\",\n    name: \"user-detail\",\n    component: () => import(\"@\u002Fpages\u002FUserDetail.vue\"), \u002F\u002F lazy\n    props: true, \u002F\u002F pass params as props\n    meta: { requiresAuth: true },\n  },\n];\n```\n\n### Navigation Guards\n\n```ts\nrouter.beforeEach((to, from) => {\n  const { isLoggedIn } = useAuthStore();\n  if (to.meta.requiresAuth && !isLoggedIn) {\n    return { name: \"login\", query: { redirect: to.fullPath } };\n  }\n});\n```\n\n### Reactive Route Params\n\nWhen a component stays mounted but route params change:\n\n```ts\nconst route = useRoute();\nconst id = computed(() => route.params.id as string);\nwatch(id, (newId) => fetchItem(newId));\n```\n\n---\n\n## 6. Template Patterns\n\n### Template Syntax\n\n```vue\n\u003C!-- v-if\u002Fv-else-if\u002Fv-else -->\n\u003Cdiv v-if=\"isLoading\">Loading...\u003C\u002Fdiv>\n\u003Cdiv v-else-if=\"error\">Error: {{ error }}\u003C\u002Fdiv>\n\u003Cdiv v-else>{{ content }}\u003C\u002Fdiv>\n\n\u003C!-- v-show for frequent toggles -->\n\u003Cdiv v-show=\"isOpen\">Toggled content\u003C\u002Fdiv>\n\n\u003C!-- v-for with stable keys -->\n\u003Cdiv v-for=\"item in items\" :key=\"item.id\">{{ item.name }}\u003C\u002Fdiv>\n\n\u003C!-- Computed filtered list (not v-if + v-for on same element) -->\n\u003Cdiv v-for=\"item in activeItems\" :key=\"item.id\">{{ item.name }}\u003C\u002Fdiv>\n\n\u003C!-- Event handling -->\n\u003Cform @submit.prevent=\"handleSubmit\">\n  \u003Cbutton type=\"submit\">Save\u003C\u002Fbutton>\n\u003C\u002Fform>\n\n\u003C!-- v-model -->\n\u003Cinput v-model=\"name\" \u002F>\n\u003CCustomInput v-model=\"value\" v-model:title=\"title\" \u002F>\n```\n\n---\n\n## 7. Performance\n\n| Technique | When to Use |\n|-----------|-------------|\n| `v-memo` | List items that rarely change |\n| `v-once` | Content rendered once and static forever |\n| `shallowRef()` | Large data structures replaced wholesale |\n| `shallowReactive()` | Only top-level properties are reactive |\n| `v-show` over `v-if` | Frequent visibility toggles |\n| `\u003CKeepAlive :max=\"10\">` | Cache toggled views |\n| Lazy routes | `() => import(...)` for non-critical routes |\n| `Suspense` | Async component loading with fallback |\n\n---\n\n## 8. Testing\n\n### Stack\n\n- **Vitest** for unit and component tests\n- **Vue Test Utils** for mounting and interaction\n- **@pinia\u002Ftesting** for store mocking\n- **Playwright** for E2E\n\n### Component Test Pattern\n\n```ts\nimport { mount } from \"@vue\u002Ftest-utils\";\nimport { createPinia, setActivePinia } from \"pinia\";\nimport UserCard from \".\u002FUserCard.vue\";\n\nbeforeEach(() => { setActivePinia(createPinia()); });\n\nit(\"renders and emits\", async () => {\n  const wrapper = mount(UserCard, {\n    props: { user: { id: \"1\", name: \"Alice\" } },\n  });\n  expect(wrapper.text()).toContain(\"Alice\");\n  await wrapper.find(\"button\").trigger(\"click\");\n  expect(wrapper.emitted(\"select\")![0]).toEqual([\"1\"]);\n});\n```\n\n---\n\n## 9. Nuxt-Specific Patterns\n\n### Auto-Imports\n\nNuxt auto-imports `ref`, `computed`, `watch`, `useFetch`, `useAsyncData`, etc. Use them directly without importing. For non-Nuxt projects, always import explicitly.\n\n### useAsyncData \u002F useFetch\n\n```ts\nconst { data: user, pending, error, refresh } = await useAsyncData(\n  \"user\", \u002F\u002F unique key for caching\n  () => $fetch(`\u002Fapi\u002Fusers\u002F${id}`),\n);\n\nconst { data: posts } = await useFetch(\"\u002Fapi\u002Fposts\", {\n  query: { page: 1 },\n  key: \"posts-page-1\", \u002F\u002F dedupes requests\n});\n```\n\n### Server Routes\n\n```ts\n\u002F\u002F server\u002Fapi\u002Fusers\u002F[id].ts\nexport default defineEventHandler(async (event) => {\n  const { id } = await getValidatedRouterParams(event, z.object({\n    id: z.string().uuid(),\n  }).parse);\n  \u002F\u002F ... fetch and return\n});\n```\n\n### Runtime Config\n\n```ts\n\u002F\u002F nuxt.config.ts\nexport default defineNuxtConfig({\n  runtimeConfig: {\n    \u002F\u002F server-only\n    apiSecret: \"\",\n    \u002F\u002F public (exposed to client)\n    public: {\n      apiBase: \"https:\u002F\u002Fapi.example.com\",\n    },\n  },\n});\n```\n\n---\n\n## 10. Vue 3.5+ New APIs\n\n### Reactive Props Destructure\n\nVue 3.5 stabilized reactive props destructure — destructured variables from `defineProps()` are automatically reactive:\n\n```ts\n\u002F\u002F Vue 3.5+: destructured props are reactive (no need for toRefs)\nconst { count = 0, msg = \"hello\" } = defineProps\u003C{\n  count?: number;\n  msg?: string;\n}>();\n\n\u002F\u002F Limitation: cannot watch destructured prop directly\nwatch(() => count, (newVal) => { ... }); \u002F\u002F PASS getter required\n```\n\n### `useTemplateRef()`\n\nReplace name-matched plain refs with `useTemplateRef()` for template references:\n\n```ts\nimport { useTemplateRef } from \"vue\";\nconst inputEl = useTemplateRef\u003CHTMLInputElement>(\"input\");\n\u002F\u002F \"input\" matches the ref=\"input\" attribute in template, not the variable name\n```\n\nSupports dynamic ref IDs: `useTemplateRef(dynamicRefId)`.\n\n### `onWatcherCleanup()`\n\nGlobally importable watcher cleanup API (Vue 3.5+). It must be called synchronously inside the watcher callback:\n\n```ts\nimport { watch, onWatcherCleanup } from \"vue\";\n\nwatch(userId, async (newId) => {\n  const controller = new AbortController();\n  onWatcherCleanup(() => controller.abort());\n  \u002F\u002F ... fetch with signal\n});\n```\n\n### `useId()`\n\nSSR-stable unique ID generation for form elements and accessibility:\n\n```ts\nimport { useId } from \"vue\";\nconst id = useId();\n```\n\n### `defer` Teleport\n\n`\u003CTeleport defer>` allows teleporting to targets rendered in the same cycle:\n\n```vue\n\u003CTeleport defer to=\"#container\">Content\u003C\u002FTeleport>\n\u003Cdiv id=\"container\">\u003C\u002Fdiv>\n```\n\n### Lazy Hydration (SSR)\n\n`defineAsyncComponent()` now supports `hydrate` strategy:\n\n```ts\nimport { defineAsyncComponent, hydrateOnVisible } from \"vue\";\nconst AsyncComp = defineAsyncComponent({\n  loader: () => import(\".\u002FComp.vue\"),\n  hydrate: hydrateOnVisible(),\n});\n```\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why It's Wrong | The Fix |\n|-------------|---------------|---------|\n| Destructuring `defineProps()` (Vue \u003C 3.5) | Captures snapshot, loses reactivity | Access via `props.xxx` or use `toRefs()` |\n| `watch()` on destructured prop (Vue 3.5+) | Compile-time error — destructured props can't be watched directly | Use getter wrapper: `watch(() => count, ...)` |\n| `v-if` + `v-for` on same element | Ambiguous execution order | Use computed filtered array |\n| `v-for` key = index | Broken state on reorder | Use stable database IDs |\n| Mutating props | Violates one-way data flow | Emit events or use `v-model` |\n| `v-html` with user content | XSS vulnerability | Sanitize with DOMPurify |\n| Mixins in Vue 3 | Opaque, collision-prone | Replace with composables |\n| Module-scope side effects in composable | Shared across instances | Scope in `onMounted` + `onUnmounted` |\n| `reactive()` for replaceable state | Replacement breaks reactivity | Use `ref()` instead |\n| Watcher without cleanup | Memory leaks, race conditions | Use `onCleanup` or `onWatcherCleanup()` (Vue 3.5+) |\n| Options API in new Vue 3 code | Ecosystem move to Composition API | Use `\u003Cscript setup>` |\n| Plain ref for template references | No dynamic ref support, name-matching fragile | Use `useTemplateRef()` (Vue 3.5+) |\n\n## Related Skills\n\n- `accessibility` — ARIA, semantic HTML, focus management\n- `frontend-patterns` — Cross-framework frontend architecture\n- `typescript` — TypeScript best practices applied to Vue projects\n- `coding-standards` — General code quality standards\n",{"name":5,"origin":24,"description":7},"ECC","main","a73152352c0612252131e5cf84e91312a6cf17dc","development\u002Fvue-patterns","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs","https:\u002F\u002Fgithub.com\u002FHenrique1601","https:\u002F\u002Fbezerraportifolio.netlify.app\u002F","Full Stack Developer | React, Next.js, TypeScript, Node.js & IA | Construindo produtos digitais e soluções SaaS","2026-11-15 02:56:04",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Henrique1601\u002FSkiilsToIAs --skill vue-patterns",{"tool":39,"command":40},"bunx","bunx skills add Henrique1601\u002FSkiilsToIAs --skill vue-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Henrique1601\u002FSkiilsToIAs --skill vue-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fdevelopment\u002Fvue-patterns\u002FSKILL.md",true,[],[48,55,62,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7E2ANBW9V6AVX5JXNCEAWF8","rag-architect-agent","Agente Arquiteto de RAG, Embeddings & Busca Vetorial. Especialista em design e implementação de pipelines de Retrieval-Augmented Generation de alta fidelidade: chunking semântico, modelagem pgvector no PostgreSQL (Neon\u002FSupabase), busca híbrida (cosseno + BM25), reranking, validação via TypeSafe AI e filosofia Ponytail (anti-overengineering).","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fcustom-agents\u002Frag-architect-agent\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7E29KKF8R02ZRGYE2MJM67G","rag-architecture-patterns","Padrões arquiteturais e implementação de pipelines RAG (Retrieval-Augmented Generation) de alta fidelidade para qualquer projeto ou sistema. Cobre chunking semântico, embeddings, busca híbrida (pgvector + BM25), reranking, validação via TypeSafe AI e filosofia Ponytail (anti-overengineering).","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Fai-agents\u002Frag-architecture-patterns\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":66,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CWRA8E3BJ7CPY8N8EG28J1","skill-repair","Use this to fix and re-install agent skills that have failed installation.\nThis skill provides the necessary context and permissions to surgically update\nthe `manifest.json` after a fix has been applied.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fskill-repair\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CWR66FZP8FA47WVZ4Z2EXC","security-scan","Scan your Claude Code configuration (.claude\u002F directory) for security vulnerabilities, misconfigurations, and injection risks using AgentShield. Checks CLAUDE.md, settings.json, MCP servers, hooks, and agent definitions.","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-scan\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CWR0QPY58QPTR1P759TFNG","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-review\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CWQXCE40XWT4FZ3VWZFGDP","security-bounty-hunter","Hunt for exploitable, bounty-worthy security issues in repositories. Focuses on remotely reachable vulnerabilities that qualify for real reports instead of noisy local-only findings.","https:\u002F\u002Fgithub.com\u002FHenrique1601\u002FSkiilsToIAs\u002Fblob\u002Fmain\u002Futilities\u002Fsecurity-bounty-hunter\u002FSKILL.md",[],[]]