agentleFS
LeonxLJXLeonxLJX/web-engineer-skills/skills/vue3-composition/SKILL.md

vue3-composition

Skill0 starsChanged 2 months agoMITView on GitHub

Write Vue 3 Composition API code that scales past the demo — component contracts, provide/inject boundaries, v-model conventions, and when NOT to extract a composable. Use when building or reviewing Vue 3 components, composables or stores.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Props are data, not config soup: If you pass more than 5 booleans, the component is doing two jobs — split it.

    line 29
  2. Distinctive:

    If two components communicate via provide/inject and neither is an ancestor factory, that's a hidden global — use a store instead.

    line 43

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Vue 3 Composition API discipline

Contracts first

A component is an API. Before writing markup, write the contract:

// ❌ implicit contract — every prop optional, everything stringly-typed
defineProps(['item', 'dense', 'onChange'])

// ✅ explicit, typed, minimal
const props = withDefaults(defineProps<{
  item: Todo
  dense?: boolean
}>(), { dense: false })

const emit = defineEmits<{
  change: [value: Todo['id'], source: 'user' | 'sync']
}>()

Rules:

  1. Props are data, not config soup. If you pass more than 5 booleans, the component is doing two jobs — split it.
  2. defineEmits with tuple syntax — typed payloads prevent the "what's in $event again" archaeology.
  3. v-model per field, not per form. v-model:title beats passing objects with update:* noise.

provide/inject boundaries

  • provide is for framework-level context (theme, i18n, feature flags), not for skipping props.
  • Injection keys must be typed and exported from one module:
// keys.ts
export const THEME_KEY: InjectionKey<Theme> = Symbol('theme')
  • If two components communicate via provide/inject and neither is an ancestor factory, that's a hidden global — use a store instead.

Composables: extract behavior, not syntax

Extract a composable when you have stateful behavior (timer, subscription, undo stack), not to save lines:

// ✅ behavior: owns state + lifecycle
export function useInterval(cb: () => void, ms: MaybeRef<number>) {
  let id: ReturnType<typeof setInterval> | undefined
  watch(() => toValue(ms), (ms) => {
    if (id) clearInterval(id)
    if (ms > 0) id = setInterval(cb, ms)
  }, { immediate: true })
  onScopeDispose(() => id && clearInterval(id))
}

Anti-patterns:

  • useXxx() that only wraps a computed — that's a function, keep it plain.
  • Composables that call onMounted for side effects instead of watch/watchEffect — breaks SSR and testability.

Reactivity: don't lose the thread

  • Destructuring props breaks reactivity — use toRefs(props) or keep props.x.
  • reactive() for objects, ref() for primitives and API results. Mixing reactive arrays with replacement logic is a classic bug source; prefer ref<T[]> + value = next.
  • Async state: derive with computed from a single source of truth (status + data + error), never three parallel refs you must keep in sync.

Performance without micro-optimizing

  • Reach for shallowRef for large lists you replace wholesale.
  • v-memo only with measured renders; it's a contract that the memo deps fully determine output — wrong deps = stale UI.
  • Virtualize lists > 1k rows; don't paginate what users scroll.

Definition of done (agent checklist)

  • Props/emits are typed; no defineProps(['a','b'])
  • No prop drilling past 2 levels (provide or store instead)
  • Every composable owns its cleanup (onScopeDispose)
  • SSR-safe: no window/document outside lifecycle guards
  • List rendering keyed by stable ids, never index

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.