frontend-vue-patterns
Use when the user asks about Vue composables, provide/inject, Vue reactivity pitfalls, custom directives, Vue Router guards and lazy routes, Pinia setup…
от j4flmao★ 47 звёзд на GitHub
Установить frontend-vue-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Vue Patterns
Purpose
Apply production patterns to Vue 3 applications: composable design, Pinia state management, router patterns, renderless components, and slot composition.
Agent Protocol
Trigger
Exact user phrases: "Vue pattern", "Composition API pattern", "composable", "provide/inject", "Vue reactivity", "Vue directive", "Vue composable", "Vue Router", "Pinia pattern", "renderless component", "Vue slot pattern".
Input Context
Before activating, verify:
- package.json has vue (version 3).
- Whether the project uses Vue Router and/or Pinia.
- Whether the project uses Nuxt (nuxt.config present).
Output Artifact
No file output. Produces composable design, state management, routing strategy as text.
Response Format
Composable Design: {single-responsibility composable}
State Management: {Pinia setup store with actions}
Routing Strategy: {lazy routes + navigation guards}
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- Composables follow single-responsibility, useX naming, return reactive refs.
- provide/inject typed with InjectionKey for 3+ level prop drilling.
- Pinia stores use setup syntax (composition API style).
- Routes are lazy-loaded with dynamic imports.
- Navigation guards handle auth, roles, data prefetch.
- Renderless components separate logic from presentation.
- Named slots + scoped slots for flexible component composition.
Max Response Length
2560 tokens.
Component Architecture / Decision Trees
Pattern Decision Tree
What pattern fits this problem?
├── Reusable logic (no UI) -> Composable (useX)
├── Shared state across features -> Pinia store
├── Shared behavior on DOM events -> Custom directive
├── 3+ levels of prop drilling -> provide/inject
├── Flexible layout structure -> Named slots (header, footer, default)
├── Logic-only component with customizable UI -> Renderless component + scoped slots
└── Async data on page load -> composable + onMounted or route guard
Composable Decision Tree
Does the composable manage async state?
├── Yes -> Return { data, isLoading, error, refresh }
├── Does it manage pagination?
│ └── Yes -> Accept Ref<T[]>, return { currentPage, totalPages, pageItems, goToPage }
└── Does it wrap a browser API?
└── Yes -> Accept options, provide start/stop/cleanup lifecycle
State Management Decision Tree
Is the state used by:
├── One component -> ref()/reactive()
├── A component tree -> provide/inject
├── Multiple unrelated components -> Pinia store
└── Page route params -> useRoute + route query via router
Component Design Patterns
Composable for Async Data
export function useAsync<T>(fetcher: () => Promise<T>) {
const data = ref<T | null>(null)
const isLoading = ref(false)
const error = ref<string | null>(null)
async function execute() {
isLoading.value = true
error.value = null
try {
data.value = await fetcher()
} catch (e) {
error.value = e instanceof Error ? e.message : 'Unknown error'
} finally {
isLoading.value = false
}
}
return { data, isLoading, error, execute }
}
Composable for Browser APIs
export function useMediaQuery(query: string) {
const matches = ref(false)
let mql: MediaQueryList
function onChange(e: MediaQueryListEvent) { matches.value = e.matches }
onMounted(() => {
mql = window.matchMedia(query)
matches.value = mql.matches
mql.addEventListener('change', onChange)
})
onUnmounted(() => mql?.removeEventListener('change', onChange))
return { matches }
}
Composable with Computed Dependencies
export function useFilteredList<T>(items: Ref<T[]>, filterFn: () => (item: T) => boolean) {
const filtered = computed(() => items.value.filter(filterFn()))
return { filtered }
}
Custom Directive
// directives/clickOutside.ts
export const vClickOutside = {
mounted(el: HTMLElement, binding: DirectiveBinding<() => void>) {
el.__clickOutsideHandler = (e: MouseEvent) => {
if (!el.contains(e.target as Node)) binding.value()
}
document.addEventListener('click', el.__clickOutsideHandler)
},
unmounted(el: HTMLElement) {
document.removeEventListener('click', el.__clickOutsideHandler)
},
}
Renderless Component with Generic
<script setup lang="ts" generic="TItem extends { id: string | number }">
interface Props {
items: TItem[]
fetchMore: (offset: number) => Promise<TItem[]>
}
const props = defineProps<Props>()
const allItems = ref<TItem[]>([...props.items])
const isLoadingMore = ref(false)
const hasMore = ref(true)
async function loadMore() {
if (isLoadingMore.value || !hasMore.value) return
isLoadingMore.value = true
const more = await props.fetchMore(allItems.value.length)
if (more.length === 0) hasMore.value = f
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/composition-patterns.md
- references/state-router-patterns.md
- references/vue-animations.md
- references/vue-form-patterns.md
- references/vue-routing.md
- references/vue-state.md
FAQ
Что делает скилл frontend-vue-patterns?
Use when the user asks about Vue composables, provide/inject, Vue reactivity pitfalls, custom directives, Vue Router guards and lazy routes, Pinia setup stores, renderless components or scoped slots. Produces reusable Vue 3 patterns. Not for overall Vue project structure (use vue-architecture).
Как установить скилл frontend-vue-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-vue-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…