[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M77YA6WZNFXRFATWSE59Y63Z":3,"skill-same:01M77YA6WZNFXRFATWSE59Y63Z":48},{"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":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M77YA6WZNFXRFATWSE59Y63Z","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.","503496348-ops\u002Fmischief-production","503496348-ops","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266905914?v=4","01M77X5J7XQWWZGT8998HDGXQM","AtomCollide","01M77X5J8V78Y3NXMY6BBC75X9",2,"MIT","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fecc-vue-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: HCP\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},"HCP","main","c9103dbad48ef3005f163584d0f2abd4591217f6","skills\u002Fecc-vue-patterns",1,"https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production","https:\u002F\u002Fgithub.com\u002F503496348-ops","https:\u002F\u002F503496348-ops.github.io\u002Fatomcollide-product-matrix\u002F#tree","元素碰撞-AtomCollide-AI 智能体实验室 测试人专属成长社群 正式招募\r\n我们的目标很纯粹：连接每一位测试工程师\u002FAI使用探索与爱好者，让你在这里既能扎实打磨技术硬实力，也能打通职业晋升的新通路，这是一个专注于AI领域的开源组","2026-07-30 00:35:42",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add 503496348-ops\u002Fmischief-production --skill vue-patterns",{"tool":40,"command":41},"bunx","bunx skills add 503496348-ops\u002Fmischief-production --skill vue-patterns",{"tool":43,"command":44},"pnpm","pnpm dlx skills add 503496348-ops\u002Fmischief-production --skill vue-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fecc-vue-patterns\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M77YG7NPZHE751W9QGK3H9ED","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-writing-skills\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M77YG4HPYH0GJP974DZ6KCPQ","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-writing-plans\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M77YFZW1FZ1GVC5C89NPE5M8","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-verification-before-completion\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},"01M77YFVPWANT5VE5GWBTKHPA2","using-智械工程","Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-using-superpowers\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},"01M77YFQJAW5PX3QYSBCD3B24S","using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-using-git-worktrees\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},"01M77YFMSTB70VX8W2QHNJWYB0","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002F503496348-ops\u002Fmischief-production\u002Fblob\u002Fmain\u002Fskills\u002Fsp-test-driven-development\u002FSKILL.md",[],[]]