affaan-m/ecc/vue-patterns
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
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. Use when building or reviewing Vue 3, Nuxt, or Pinia code — Composition API, reactivity, or router navigation.
Install
npx vskill@latest install affaan-m/ecc/vue-patternsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Vue.js Patterns and Best Practices
Comprehensive guide for Vue.js 3 development using Composition API (<script setup>), covering component design, reactivity, state management, routing, testing, and SSR patterns. Nuxt-specific guidance is included where it differs from vanilla Vue.
When to Activate
Activate this skill when:
- The project uses Vue.js (any version), Nuxt, Vite + Vue, or Pinia.
- The user asks about Vue component architecture, composables, reactivity, or state management.
- Reviewing Vue Single-File Components (
.vuefiles). - Setting up Vue Router, Pinia stores, or Vite/Vitest configuration.
- Discussing Vue-specific performance, security, or SSR patterns.
1. Project Structure
Recommended Layout (Feature-First)
File Naming
| Convention | When to Use | |
|---|---|---|
PascalCase.vue | All components (enforced by vue/multi-word-component-names) | |
useCamelCase.ts | Composables | |
camelCase.ts | Utilities, API clients, types | |
kebab-case directories | Route segments, feature folders |
2. Component Architecture
Single-File Component Order
Presentational vs Container
- Container components: Own data fetching, state, and side effects. Render presentational components.
- Presentational components: Receive props, emit events. No API calls, no store access. Pure rendering.
Props Best Practices
- Always provide
type, andrequired/defaultwhere appropriate. - Boolean props:
isXxx,hasXxx,canXxx. - Never mutate props — emit events instead.
- For v-model binding, use
defineModel()(Vue 3.4+) ormodelValue+update:modelValue.
Events
- Use kebab-case in templates (
@update:model-value). - Use camelCase in script (
emit("update:modelValue", val)).
3. Composables (Reusable Logic)
Structure
Rules
- Must start with
useprefix. - Return reactive values (
ref,computed,reactive), never plain primitives. - Accept reactive inputs via
MaybeRef/toRef()/toValue(). - Clean up side effects in
onUnmountedor watcheronCleanup. - No module-scope side effects.
vs Mixins
Composables replace Vue 2 mixins entirely:
- Mixins: Opaque data flow, source-of-truth collisions, name conflicts.
- Composables: Explicit imports, clear return values, composable and tree-shakable.
4. State Management
When to Use What
| Pattern | Use Case | |
|---|---|---|
ref() / reactive() | Local component state | |
| Props + Emits | Parent-child communication | |
| Provide / Inject | Theme, config, plugin API | |
| Pinia store | Global, shared, complex state | |
| Server state composable | API data with caching (wrap fetch/TanStack Query) |
Pinia Setup Store (Preferred)
- Use Setup Store syntax (not Options Store).
- Prefer actions for business-level mutations and
$patch()for grouped updates. - Every async action: handle loading + success + error.
5. Vue Router
Route Definitions
Navigation Guards
Reactive Route Params
When a component stays mounted but route params change:
6. Template Patterns
Template Syntax
7. Performance
| Technique | When to Use | |
|---|---|---|
v-memo | List items that rarely change | |
v-once | Content rendered once and static forever | |
shallowRef() | Large data structures replaced wholesale | |
shallowReactive() | Only top-level properties are reactive | |
v-show over v-if | Frequent visibility toggles | |
<KeepAlive :max="10"> | Cache toggled views | |
| Lazy routes | () => import(...) for non-critical routes | |
Suspense | Async component loading with fallback |
8. Testing
Stack
- Vitest for unit and component tests
- Vue Test Utils for mounting and interaction
- @pinia/testing for store mocking
- Playwright for E2E
Component Test Pattern
9. Nuxt-Specific Patterns
Auto-Imports
Nuxt auto-imports ref, computed, watch, useFetch, useAsyncData, etc. Use them directly without importing. For non-Nuxt projects, always import explicitly.
useAsyncData / useFetch
Server Routes
Runtime Config
10. Vue 3.5+ New APIs
Reactive Props Destructure
Vue 3.5 stabilized reactive props destructure — destructured variables from defineProps() are automatically reactive:
useTemplateRef()
Replace name-matched plain refs with useTemplateRef() for template references:
Supports dynamic ref IDs: useTemplateRef(dynamicRefId).
onWatcherCleanup()
Globally importable watcher cleanup API (Vue 3.5+). It must be called synchronously inside the watcher callback:
useId()
SSR-stable unique ID generation for form elements and accessibility:
defer Teleport
<Teleport defer> allows teleporting to targets rendered in the same cycle:
Lazy Hydration (SSR)
defineAsyncComponent() now supports hydrate strategy:
Anti-Patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 93 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/vue-patterns/SKILL.md
Popularity
- Repository stars
- 252,703
- Repository forks
- 37,913
- 7-day trend score
- 62
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/affaan-m/ecc/vue-patterns)