Master Vue Composition API - Composables, Reactivity Utilities, Script Setup, Provide/Inject
Master Vue Composition API patterns including composables, reactivity utilities, and provide/inject. Use when building reusable logic or converting Options API to Composition API.
/plugin marketplace add pluginagentmarketplace/custom-plugin-vue/plugin install vue-assistant@pluginagentmarketplace-vueThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyProduction-grade skill for mastering Vue's Composition API and building reusable, scalable logic.
Single Responsibility: Teach composable design patterns, advanced reactivity utilities, and modern Vue 3 composition techniques.
interface CompositionAPIParams {
topic: 'composables' | 'reactivity' | 'script-setup' | 'provide-inject' | 'all';
level: 'beginner' | 'intermediate' | 'advanced';
context?: {
existing_knowledge?: string[];
use_case?: string;
};
}
Prerequisites: vue-fundamentals
Duration: 1-2 hours
Outcome: Use <script setup> effectively
| Topic | Concept | Exercise |
|---|---|---|
| Syntax | <script setup> shorthand | Convert Options API |
| defineProps | Type-safe props | Typed component |
| defineEmits | Type-safe events | Event handling |
| defineExpose | Public API | Component ref access |
Prerequisites: Module 1
Duration: 3-4 hours
Outcome: Master all reactivity utilities
| Utility | When to Use | Exercise |
|---|---|---|
| ref() | Primitives | Counter state |
| reactive() | Objects | Form state |
| readonly() | Immutable exposure | Store state |
| toRef() | Single prop reference | Props handling |
| toRefs() | Destructure reactive | Store destructure |
| shallowRef() | Large objects | Performance opt |
| customRef() | Custom behavior | Debounced input |
Prerequisites: Modules 1-2
Duration: 4-5 hours
Outcome: Design production composables
Composable Anatomy:
// composables/useFeature.ts
export function useFeature(options?: Options) {
// 1. State (refs)
const state = ref(initialValue)
// 2. Computed (derived)
const derived = computed(() => transform(state.value))
// 3. Methods (actions)
function action() { /* ... */ }
// 4. Lifecycle (setup/cleanup)
onMounted(() => { /* setup */ })
onUnmounted(() => { /* cleanup */ })
// 5. Return (public API)
return { state: readonly(state), derived, action }
}
| Exercise | Composable | Features |
|---|---|---|
| Data Fetching | useFetch | loading, error, refetch |
| Local Storage | useStorage | sync, parse, stringify |
| Media Query | useMediaQuery | reactive breakpoints |
| Debounce | useDebounce | value, delay |
| Intersection | useIntersection | observer, cleanup |
Prerequisites: Module 3
Duration: 2 hours
Outcome: Share state across components
| Pattern | Use Case | Example |
|---|---|---|
| Theme Provider | App-wide theming | Dark/light mode |
| Auth Context | User state | Auth provider |
| Config Injection | Feature flags | Runtime config |
| Form Context | Multi-step forms | Form validation |
Prerequisites: Modules 1-4
Duration: 3-4 hours
Outcome: Expert-level composition
| Pattern | Description | Exercise |
|---|---|---|
| Composable Composition | Composables using composables | useAuth + useFetch |
| State Machines | Finite state composables | useWizard |
| Plugin Pattern | Extend with plugins | useLogger plugin |
| Async Composables | Handle async setup | useAsyncData |
const skillConfig = {
maxAttempts: 3,
backoffMs: [1000, 2000, 4000],
onFailure: 'provide_simpler_example'
}
tracking:
- event: composable_created
data: [name, complexity_score]
- event: pattern_learned
data: [pattern_name, exercises_completed]
- event: skill_mastery
data: [modules_completed, project_quality]
| Issue | Cause | Solution |
|---|---|---|
| Lost reactivity | Destructured reactive | Use toRefs() |
| inject undefined | Missing provider | Check tree hierarchy |
| Memory leak | No cleanup | Add onUnmounted cleanup |
| Type errors | Wrong generics | Specify type params |
import { describe, it, expect } from 'vitest'
import { useCounter } from './useCounter'
describe('useCounter', () => {
it('initializes with default value', () => {
const { count } = useCounter()
expect(count.value).toBe(0)
})
it('increments correctly', () => {
const { count, increment } = useCounter()
increment()
expect(count.value).toBe(1)
})
it('resets to initial value', () => {
const { count, increment, reset } = useCounter(5)
increment()
increment()
reset()
expect(count.value).toBe(5)
})
})
Skill("vue-composition-api")
vue-fundamentals - Prerequisitevue-pinia - State managementvue-typescript - Type-safe composablesThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.