vue-best-practices · ejirocodes — скилл для Claude Code: Vue 3 на TypeScript
Скилл vue-best-practices для Claude и других агентов: помогает писать и рефакторить компоненты Vue 3 на TypeScript, настраивать Volar и моки Pinia в тестах.
MIT 301 установок ★ 6 обновлён 2026-06-25
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a claude-codeЧто делает vue-best-practices
Скилл даёт агенту набор приёмов для компонентов Vue 3 на TypeScript. Типы пропсов вытаскиваются через ComponentProps из vue-component-type-helpers, модель объявляется через defineModel с required, ссылка на элемент шаблона берётся через useTemplateRef. Внутри лежат справочники typescript.md, volar.md, components.md, tooling.md и testing.md, а таблица в начале подсказывает, какой открывать под конкретную задачу.
Часть примеров привязана к версиям: реактивная деструктуризация пропсов, useTemplateRef и useId рассчитаны на Vue 3.5, а createSpy в createTestingPinia нужен начиная с @pinia/testing 1.0. strictTemplates авторы кладут в tsconfig.app.json, не в корневой конфиг — в корневом проверка шаблонов не заработает. В Neovim с Volar 3.0 вместо ts_ls советуют vtsls.
В разделе ошибок — InstanceType<typeof Component>['$props'] там, где нужен ComponentProps, и deep: true на больших структурах, где хватает числовой глубины.
Какие задачи решает
- вытащить типы пропсов обёртки над чужим компонентом
- включить проверку шаблонов через
strictTemplates - перевести компонент с
withDefaultsна реактивную деструктуризацию пропсов - замокать Pinia-стор в тесте через
createTestingPinia - убрать рассинхрон гидрации из-за случайных id при SSR
Примеры запросов агенту
- Отрефактори
UserCard.vueпод Vue 3.5: вынеси пропсы черезComponentPropsи убериwithDefaults. - Почему падает тест с
createTestingPinia? ПосмотриCartList.spec.tsи допиши мок стора. - Настрой
strictTemplatesвtsconfig.app.jsonи объясни, что даётvueCompilerOptions.
Как установить vue-best-practices
1Через Skills CLI (Vercel)
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a claude-code2Вручную: положить файлы
~/.claude/skills/vue-best-practices/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/vue-best-practices/
1Через Skills CLI (Vercel)
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a codex2Вручную: положить файлы
.agents/skills/vue-best-practices/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a cursor2Вручную: положить файлы
.cursor/skills/vue-best-practices/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install ejirocodes/agent-skills vue/skills/vue-best-practices2Вручную: положить файлы
.github/skills/vue-best-practices/SKILL.md1Через Skills CLI (Vercel)
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a gemini-cli2Командой платформы
gemini skills install https://github.com/ejirocodes/agent-skills --path vue/skills/vue-best-practicesВручную: положить файлы
.devin/skills/vue-best-practices/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add ejirocodes/agent-skills --skill vue-best-practices -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о vue-best-practices
Как установить vue-best-practices в Claude Code?
Выполните npx skills add ejirocodes/agent-skills --skill vue-best-practices -a claude-code. Скилл окажется в ~/.claude/skills/vue-best-practices/SKILL.md.
Что делает vue-best-practices?
Подсказывает агенту, как писать и рефакторить компоненты Vue 3 на TypeScript: типы пропсов, defineModel, useTemplateRef, настройка Volar и тесты Pinia.
Под какую версию Vue написаны примеры?
Реактивная деструктуризация пропсов, useTemplateRef и useId описаны для Vue 3.5. В тестах createSpy нужен с @pinia/testing 1.0.
Исходный текст
SKILL.md · MIT
---
name: vue-best-practices
description: "Vue 3 and Vue.js best practices for TypeScript, vue-tsc, Volar, and component patterns. Use when writing, reviewing, or refactoring Vue 3 components with TypeScript, configuring Volar/vueCompilerOptions, extracting component types, working with defineModel/withDefaults, setting up Pinia store tests, or debugging Vue tooling issues. Triggers on Vue components, props extraction, wrapper components, template type checking, strictTemplates, vueCompilerOptions, Volar 3, CSS modules, fallthrough attributes, defineModel, withDefaults, deep watch, vue-router typed params, Pinia mocking, HMR SSR, moduleResolution bundler, useTemplateRef, onWatcherCleanup, useId, generic components, reactive props destructure."
license: MIT
metadata:
author: ejirocodes
version: '1.0.0'
---
# Vue 3 Best Practices
## Quick Reference
| Topic | When to Use | Reference |
|-------|-------------|-----------|
| **TypeScript** | Props extraction, generic components, useTemplateRef, JSDoc, reactive props destructure | [typescript.md](references/typescript.md) |
| **Volar** | IDE config, strictTemplates, CSS modules, directive comments, Volar 3.0 migration | [volar.md](references/volar.md) |
| **Components** | defineModel, deep watch, onWatcherCleanup, useId, deferred teleport | [components.md](references/components.md) |
| **Tooling** | moduleResolution, HMR SSR, duplicate plugin detection | [tooling.md](references/tooling.md) |
| **Testing** | Pinia store mocking, setup stores, Vue Router typed params | [testing.md](references/testing.md) |
## Essential Patterns
### Extract Component Props
```typescript
import type { ComponentProps } from 'vue-component-type-helpers'
import MyButton from './MyButton.vue'
type Props = ComponentProps<typeof MyButton>
```
### Reactive Props Destructure (Vue 3.5+)
```vue
<script setup lang="ts">
// Destructured props are reactive - preferred in Vue 3.5+
const { name, count = 0 } = defineProps<{ name: string; count?: number }>()
</script>
```
### useTemplateRef (Vue 3.5+)
```vue
<script setup lang="ts">
import { useTemplateRef, onMounted } from 'vue'
const inputRef = useTemplateRef('input') // Auto-typed
onMounted(() => inputRef.value?.focus())
</script>
<template><input ref="input" /></template>
```
### onWatcherCleanup (Vue 3.5+)
```typescript
import { watch, onWatcherCleanup } from 'vue'
watch(query, async (q) => {
const controller = new AbortController()
onWatcherCleanup(() => controller.abort())
await fetch(`/api?q=${q}`, { signal: controller.signal })
})
```
### defineModel with Required
```typescript
// Returns Ref<Item> instead of Ref<Item | undefined>
const model = defineModel<Item>({ required: true })
```
### Deep Watch with Numeric Depth
```typescript
// Vue 3.5+ - watch array mutations without full traversal
watch(items, handler, { deep: 1 })
```
### Pinia Store Test Setup
```typescript
import { createTestingPinia } from '@pinia/testing'
import { vi } from 'vitest'
mount(Component, {
global: {
plugins: [createTestingPinia({ createSpy: vi.fn })]
}
})
```
## Common Mistakes
1. **Using `InstanceType<typeof Component>['$props']`** - Use `ComponentProps` instead
2. **Missing `createSpy` in createTestingPinia** - Required in @pinia/testing 1.0+
3. **Using `withDefaults` with union types** - Use Reactive Props Destructure
4. **`strictTemplates` in wrong tsconfig** - Add to `tsconfig.app.json`, not root
5. **ts_ls with Volar 3.0** - Use vtsls instead (Neovim)
6. **`deep: true` on large structures** - Use numeric depth for performance
7. **Watching destructured props directly** - Wrap in getter: `watch(() => count, ...)`
8. **Random IDs in SSR** - Use `useId()` for hydration-safe IDs
© ejirocodes · MIT · ejirocodes/agent-skills
Похожие скиллы
Все скиллы по теме «Фронтенд и UI» →Сначала — vue-best-practices от других авторов.