vue-best-practices
Original:🇺🇸 English
Translated
2 scriptsChecked / no sensitive code detected
Vue.js performance optimization guidelines for building fast, maintainable applications. This skill should be used when writing, reviewing, or refactoring Vue.js code to ensure optimal performance patterns. Triggers on tasks involving Vue components, reactivity, Composition API, state management, or performance improvements.
9installs
Added on
NPX Install
npx skill4agent add vinayakkulkarni/vue-nuxt-best-practices vue-best-practicesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Vue Best Practices
Comprehensive performance optimization guide for Vue.js applications. Contains 40+ rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Writing new Vue components
- Implementing reactive state and computed properties
- Reviewing code for performance issues
- Refactoring existing Vue code
- Optimizing rendering and re-renders
- Working with Composition API or Options API
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Reactivity Fundamentals | CRITICAL | |
| 2 | Component Performance | CRITICAL | |
| 3 | Computed & Watchers | HIGH | |
| 4 | Template Optimization | MEDIUM-HIGH | |
| 5 | Composition API Patterns | MEDIUM | |
| 6 | State Management | MEDIUM | |
| 7 | Async & Data Fetching | LOW-MEDIUM | |
| 8 | Advanced Patterns | LOW | |
Quick Reference
1. Reactivity Fundamentals (CRITICAL)
- - Use ref() for primitives, reactive() for objects
reactivity-ref-vs-reactive - - Don't destructure reactive objects
reactivity-avoid-destructure - - Use toRefs() when destructuring is needed
reactivity-toRefs - - Use shallowRef() for large non-reactive data
reactivity-shallowRef - - Use toRaw() for read-only operations on large data
reactivity-raw-values
2. Component Performance (CRITICAL)
- - Use v-once for static content
component-v-once - - Use v-memo for expensive list items
component-v-memo - - Use defineAsyncComponent for heavy components
component-async - - Cache component state with KeepAlive
component-keep-alive - - Prefer functional components for stateless UI
component-functional
3. Computed & Watchers (HIGH)
- - Use computed() for derived values, not methods
computed-cache - - Avoid setters in computed when possible
computed-getter-only - - Minimize computed dependencies
computed-dependencies - - Avoid immediate watchers, use computed instead
watch-immediate - - Avoid deep watchers on large objects
watch-deep-avoid - - Always cleanup async watchers
watch-cleanup
4. Template Optimization (MEDIUM-HIGH)
- - v-show for frequent toggles, v-if for rare
template-v-show-vs-if - - Always use unique keys in v-for
template-key-attribute - - Never use v-if and v-for on same element
template-avoid-v-if-v-for - - Let compiler hoist static content
template-static-hoisting - - Use event modifiers instead of JS handlers
template-event-modifiers
5. Composition API Patterns (MEDIUM)
- - One concern per composable
composable-single-responsibility - - Return refs, not reactive objects
composable-return-refs - - Handle cleanup in composables
composable-cleanup - - Lazy initialize expensive resources
composable-lazy-init - - Use provide/inject for deep prop drilling
composable-provide-inject
6. State Management (MEDIUM)
- - Split stores by domain
state-pinia-stores - - Use getters for computed state
state-getters - - Keep mutations simple, logic in actions
state-actions-mutations - - Cleanup store subscriptions
state-subscription-cleanup
7. Async & Data Fetching (LOW-MEDIUM)
- - Use Suspense for async component loading
async-suspense - - Handle async errors gracefully
async-error-boundaries - - Implement SWR pattern for data fetching
async-stale-while-revalidate - - Cancel pending requests on unmount
async-abort-controller
8. Advanced Patterns (LOW)
- - Create directives for DOM manipulation
advanced-custom-directives - - Use render functions for dynamic templates
advanced-render-functions - - Use Teleport for modals and overlays
advanced-teleport - - Optimize list transitions
advanced-transition-groups
How to Use
Read individual rule files for detailed explanations and code examples:
rules/reactivity-ref-vs-reactive.md
rules/component-v-memo.md
rules/_sections.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
Full Compiled Document
For the complete guide with all rules expanded:
AGENTS.md