Install
openclaw skills install @charlie-morrison/vue-composition-analyzerAnalyze Vue 3 Composition API usage — audit reactivity patterns, composable design, ref vs reactive choices, computed properties, watcher usage, and component lifecycle hooks. Use when reviewing Vue 3 codebases, migrating from Options API, or enforcing Composition API best practices.
openclaw skills install @charlie-morrison/vue-composition-analyzerDeep analysis of Vue 3 Composition API usage. Detects anti-patterns in reactivity, composable design, watcher usage, lifecycle hooks, and component structure. Produces actionable findings with severity levels.
Use when: reviewing Vue 3 quality, migrating from Options API, auditing composable architecture, or enforcing Composition API conventions.
cat package.json 2>/dev/null | jq '{vue: .dependencies.vue, nuxt: .dependencies.nuxt, pinia: .dependencies.pinia}'
find . -name "*.vue" -not -path '*/node_modules/*' | wc -l
# Options API components
grep -rl "export default {" --include="*.vue" . 2>/dev/null | while read f; do
grep -l "data()\|methods:\|computed:" "$f" 2>/dev/null
done | sort -u | head -20
# Script setup (preferred) vs setup()
grep -rl "<script setup" --include="*.vue" . 2>/dev/null | wc -l
grep -rl "setup()" --include="*.vue" . 2>/dev/null | wc -l
Classify each component as Options API, setup(), or <script setup>. Flag mixed-style codebases.
grep -rn "ref(\|reactive(\|shallowRef\|shallowReactive" --include="*.vue" --include="*.ts" . 2>/dev/null | head -30
# Reactivity loss: destructuring reactive without toRefs
grep -rn "const {.*} = .*reactive\|let {.*} = .*reactive" --include="*.vue" --include="*.ts" . 2>/dev/null | head -15
# toRefs usage
grep -rn "toRefs\|toRef(" --include="*.vue" --include="*.ts" . 2>/dev/null | head -15
Check for:
reactive() without toRefs() silently breaks reactivityref for primitives and replaceable objects, reactive for stable complex objectsreactive({count: 0}) instead of ref(0)ref(reactive({...})) — always a buggrep -rn "computed(" --include="*.vue" --include="*.ts" . 2>/dev/null | head -20
# Side effects in computed
grep -A5 "computed(" --include="*.vue" --include="*.ts" . 2>/dev/null \
| grep -i "console\.\|fetch(\|emit(\|\.value =" | head -15
# Watchers
grep -rn "watch(\|watchEffect(" --include="*.vue" --include="*.ts" . 2>/dev/null | head -20
# Immediate watchers (often replaceable with watchEffect)
grep -A10 "watch(" --include="*.vue" --include="*.ts" . 2>/dev/null | grep "immediate: true" | head -10
# Deep watchers on large objects
grep -A10 "watch(" --include="*.vue" --include="*.ts" . 2>/dev/null | grep "deep: true" | head -10
Flag:
localStorage/window won't trigger re-computationwatchEffect()find . -name "use*.ts" -o -name "use*.js" -not -path '*/node_modules/*' 2>/dev/null | head -20
find . -path "*/composables/*" -not -name "use*" -not -path '*/node_modules/*' -name "*.ts" 2>/dev/null | head -10
# Composables using component-specific APIs
grep -rn "defineProps\|defineEmits\|useSlots" --include="*.ts" . 2>/dev/null | grep -i "composable\|use" | head -10
Evaluate:
use prefixonUnmounted# onMounted without matching onUnmounted
for f in $(grep -rl "onMounted" --include="*.vue" . 2>/dev/null); do
if ! grep -q "onUnmounted\|onBeforeUnmount" "$f"; then
echo "MISSING_CLEANUP: $f"
fi
done | head -15
# addEventListener without removeEventListener
grep -l "addEventListener" --include="*.vue" --include="*.ts" . 2>/dev/null | while read f; do
if ! grep -q "removeEventListener" "$f"; then echo "LISTENER_LEAK: $f"; fi
done | head -15
# setInterval without clearInterval
grep -l "setInterval" --include="*.vue" . 2>/dev/null | while read f; do
if ! grep -q "clearInterval" "$f"; then echo "INTERVAL_LEAK: $f"; fi
done | head -10
grep -rn "defineProps" --include="*.vue" . 2>/dev/null | head -15
grep -A5 "defineProps(\[" --include="*.vue" . 2>/dev/null | head -15
grep -rn "provide(\|inject(" --include="*.vue" --include="*.ts" . 2>/dev/null | head -15
Flag:
defineProps(['foo']) has no type safety; use object or TypeScript generic syntaxInjectionKey<T> for type safety# Vue Composition API Analysis — [Project Name]
## Summary
- Components: N | Script setup: N% | Options API remaining: N
- Critical: N | Warnings: N
## API Style Migration
| Style | Count | Files |
|-------|-------|-------|
| `<script setup>` | N | — |
| `setup()` function | N | file1.vue |
| Options API | N | legacy1.vue |
## Critical Findings
### [C1] Reactivity Loss — destructuring reactive without toRefs
- **File**: src/components/UserForm.vue:24
- **Code**: `const { name, email } = userState`
- **Fix**: `const { name, email } = toRefs(userState)`
### [C2] Side Effect in Computed
- **File**: src/composables/useCart.ts:45
- **Fix**: Move localStorage write to a watcher
## Warnings
### [W1] Missing Cleanup — addEventListener in onMounted, no onUnmounted
### [W2] Deep Watcher on 1000+ item array — watch specific properties instead
## Composable Health
| Composable | Issues |
|-----------|--------|
| useAuth | Returns raw values instead of refs |
| useCart | No cleanup for event subscription |
## Recommendations
1. Convert N Options API components to `<script setup>`
2. Add `InjectionKey<T>` types to provide/inject pairs
3. Replace `watch(..., { immediate: true })` with `watchEffect()` in N places
4. Add `onUnmounted` cleanup to N components with resource subscriptions
| Anti-Pattern | Severity | Description |
|---|---|---|
| Destructure reactive | Critical | Breaks reactivity silently |
| Side effects in computed | Critical | Non-deterministic, SSR-incompatible |
| ref(reactive(...)) | Critical | Double-wrapping, confusing unwrap |
| Missing watcher cleanup | High | Memory leaks, race conditions |
| Deep watch large objects | Medium | Performance degradation |
| watch + immediate | Low | Prefer watchEffect |
| Array-style defineProps | Low | No type safety or defaults |
npx vue-tsc --noEmit to type-check all SFC files including template expressionseffectScope() in composables that create many watchers/effects for batch cleanupuseAsyncData/useFetch for proper key usage and deduplication