vuejs-best-practices
Vue 3 and Nuxt 3 performance optimization and best practices. This skill should be used when writing, reviewing, or refactoring Vue.js code to ensure optimal performance patterns. Triggers on tasks involving Vue components, Nuxt pages, Composition API, Pinia state management, or performance improvements.
Best use case
vuejs-best-practices is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Vue 3 and Nuxt 3 performance optimization and best practices. This skill should be used when writing, reviewing, or refactoring Vue.js code to ensure optimal performance patterns. Triggers on tasks involving Vue components, Nuxt pages, Composition API, Pinia state management, or performance improvements.
Teams using vuejs-best-practices should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/vuejs-best-practices/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How vuejs-best-practices Compares
| Feature / Agent | vuejs-best-practices | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Vue 3 and Nuxt 3 performance optimization and best practices. This skill should be used when writing, reviewing, or refactoring Vue.js code to ensure optimal performance patterns. Triggers on tasks involving Vue components, Nuxt pages, Composition API, Pinia state management, or performance improvements.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Vue.js Best Practices
Comprehensive performance optimization guide for Vue 3 and Nuxt 3 applications. Contains 50+ rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.
## When to Apply
Reference these guidelines when:
- Writing new Vue 3 components or Nuxt 3 pages
- Using Composition API and composables
- Implementing data fetching (client or server-side)
- Managing state with Pinia
- Reviewing code for performance issues
- Refactoring existing Vue/Nuxt code
- Optimizing bundle size or load times
## Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Reactivity Optimization | CRITICAL | `reactivity-` |
| 2 | Bundle Size Optimization | CRITICAL | `bundle-` |
| 3 | Nuxt 3 Server Performance | HIGH | `nuxt-` |
| 4 | Component Design Patterns | HIGH | `component-` |
| 5 | Composition API Patterns | MEDIUM-HIGH | `composable-` |
| 6 | State Management (Pinia) | MEDIUM-HIGH | `pinia-` |
| 7 | Rendering Performance | MEDIUM | `rendering-` |
| 8 | TypeScript Integration | MEDIUM | `typescript-` |
| 9 | Testing Patterns | LOW-MEDIUM | `testing-` |
| 10 | Advanced Patterns | LOW | `advanced-` |
## Quick Reference
### 1. Reactivity Optimization (CRITICAL)
- `reactivity-shallowref` - Use shallowRef for large objects that don't need deep reactivity
- `reactivity-shallowreactive` - Use shallowReactive for flat objects
- `reactivity-computed-cache` - Leverage computed for expensive calculations (auto-caching)
- `reactivity-toraw` - Use toRaw() when passing to external libraries
- `reactivity-markraw` - Use markRaw() for non-reactive objects (classes, third-party instances)
- `reactivity-effectscope` - Use effectScope() to batch cleanup of effects
### 2. Bundle Size Optimization (CRITICAL)
- `bundle-tree-shaking` - Import from 'vue' not internal packages (@vue/reactivity, @vue/runtime-core)
- `bundle-async-components` - Use defineAsyncComponent for heavy components
- `bundle-dynamic-imports` - Dynamic import() for route-level code splitting
- `bundle-icon-imports` - Import icons directly, avoid icon libraries barrel files
- `bundle-lodash-es` - Use lodash-es with specific imports
- `bundle-analyze` - Use rollup-plugin-visualizer to identify bloat
- `bundle-external-cdn` - Externalize large libraries to CDN when appropriate
### 3. Nuxt 3 Server Performance (HIGH)
- `nuxt-usefetch` - Use useFetch/useAsyncData for SSR-friendly data fetching
- `nuxt-lazy-components` - Prefix with Lazy for automatic lazy loading
- `nuxt-payload-reduce` - Minimize payload with pick/transform options
- `nuxt-cache-route` - Use routeRules for caching strategies
- `nuxt-server-components` - Use .server.vue for server-only components
- `nuxt-prerender` - Prerender static pages at build time
- `nuxt-islands` - Use Nuxt Islands for partial hydration
- `nuxt-nitro-cache` - Leverage Nitro caching for API routes
### 4. Component Design Patterns (HIGH)
- `component-sfc-setup` - Always use `<script setup>` syntax
- `component-props-destructure` - Use destructuring with defineProps for reactivity
- `component-emits-typed` - Always define emits with TypeScript
- `component-slots-typed` - Type slots with defineSlots
- `component-expose` - Use defineExpose sparingly, prefer props/emits
- `component-v-once` - Use v-once for static content
- `component-v-memo` - Use v-memo for list item optimization
- `component-teleport` - Use Teleport for modals/tooltips
### 5. Composition API Patterns (MEDIUM-HIGH)
- `composable-naming` - Prefix composables with 'use' (useAuth, useFetch)
- `composable-return-object` - Return object, not array, for better DX
- `composable-cleanup` - Always handle cleanup in onUnmounted
- `composable-async` - Handle async state properly (loading, error, data)
- `composable-ssr-safe` - Check `import.meta.client` for browser-only code
- `composable-provide-inject` - Use provide/inject with InjectionKey for type safety
- `composable-vueuse` - Leverage VueUse before writing custom composables
### 6. State Management - Pinia (MEDIUM-HIGH)
- `pinia-setup-syntax` - Prefer setup stores over options stores
- `pinia-storetorefs` - Use storeToRefs() to maintain reactivity
- `pinia-actions-async` - Use actions for async operations, not getters
- `pinia-persist` - Use pinia-plugin-persistedstate for persistence
- `pinia-reset` - Implement $reset for store cleanup
- `pinia-subscribe` - Use $subscribe for side effects
- `pinia-ssr-hydration` - Handle SSR hydration properly in Nuxt
### 7. Rendering Performance (MEDIUM)
- `rendering-v-show-v-if` - v-show for frequent toggles, v-if for rare conditions
- `rendering-key-attribute` - Always use unique :key in v-for (avoid index as key)
- `rendering-virtual-scroll` - Use virtual scrolling for long lists (100+ items)
- `rendering-keep-alive` - Cache component instances with KeepAlive
- `rendering-suspense` - Use Suspense for async component loading states
### 8. TypeScript Integration (MEDIUM)
- `typescript-props-interface` - Define props with interface, not type
- `typescript-ref-type` - Explicitly type refs: `ref<string>('')`
- `typescript-template-ref` - Type template refs: `ref<HTMLInputElement | null>(null)`
- `typescript-component-type` - Use `ComponentPublicInstance` for component refs
- `typescript-generic-components` - Use generic components for reusable patterns
- `typescript-strict-inject` - Use InjectionKey<T> for type-safe provide/inject
- `typescript-event-handlers` - Type event handlers properly
### 9. Testing Patterns (LOW-MEDIUM)
- `testing-vitest` - Use Vitest for unit testing (Vue ecosystem native)
- `testing-vue-test-utils` - Use @vue/test-utils for component testing
- `testing-composables` - Test composables in isolation
- `testing-pinia` - Use createTestingPinia for store testing
- `testing-msw` - Use MSW for API mocking
- `testing-playwright` - Use Playwright for E2E with Nuxt
### 10. Advanced Patterns (LOW)
- `advanced-render-function` - Use render functions for dynamic component generation
- `advanced-custom-directive` - Create custom directives for DOM manipulation
- `advanced-plugin-pattern` - Structure plugins with proper install function
---
## Decision Trees
### When to use ref vs reactive
```
What type of data?
│
├── Primitives (string, number, boolean)
│ └── ref() ✓
│
├── Objects/Arrays (need deep reactivity)
│ └── reactive() ✓
│
├── Large objects (performance critical)
│ └── shallowRef() or shallowReactive() ✓
│
└── Non-reactive data (class instances, external libs)
└── markRaw() ✓
```
### When to use useFetch vs $fetch (Nuxt)
```
Where is the code running?
│
├── Component/Page (need SSR + reactivity)
│ └── useFetch() or useAsyncData() ✓
│
├── Server API route
│ └── $fetch() ✓
│
├── Event handler (client-side only)
│ └── $fetch() ✓
│
└── Composable (reusable)
└── useFetch() with key ✓
```
### Component communication pattern
```
What's the relationship?
│
├── Parent → Child
│ └── Props ✓
│
├── Child → Parent
│ └── Emits ✓
│
├── Siblings
│ └── Pinia store or provide/inject ✓
│
├── Deep nesting (prop drilling)
│ └── provide/inject ✓
│
└── Global state
└── Pinia store ✓
```
---
## Anti-Patterns to Avoid
### ❌ DON'T:
- Use Options API in new Vue 3 projects
- Mutate props directly
- Use `this` in `<script setup>`
- Create reactive() with primitives
- Use v-if and v-for on same element
- Forget :key in v-for loops
- Use index as :key for dynamic lists
- Access refs without .value in script
- Nest Pinia stores unnecessarily
- Use `$fetch` in components (use `useFetch`)
### ✅ DO:
- Use Composition API with `<script setup>`
- Define props and emits with TypeScript
- Use computed for derived state
- Use watchEffect for side effects
- Leverage VueUse composables
- Use Pinia for global state
- Handle loading/error states
- Clean up effects in onUnmounted
- Use Suspense for async components
---
## Performance Checklist
Before shipping:
- [ ] **Bundle analyzed?** No unexpected large dependencies
- [ ] **Lazy loading?** Routes and heavy components code-split
- [ ] **Reactivity optimized?** Using shallowRef where appropriate
- [ ] **SSR working?** No hydration mismatches
- [ ] **Images optimized?** Using nuxt/image or similar
- [ ] **API calls deduplicated?** Using useFetch with proper keys
- [ ] **State management efficient?** Not over-fetching in stores
- [ ] **List rendering optimized?** Virtual scroll for long lists
---
## Full Compiled Document
For detailed code examples, implementation patterns, and comprehensive explanations: `AGENTS.md`
Each section in AGENTS.md contains:
- Detailed explanations of why patterns matter
- Incorrect vs Correct code comparisons
- Copy-paste ready implementations
- Vue 3 and Nuxt 3 specific examples
- VueUse integration examplesRelated Skills
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-ai-sdk-best-practices
Best practices for using the Vercel AI SDK in Next.js 15 applications with React Server Components and streaming capabilities.
typescript-nestjs-best-practices-cursorrules-promp-cursorrules
Apply for typescript-nestjs-best-practices-cursorrules-promp. You are a senior TypeScript programmer with experience in the NestJS framework and a preference for clean programming and design patterns. Generate code, corrections, and refactorings that comply with
supabase-postgres-best-practices
Postgres query performance optimization and runtime best practices for Supabase. Covers indexing strategies (B-tree, GIN, GiST, BRIN, composite, partial, covering), EXPLAIN ANALYZE diagnostics, connection pooling (Supavisor transaction/session modes, pool sizing), RLS performance patterns (auth.uid() subquery caching, SECURITY DEFINER bypass), concurrency control (deadlock prevention, SKIP LOCKED, advisory locks), data access optimization (N+1 elimination, keyset pagination, batch inserts, UPSERT), runtime monitoring (pg_stat_statements, VACUUM/ANALYZE), and advanced tuning (full-text search, JSONB GIN indexing). Use when writing, reviewing, or optimizing SQL queries, diagnosing slow queries with EXPLAIN, configuring connection pooling, tuning RLS performance, implementing concurrent processing, detecting unused indexes, or resolving Postgres bottlenecks. Does NOT cover schema design (ansem-db-patterns), auth/RLS policy design (supabase-auth-patterns), or TypeScript types (typescript-best-practices).
storyblok-best-practices
Comprehensive Storyblok CMS development best practices for agency developers. Covers content modeling, SDK integration (React, Vue, Nuxt, Next.js), Visual Editor configuration, field plugins, API usage, internationalization, webhooks, and deployment patterns. Triggers on tasks involving Storyblok components, Visual Editor setup, content fetching, field plugin development, or headless CMS integration.
sojustack-best-practices
Best-practice guidance for the SojuStack monorepo (NestJS + Drizzle + Better Auth + TanStack Start). Use when editing files in apps/api or apps/web, designing routes, query/form patterns, auth/transaction flows, or implementing cross-stack features.
security-best-practices
Perform language and framework specific security best-practice reviews and suggest improvements. Trigger only when the user explicitly requests security best practices guidance, a security review/report, or secure-by-default coding help. Trigger only for supported languages (python, javascript/typescript, go). Do not trigger for general code review, debugging, or non-security tasks.
sc-best-practices-auto
单细胞分析最佳实践集合——目录索引自动发现,完整抓取HTML/MD与代码块
react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance pat...
python-best-practices
Python development best practices, patterns, and conventions. Use when writing Python code, reviewing .py files, discussing pytest, asyncio, type hints, pydantic, dataclasses, or Python project structure. Triggers on mentions of Python, pytest, mypy, ruff, black, FastAPI, Django, Flask.
prpm-json-best-practices
Best practices for structuring prpm.json package manifests with required fields, tags, organization, multi-package management, enhanced file format, eager/lazy activation, and conversion hints
open-source-best-practices
Complete framework for preparing GitHub projects for sustainable open source release. Covers security scanning with Git History Cleaner, legal foundations, governance, contributor onboarding, maintainer expectations, and GitHub Sponsors setup. Use when launching a project publicly, preparing a private repo for open source, or hardening an existing public repo for long-term maintenance.