Index of every page on this site: llms.txt
All skills
vuejs-ai avatar

/vue-best-practices

@198f0cd official #11 trending · Oct 2026
by Vue AIvuejs-ai/skills3.4k stars
199
Run it yourself

MUST be used for Vue.js tasks. Strongly recommends Composition API with `<script setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.

Use this Skill: https://skilld.dev/gh/vuejs-ai/skills/vue-best-practices

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈84 tokens for metadata: the name and description. ≈2.5k when used: this file. ≈27k more on demand in 22 files.

Description uses 4.2% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈336 characters, or 4.2%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Vue Best Practices Workflow

Use this skill as an instruction set. Follow the workflow in order unless the user explicitly asks for a different order.

Core Principles

  • Keep state predictable: one source of truth, derive everything else.
  • Make data flow explicit: Props down, Events up for most cases.
  • Decompose by responsibility: keep each implementation focused and the contracts between implementations explicit.
  • Avoid unnecessary re-renders: use computed properties and watchers wisely.
  • Readability counts: write clear, self-documenting code.

1) Confirm architecture before coding (required)

  • Default stack: Vue 3 + Composition API + <script setup lang="ts">.
  • If the project explicitly uses Options API, load vue-options-api-best-practices skill if available.
  • If the project explicitly uses JSX, load vue-jsx-best-practices skill if available.

1.1 Must-read core references (required)

  • Before implementing any Vue task, make sure to read and apply these core references:
    • references/reactivity.md
    • references/sfc.md
    • references/component-data-flow.md
    • references/composables.md
  • Keep these references in active working context for the entire task, not only when a specific issue appears.

1.2 Plan component boundaries before coding (required)

For a non-trivial feature or structural refactor, sketch responsibilities, state owners, and the contracts that cross their boundaries. For local fixes, preserve existing boundaries unless they obstruct the change.

  • Identify substantial UI responsibilities, stateful workflows, and DOM lifecycles in the affected feature. Sketch their owners, consumers, and the contracts needed for coordination.
  • Judge cohesion by behavior that changes together or maintains a shared invariant. Being on the same page, reading the same data, or having only one consumer does not by itself justify one implementation.
  • Let root/route components compose features and coordinate page behavior. Apply the same responsibility review inside feature components and composables; moving a whole feature to a child or a useFeature() function is not sufficient decomposition.
  • Follow the project's layout and scale the design to the affected behavior. A local fix does not require a project-wide component map or new architectural layers.

2) Apply essential Vue foundations (required)

These are essential, must-know foundations. Apply all of them in every Vue task using the core references already loaded in section 1.1.

Reactivity

  • Must-read reference from 1.1: reactivity
  • Keep source state minimal (ref/reactive), derive everything possible with computed.
  • Use watchers for side effects if needed.
  • Avoid recomputing expensive logic in templates.

SFC structure and template safety

  • Must-read reference from 1.1: sfc
  • Keep SFC sections in this order: <script> → <template> → <style>.
  • Keep SFC responsibilities cohesive; use the boundary criteria below when splitting.
  • Keep templates declarative; move branching/derivation to script.
  • Apply Vue template safety rules (v-html, list rendering, conditional rendering choices).

Choose useful boundaries

  • Extract substantial, separable UI responsibilities and stateful workflows when doing so reduces the code a consumer or maintainer must understand. Single-use components and composables are valid; reuse is not a prerequisite. Keep the state and event handling needed by a UI responsibility with that UI.
  • During a structural refactor, implement useful boundaries for the responsibilities identified above. Review what remains together as well as what was extracted. A small public API can hide an implementation that still needs decomposition.
  • Treat file length, UI section count, and API size as review signals, not extraction thresholds. Keep a small cohesive production feature in one SFC when extra boundaries would not hide meaningful complexity.
  • If a split adds extensive forwarding or mutual callbacks, first move local state and DOM behavior to their UI owner, then identify genuinely shared dependencies and their lifetime. Use explicit contracts or scoped context as appropriate. Merge only when the boundary has no useful responsibility to encapsulate, not merely to reduce wiring.
  • Group inputs only when they form a cohesive concept. Passing a whole controller, grouping unrelated handlers, or adding catch-all events does not reduce the dependencies consumers must understand.

Component data flow

  • Must-read reference from 1.1: component-data-flow
  • Use props down, events up as the primary model.
  • Use v-model only for true two-way component contracts.
  • Use typed, scoped provide/inject for shared descendant dependencies when intermediate components only relay them; reassess component boundaries first. See the data-flow reference for scope and ownership.
  • Keep contracts explicit and typed with defineProps, defineEmits, and InjectionKey as needed.

Composables

  • Must-read reference from 1.1: composables
  • Compose substantial stateful behavior from focused capabilities, including single-use workflows that improve code organization. Keep simple component-local logic local; use plain functions for pure calculations.
  • Distinguish implementation ownership from the public facade. A coordinator connects capabilities and implements cross-capability operations; it should not contain all their implementations or re-export all their internals.
  • Return consumer-facing state and actions. If a consumer needs unrelated groups of internals, review that consumer's responsibilities too. Encapsulate reactive bookkeeping so consumers can read current values without manually triggering invalidation.
  • Keep DOM interaction and cleanup with its owning UI or composable. Preserve the explicit coordination other features need, such as committing a pending draft before saving.

3) Consider optional features only when requirements call for them

3.1 Standard optional features

Do not add these by default. Load the matching reference only when the requirement exists.

3.2 Less-common optional features

Use these only when there is explicit product or technical need.

  • Directives: behavior is DOM-specific and not a good composable/component fit -> directives
  • Async components: heavy/rarely-used UI should be lazy loaded -> component-async
  • Render functions only when templates cannot express the requirement -> render-functions
  • Plugins when behavior must be installed app-wide -> plugins
  • State management patterns: app-wide shared state crosses feature boundaries -> state-management

4) Run performance optimization after behavior is correct

Performance work is a post-functionality pass. Do not optimize before core behavior is implemented and verified.

5) Final self-check before finishing

  • Core behavior works and matches requirements.
  • All must-read references were read and applied.
  • Reactivity model is minimal and predictable.
  • SFC structure and template rules are followed.
  • Both sides of the boundary review pass: substantial separable responsibilities are not still concentrated in one implementation, and extracted units hide useful complexity rather than merely forward it.
  • Public contracts are typed and hide internals. Trace a representative local change through the code: it should stay with its responsible UI/workflow and legitimate coordination, without unrelated forwarding edits.
  • State has explicit ownership and lifetime; shared consumers use the same intended instance, independent instances remain independent, and side effects clean up with their owner.
  • Refactors preserve existing behavior, including pending work and cross-feature operations. Use the project's applicable tests; API or file-size reductions alone are not evidence of success.
  • Optional features are used only when requirements demand them.
  • Performance changes were applied only after functionality was complete.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts28d5 checks · Risk SAFE
  • Gen Agent Trust Hub28d

    The skill provides comprehensive and standard best practices for Vue.js 3 development, focusing on the Composition API, performance optimization, and secure coding patterns such as HTML sanitization.

  • Socket28d

    No alerts

  • Snyk28d

    Risk: LOW · No issues

  • Runlayer8mo

    23 files scanned · No issues

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 198f0cd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated last month
metadata
{
  "author": "github.com/vuejs-ai",
  "version": "19.1.0"
}
  • Vue
  • TypeScript
  • composition-api
  • script-setup
  • vue-router
  • pinia
  • vite
  • ssr
  • volar
  • component-design

README badge

README badge for vuejs-ai/skills/vue-best-practices

Instructs Claude to follow Vue 3 best practices using Composition API with `<script setup>` and TypeScript, covering reactivity, component splitting, data flow, and composables. Load this skill for any Vue work—it enforces a workflow that prioritizes minimal state, explicit props/events, focused components, and defers optional features until requirements demand them.

Generated from the current SKILL.md.

Should I use Options API or Composition API?
Use Composition API with <script setup> and TypeScript as the default. Only switch to Options API if the project explicitly requires it.
Does this skill cover Vue 2?
No. This skill targets Vue 3, Composition API, <script setup>, and TypeScript.
When should I split a component into smaller components?
Split when a component has more than one clear responsibility, contains 3+ distinct UI sections, or has repeated template blocks. Keep entry/root and route view components thin unless the feature is a small throwaway demo.
What references should I read before starting a Vue task?
You must read and keep active: reactivity.md, sfc.md, component-data-flow.md, and composables.md. Load additional optional references only when requirements call for slots, animations, state management, or other specific features.
When should I add state management like Pinia?
Only when app-wide shared state crosses feature boundaries. For most features, use composables and props/events for data flow instead.

Generated from the current SKILL.md. These answers refresh after source changes.