Build or update the BlueBubbles external channel plugin for Moltbot (extension package, REST...
npx skills add vuejs-ai/skills --skill "vue-best-practices"
Install specific skill from multi-skill repository
# Description
MUST be used for Vue.js tasks. Strongly recommends Composition API with `<script setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.
# SKILL.md
name: vue-best-practices
description: MUST be used for Vue.js tasks. Strongly recommends Composition API with <script setup> and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.
license: MIT
metadata:
author: github.com/vuejs-ai
version: "17.0.0"
Vue 3 best practices, common gotchas, and performance optimization.
Reactivity
- Accessing ref() values without .value in scripts β See ref-value-access
- Destructuring reactive() objects, losing reactivity β See reactive-destructuring
- Choosing between ref() and reactive() for state β See prefer-ref-over-reactive
- Accessing refs inside arrays and collections β See refs-in-collections-need-value
- Large objects or external library data overhead β See shallow-ref-for-performance
- Using nested refs in template expressions β See template-ref-unwrapping-top-level
- Comparing reactive objects with === operator β See reactivity-proxy-identity-hazard
- Library instances breaking in reactive state β See reactivity-markraw-for-non-reactive
- Expecting watchers to fire for each state change β See reactivity-same-tick-batching
- Integrating external state management libraries β See reactivity-external-state-integration
- Tracing unexpected re-renders and state updates β See reactivity-debugging-hooks
- Deriving state with watchEffect instead of computed β See reactivity-computed-over-watcheffect-mutations
Computed
- Computed getter is making API calls or mutations β See computed-no-side-effects
- Mutating computed values causes lost changes unexpectedly β See computed-return-value-readonly
- Computed property doesn't update when expected β See computed-conditional-dependencies
- Sorting or reversing arrays destroys original data β See computed-array-mutation
- Expensive operations running too frequently every render β See computed-vs-methods-caching
- Trying to pass arguments to computed properties β See computed-no-parameters
- Complex conditions bloating inline class bindings β See computed-properties-for-class-logic
Watchers
- Need to watch a reactive object property β See watch-reactive-property-getter
- Large nested data structures causing performance issues β See watch-deep-performance
- Async operations overwriting with stale data β See watch-async-cleanup
- Creating watchers inside async callbacks β See watch-async-creation-memory-leak
- Dependencies accessed after await not tracking β See watcheffect-async-dependency-tracking
- Need to access updated DOM in watchers β See watch-flush-timing
- Uncertain whether to use watch or watchEffect β See watch-vs-watcheffect
- Duplicating initial calls and watch callbacks β See watch-immediate-option
- Can't compare old and new values correctly β See watch-deep-same-object-reference
- Template refs appearing null or stale β See watcheffect-flush-post-for-refs
Components
- Prop values being changed from a child component β See props-are-read-only
- Parent can't access child ref data in script setup β See component-ref-requires-defineexpose
- Child component throws "component not found" error β See local-components-not-in-descendants
- Click listener doesn't fire on custom component β See click-events-on-components
- HTML template parsing breaks Vue component syntax β See in-dom-template-parsing-caveats
- Grandparent can't listen to grandchild emitted events β See component-events-dont-bubble
- Wrong component renders due to naming collisions β See component-naming-conflicts
- Distinguishing Vue components from native elements β See component-naming-pascalcase
- Parent styles don't apply to multi-root component β See multi-root-component-class-attrs
- Recursive component needs to reference itself β See self-referencing-component-name
- Bundle includes components that aren't used β See prefer-local-component-registration
- Tight coupling through component ref access β See prefer-props-emit-over-component-refs
Props & Emits
- Boolean prop not parsing as expected β See prop-boolean-casting-order
- Composable doesn't update when props change β See prop-composable-reactivity-loss
- Variables referenced in defineProps cause errors β See prop-defineprops-scope-limitation
- Destructured props not updating watchers β See prop-destructured-watch-getter
- Prop validation needs component instance data β See prop-validation-before-instance
- Component emits undeclared event causing warnings β See declare-emits-for-documentation
- defineEmits used inside function or conditional β See defineEmits-must-be-top-level
- defineEmits has both type and runtime arguments β See defineEmits-no-runtime-and-type-mixed
- Event name inconsistency in templates and scripts β See emit-kebab-case-in-templates
- Event payloads need validation during development β See emit-validation-for-complex-payloads
- Native event listeners not responding to clicks β See native-event-collision-with-emits
- Component event fires twice when clicking β See undeclared-emits-double-firing
Templates
- Rendering untrusted user content as HTML β See v-html-xss-security
- Filtering or conditionally hiding list items β See no-v-if-with-v-for
- List items disappearing or swapping state unexpectedly β See v-for-key-attribute
- Getting template compilation errors with statements β See template-expressions-restrictions
- Dynamic directive arguments not working properly β See dynamic-argument-constraints
- Functions in templates modifying data unexpectedly β See template-functions-no-side-effects
- v-else elements rendering unconditionally always β See v-else-must-follow-v-if
- Child components in loops showing undefined data β See v-for-component-props
- Array order changing after sorting or reversing β See v-for-computed-reverse-sort
- Getting off-by-one errors with range iteration β See v-for-range-starts-at-one
- Performance issues with filtered or sorted lists β See v-for-use-computed-for-filtering
- "Cannot read property of undefined" runtime errors β See v-if-null-check-order
- Deciding between v-if and v-show for conditionals β See v-if-vs-v-show-performance
- v-show or v-else not working on template elements β See v-show-template-limitation
Template Refs
- Ref becomes null when element is conditionally hidden β See template-ref-null-with-v-if
- Ref array indices don't match data array in loops β See template-ref-v-for-order
- Refactoring template ref names breaks silently in code β See use-template-ref-vue35
Forms & v-model
- Initial form values not showing when using v-model β See v-model-ignores-html-attributes
- Textarea content changes not updating the ref β See textarea-no-interpolation
- iOS users cannot select dropdown first option β See select-initial-value-ios-bug
- Parent and child components have different values β See define-model-default-value-sync
- Need to handle v-model modifiers in child β See definemodel-hidden-modifier-props
- Object property changes not syncing to parent β See definemodel-object-mutation-no-emit
- Need to use updated value immediately after change β See definemodel-value-next-tick
- Real-time search/validation broken for Chinese/Japanese input β See v-model-ime-composition
- Number input returns empty string instead of zero β See v-model-number-modifier-behavior
- Migrating Vue 2 components to Vue 3 β See v-model-vue3-breaking-changes
- Custom checkbox values not submitted in forms β See checkbox-true-false-value-form-submission
Events & Modifiers
- Chaining multiple event modifiers produces unexpected results β See event-modifier-order-matters
- Need to handle same event only one time β See event-once-modifier-for-single-use
- Keyboard shortcuts fire with unintended modifier combinations β See exact-modifier-for-precise-shortcuts
- Keyboard shortcuts don't fire with system modifier keys β See keyup-modifier-timing
- Using left-handed mouse or non-standard input devices β See mouse-button-modifiers-intent
- Preventing default browser action and scroll performance together β See no-passive-with-prevent
Lifecycle
- Lifecycle hooks don't execute asynchronously β See lifecycle-hooks-synchronous-registration
- DOM access fails before component mounts β See lifecycle-dom-access-timing
- Memory leaks from unremoved event listeners β See cleanup-side-effects
- SSR rendering differs from client hydration β See lifecycle-ssr-awareness
- Expensive operations slow performance drastically β See updated-hook-performance
- DOM reads return stale values after state changes β See dom-update-timing-nexttick
Slots
- Accessing child component data in slot content β See slot-render-scope-parent-only
- Mixing named and scoped slots together β See slot-named-scoped-explicit-default
- Using v-slot on native HTML elements β See slot-v-slot-on-components-or-templates-only
- Empty wrapper elements rendering unnecessarily β See slot-conditional-rendering-with-slots
- Scoped slot props lack TypeScript type safety β See slot-define-slots-for-typescript
- Rendering empty component slots without defaults β See slot-fallback-content-default-values
- Wrapper components breaking child slot functionality β See slot-forwarding-to-child-components
- Confused about which slot content goes where β See slot-implicit-default-content
- Expecting name property in scoped slot props β See slot-name-reserved-prop
- Choosing between renderless components and composables β See slot-renderless-components-vs-composables
Provide/Inject
- Injected values not updating when provider changes β See provide-inject-reactivity-not-automatic
- Calling provide after async operations fails silently β See provide-inject-synchronous-setup
- String keys collide in large applications β See provide-inject-symbol-keys
- Tracing where provided values come from β See provide-inject-debugging-challenges
- Multiple components share same default object β See provide-inject-default-value-factory
- State mutations scattered across components β See provide-inject-mutations-in-provider
- Passing props through many component layers β See avoid-prop-drilling-use-provide-inject
Attrs
- Both internal and fallthrough event handlers execute β See attrs-event-listener-merging
- Accessing hyphenated attributes in JavaScript code β See attrs-hyphenated-property-access
- Watching fallthrough attributes for changes with watch() β See attrs-not-reactive
- Explicit attributes overwritten by fallthrough values β See fallthrough-attrs-overwrite-vue3
- Attributes applying to wrong element in wrappers β See inheritattrs-false-for-wrapper-components
Composables
- Composable has unexpected side effects affecting external state β See composable-avoid-hidden-side-effects
- Composable called outside setup context or asynchronously β See composable-call-location-restrictions
- Building complex logic from smaller focused composables β See composable-composition-pattern
- Inconsistent composable names or destructuring loses reactivity β See composable-naming-return-pattern
- Composable has many optional parameters or confusing argument order β See composable-options-object-pattern
- Need to prevent uncontrolled mutations of composable state β See composable-readonly-state
- Composable reactive dependency not updating when input changes β See composable-tovalue-inside-watcheffect
- Unsure whether logic belongs in composable or utility function β See composable-vs-utility-functions
Composition API
- Optimizing production bundle size and performance β See composition-api-bundle-size-minification
- Composition API code becoming scattered and hard to maintain β See composition-api-code-organization
- Fixing naming conflicts and unclear data origins in mixins β See composition-api-mixins-replacement
- Applying functional patterns incorrectly to Vue state β See composition-api-not-functional-programming
- Gradually migrating large Options API codebase β See composition-api-options-api-coexistence
- Lifecycle hooks failing silently after async operations β See composition-api-script-setup-async-context
- Coming from React, over-engineering Vue patterns unnecessarily β See composition-api-vs-react-hooks-differences
- Parent component refs unable to access exposed properties β See define-expose-before-await
Directives
- Storing state across directive hooks β See directive-arguments-read-only
- Applying custom directives to Vue components β See directive-avoid-on-components
- Creating intervals or event listeners in directives β See directive-cleanup-in-unmounted
- Simplifying directives with identical behavior β See directive-function-shorthand
- Using custom directives in script setup β See directive-naming-v-prefix
- Choosing between custom and built-in directives β See directive-prefer-declarative-templating
- Deciding between directives and components β See directive-vs-component-decision
- Migrating Vue 2 directives to Vue 3 β See directive-vue2-migration-hooks
Transitions
- Wrapping multiple elements or components in transitions β See transition-single-element-slot
- Transitioning between same element types without animation β See transition-key-for-same-element
- Using JavaScript animations without calling done callback β See transition-js-hooks-done-callback
- Animating lists with TransitionGroup without unique keys β See transition-group-key-requirement
- Performance problems with janky list animations β See transition-animate-transform-opacity
- Move animations failing on inline list elements β See transition-group-flip-inline-elements
- List items jumping instead of smoothly animating β See transition-group-move-animation-position-absolute
- Vue 2 to Vue 3 transition layout breaks unexpectedly β See transition-group-no-default-wrapper-vue3
- Trying to sequence list animations with mode prop β See transition-group-no-mode-prop
- Creating cascading delays for list item animations β See transition-group-staggered-animations
- Overlapping elements or layout jumping during transitions β See transition-mode-out-in
- Nested transition animations cutting off prematurely β See transition-nested-duration
- Reusable transition components with scoped styles breaking β See transition-reusable-scoped-style
- RouterView transitions unexpectedly animating on page load β See transition-router-view-appear
- Mixing CSS transitions and animations causing timing issues β See transition-type-when-mixed
- Component cleanup not firing during fast transition replacements β See transition-unmount-hook-timing
Animation
- Need to animate elements staying in DOM β See animation-class-based-technique
- Animations not triggering on content changes β See animation-key-for-rerender
- Building interactive animations with user input β See animation-state-driven-technique
- Animating list changes causing noticeable lag β See animation-transitiongroup-performance
KeepAlive
- Using KeepAlive without proper cache limits or cleanup β See keepalive-memory-management
- KeepAlive include/exclude props not matching cached components β See keepalive-component-name-requirement
- Need to programmatically remove component from KeepAlive cache β See keepalive-no-cache-removal-vue3
- Users see stale cached content when expecting fresh page data β See keepalive-router-fresh-vs-cached
- Child components mount twice with nested Vue Router routes β See keepalive-router-nested-double-mount
- Memory grows when combining KeepAlive with Transition animations β See keepalive-transition-memory-leak
- Dynamic component state resets when switching between them β See dynamic-components-with-keepalive
Async Components
- Setting up Vue Router route component loading β See async-component-vue-router
- Async component options ignored by parent Suspense β See async-component-suspense-control
- Network failures or timeouts loading components β See async-component-error-handling
- Improving Time to Interactive with SSR apps β See async-component-hydration-strategies
- Template refs undefined after component reactivation β See async-component-keepalive-ref-issue
- Loading spinner flashing on fast networks β See async-component-loading-delay
Render Functions
- Render function from setup doesn't update reactively β See rendering-render-function-return-from-setup
- Same vnode appearing multiple times in tree β See render-function-vnodes-must-be-unique
- Rendering lists in render functions without keys β See render-function-v-for-keys-required
- Implementing .stop, .prevent in render functions β See render-function-event-modifiers
- Two-way binding on components in render functions β See render-function-v-model-implementation
- Using string names for components in render functions β See rendering-resolve-component-for-string-names
- Accessing vnode internals like el or shapeFlag β See render-function-avoid-internal-vnode-properties
- Creating simple stateless presentational components β See render-function-functional-components
- Applying custom directives in render functions β See render-function-custom-directives
- Excessive rerenders from watchers or deep watchers β See rendering-excessive-rerenders-watch-vs-computed
- Choosing render functions over templates β See rendering-prefer-templates-over-render-functions
- Migrating Vue 2 render functions to Vue 3 β See rendering-render-function-h-import-vue3
- Passing slot content to h() incorrectly β See rendering-render-function-slots-as-functions
- Understanding Vue's vdom optimization blocks β See rendering-understand-vdom-block-structure
Teleport
- Teleport target element not found in DOM β See teleport-target-must-exist
- Teleported content breaks SSR hydration β See teleport-ssr-hydration
- Modal breaks with parent CSS transforms β See teleport-css-positioning-issues
- Content needs different layout on mobile β See teleport-disabled-for-responsive
- Unsure if props/events work through teleport β See teleport-logical-hierarchy-preserved
- Multiple modals targeting same container β See teleport-multiple-to-same-target
- Scoped styles not applying to teleported content β See teleport-scoped-styles-limitation
Suspense
- Need to handle async errors from Suspense components β See suspense-no-builtin-error-handling
- Want to track Suspense loading states programmatically β See suspense-events-for-state-tracking
- Planning Suspense usage in production applications β See suspense-experimental-api-stability
- Fallback not showing when content changes β See suspense-fallback-not-immediate-on-revert
- Nesting Suspense components together β See suspense-nested-suspensible-prop
- Combining Suspense with Router, Transition, KeepAlive β See suspense-nesting-order-with-router
- Nested async component not showing loading indicator β See suspense-revert-only-on-root-change
- Multiple async components in single Suspense β See suspense-single-child-requirement
- Using Suspense with server-side rendering β See suspense-ssr-hydration-issues
TypeScript
- Declaring props with TypeScript in composition API components β See ts-defineprops-type-based-declaration
- Providing default values to mutable prop types β See ts-withdefaults-mutable-factory-function
- Typing reactive state with ref unwrapping concerns β See ts-reactive-no-generic-argument
- Accessing DOM elements after component mounts β See ts-template-ref-null-handling
- Typing refs to child Vue components β See ts-component-ref-typeof-instancetype
- Using custom directives with TypeScript support β See ts-custom-directive-type-augmentation
- Declaring component events with full type safety β See ts-defineemits-type-based-syntax
- Handling optional boolean props in TypeScript β See ts-defineprops-boolean-default-false
- Using imported types safely in defineProps β See ts-defineprops-imported-types-limitations
- Handling DOM events with strict TypeScript checking β See ts-event-handler-explicit-typing
- Sharing data between components with type safety β See ts-provide-inject-injection-key
- Storing Vue components in reactive state β See ts-shallowref-for-dynamic-components
- Working with union types in Vue templates β See ts-template-type-casting
SSR
- User data leaking between server requests β See state-ssr-cross-request-pollution
- HTML differs between server and client renders β See ssr-hydration-mismatch-causes
- Code runs on both server and browser environments β See ssr-platform-specific-apis
- Custom directives not displaying on server-rendered HTML β See ssr-custom-directive-getssrprops
Performance
- Many list items re-rendering unnecessarily during state changes β See perf-props-stability-update-optimization
- Rendering hundreds or thousands of items causing DOM performance issues β See perf-virtualize-large-lists
- Static content re-evaluated on every parent component update β See perf-v-once-v-memo-directives
- List performance degrading from deeply nested component structure β See perf-avoid-component-abstraction-in-lists
- Computed properties returning objects triggering effects unexpectedly β See perf-computed-object-stability
- Page load metrics suffering from client-side JavaScript execution delay β See perf-ssr-ssg-for-page-load
SFC (Single File Components)
- Trying to use named exports from component script blocks β See sfc-named-exports-forbidden
- Starting a Vue project with a build setup β See sfc-recommended-for-build-projects
- Styling child component elements with scoped CSS β See sfc-scoped-css-child-component-styling
- Styling content added dynamically with v-html β See sfc-scoped-css-dynamic-content
- Optimizing scoped CSS selector performance β See sfc-scoped-css-performance
- Styling content passed through component slots β See sfc-scoped-css-slot-content
- Variables not updating in template after changes β See sfc-script-setup-reactivity
- Organizing component template, logic, and styles β See sfc-separation-of-concerns-colocate
- Binding inline styles with property names β See style-binding-camelcase
- Building Tailwind classes with string concatenation β See tailwind-dynamic-class-generation
Plugins
- Debugging why global properties cause naming conflicts β See plugin-global-properties-sparingly
- Plugin not working or inject returns undefined β See plugin-install-before-mount
- Global properties not available in setup function β See plugin-prefer-provide-inject-over-global-properties
- Creating a new Vue plugin from scratch β See plugin-structure-install-method
- Preventing collisions between multiple plugins β See plugin-symbol-injection-keys
- Global properties missing TypeScript autocomplete support β See plugin-typescript-type-augmentation
App Configuration
- App configuration methods not working after mount call β See configure-app-before-mount
- Need to chain app configuration methods after mount β See mount-return-value
- Vue only controlling specific page sections β See multiple-app-instances
- Migrating dynamic component registration to Vite β See dynamic-component-registration-vite
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.