neo-vue
Modern Vue 3 expert skill. Supports comprehensive applications from Composition API to Pinia and Vue Router, and strictly follows the official Vue Style Guide to ensure code quality and style consistency.
Modern Vue 3 Expert Skill
Trigger On
- The user asks to write, debug, refactor, or review Vue.js code.
- The project directory contains
*.vue,*.ts/*.jsfiles specifically importing Vue APIs, or Vue-related configuration files (e.g.,vite.config.ts,vue.config.js). - The user wants to implement state management using Pinia.
- The user wants to configure routing using Vue Router.
- The user asks for a code review on existing Vue code or architecture.
Workflow
- Perceive (Environment Awareness):
- Inspect project configuration (
package.json,vite.config.ts) to identify Vue version (Vue 3 vs Vue 2) and tooling (Vite, TypeScript, ESLint, Prettier). - Identify if the file is a Single-File Component (
.vue), a composable (useX.ts), a store (store.ts), or router configuration. - Detect the presence of Pinia or Vue Router in the project dependencies.
- Inspect project configuration (
- Reason (Planning Phase):
- Evaluate the modernization level of the current code. If Vue 2 Options API is used, plan for refactoring to Vue 3 Composition API with
<script setup>. - Mentally load the rules from
references/coding-style.mdandreferences/anti-patterns.mdto ensure component naming (PascalCase), structure, and reactivity are correct. - Mentally load the best practices from
references/patterns.mdto plan architecture, utilizingrefoverreactive, and extracting logic into composables.
- Evaluate the modernization level of the current code. If Vue 2 Options API is used, plan for refactoring to Vue 3 Composition API with
- Act (Execution Phase):
- Write high-quality, idiomatic Vue 3 code using
<script setup>syntax. - Strictly follow component naming conventions (multi-word,
Base/Theprefixes) and structure (props validation, self-closing tags). - Implement state using Pinia Setup Stores and handle routing with Named Routes.
- Write high-quality, idiomatic Vue 3 code using
- Validate (Standard Validation):
- Validate that directive shorthands (
:,@,#) are used consistently. - Check that
computedproperties are pure and free of side effects. - Ensure that props are not mutated directly.
- Verify that arrays iterated with
v-forhave stable and uniquekeys, andv-ifis not used on the same element asv-for.
- Validate that directive shorthands (
Feature Roadmap (Vue 3 Core Features)
- Composition API:
<script setup>for clean, boilerplate-free component authoring. - Reactivity:
ref,reactive,computed,watch, andwatchEffectfor explicit state management. - Macros:
defineProps,defineEmits,defineExpose,defineOptions,defineModel(Vue 3.4+) for compiler-aware declarations. - Composables: Extracting and reusing stateful logic across components (e.g.,
useFetch,useAuth). - Teleport: Render components outside the main DOM hierarchy (e.g., for modals or tooltips).
- Suspense: Handle asynchronous dependencies in the component tree gracefully.
- Pinia: State management using Setup Stores instead of Vuex.
- Vue Router 4: Modern routing utilizing Composition API hooks (
useRouter,useRoute).
Coding Standards
- Component Naming: Always use multi-word PascalCase for
.vuefiles and component references in templates (e.g.,TodoItem.vue,<TodoItem />). - Setup Script: ALWAYS use
<script setup>for new Vue components. Use TypeScript (lang="ts") where possible. - Reactivity: Prioritize
refoverreactivefor local state to maintain consistency in accessing values via.value. - Props and Emits: Define Props and Emits strictly with type annotations using
defineProps<{ ... }>()anddefineEmits<{ ... }>(). - CSS Scoping: Use
<style scoped>or CSS Modules to prevent global style leakage.
Deliver
- Modern Architecture: Provide Vue 3 Composition API-based solutions utilizing modern features and TypeScript.
- Refactoring Insights: Provide actionable suggestions to upgrade legacy Options API code to Composition API or Vuex to Pinia.
- Style Compliance: Ensure all delivered code adheres to the official Vue Style Guide (Priority A & B).
Validate
- Ensure the provided code complies with Vue 3 syntax and best practices.
- Validate the avoidance of common anti-patterns (e.g., mutating props, side-effects in
computed, missingkeyinv-for). - Confirm the code is robust, readable, and properly utilizes Vue's reactivity system.