vue-best-practices

dedalus-erp-pas/foundation-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/dedalus-erp-pas/foundation-skills --skill vue-best-practices
0 commentsdiscussion
summary

Comprehensive best practices guide for Vue.js 3 applications. Contains guidelines across multiple categories to ensure idiomatic, maintainable, and scalable Vue.js code, including Tailwind CSS integration patterns for utility-first styling and PrimeVue component library best practices.

skill.md

Vue.js Best Practices

Comprehensive best practices guide for Vue.js 3 applications. Contains guidelines across multiple categories to ensure idiomatic, maintainable, and scalable Vue.js code, including Tailwind CSS integration patterns for utility-first styling and PrimeVue component library best practices.

When to Apply

Reference these guidelines when:

  • Writing new Vue components or composables
  • Implementing features with Composition API
  • Reviewing code for Vue.js patterns compliance
  • Refactoring existing Vue.js code
  • Setting up component architecture
  • Working with Nuxt.js applications
  • Styling Vue components with Tailwind CSS utility classes
  • Creating design systems with Tailwind and Vue
  • Using PrimeVue component library natively
  • Customizing PrimeVue theme through design tokens and definePreset()

Rule Categories

Category Focus Prefix
Composition API Proper use of Composition API patterns composition-
Component Design Component structure and organization component-
Reactivity Reactive state management patterns reactive-
Props & Events Component communication patterns props-
Template Patterns Template syntax best practices template-
Code Organization Project and code structure organization-
TypeScript Type-safe Vue.js patterns typescript-
Error Handling Error boundaries and handling error-
Tailwind CSS Utility-first styling patterns tailwind-
PrimeVue Component library integration patterns primevue-

Quick Reference

1. Composition API Best Practices

  • composition-script-setup - Always use <script setup> for single-file components
  • composition-ref-vs-reactive - Use ref() for primitives, reactive() for objects
  • composition-computed-derived - Use computed() for all derived state
  • composition-watch-side-effects - Use watch()/watchEffect() only for side effects
  • composition-composables - Extract reusable logic into composables
  • composition-lifecycle-order - Place lifecycle hooks after reactive state declarations
  • composition-avoid-this - Never use this in Composition API

2. Component Design

  • component-single-responsibility - One component, one purpose
  • component-naming-convention - Use PascalCase for components, kebab-case in templates
  • component-small-focused - Keep components under 200 lines
  • component-presentational-container - Separate logic from presentation when beneficial
  • component-slots-flexibility - Use slots for flexible component composition
  • component-expose-minimal - Only expose what's necessary via defineExpose()

3. Reactivity Patterns

  • reactive-const-refs - Always declare refs with const
  • reactive-unwrap-template - Let Vue unwrap refs in templates (no .value)
  • reactive-shallow-large-data - Use shallowRef()/shallowReactive() for large non-reactive data
  • reactive-readonly-props - Use readonly() to prevent mutations
  • reactive-toRefs-destructure - Use toRefs() when destructuring reactive objects
  • reactive-avoid-mutation - Prefer immutable updates for complex state

4. Props & Events

  • props-define-types - Always define prop types with defineProps<T>()
  • props-required-explicit - Be explicit about required vs optional props
  • props-default-values - Provide sensible defaults with withDefaults()
  • props-immutable - Never mutate props directly
  • props-validation - Use validator functions for complex prop validation
  • events-define-emits - Always define emits with defineEmits<T>()
  • events-naming - Use kebab-case for event names in templates
  • events-payload-objects - Pass objects for events with multiple values

5. Template Patterns

  • template-v-if-v-show - Use v-if for conditional rendering, v-show for toggling
  • template-v-for-key - Always use unique, stable :key with v-for
  • template-v-if-v-for - Never use v-if and v-for on the same element
  • template-computed-expressions - Move complex expressions to computed properties
  • template-event-modifiers - Use event modifiers (.prevent, .stop) appropriately
  • template-v-bind-shorthand - Use shorthand syntax (: for v-bind, @ for v-on)
  • template-v-model-modifiers - Use v-model modifiers (.trim, .number, .lazy)

6. Code Organization

  • organization-feature-folders - Organize by feature, not by type
  • organization-composables-folder - Keep composables in dedicated composables/ folder
  • organization-barrel-exports - Use index files for clean imports
  • organization-consistent-naming - Follow consistent naming conventions
  • organization-colocation - Colocate related files (component, tests, styles)

7. TypeScript Integration

  • typescript-generic-components - Use generics for reusable typed components
  • typescript-prop-types - Use TypeScript interfaces for prop definitions
  • typescript-emit-types - Type emit payloads explicitly
  • typescript-ref-typing - Specify types for refs when not inferred
  • typescript-template-refs - Type template refs with ref<InstanceType<typeof Component> | null>(null)

8. Error Handling

  • error-boundaries - Use onErrorCaptured() for component error boundaries
  • error-async-handling - Handle errors in async operations explicitly
  • error-provide-fallbacks - Provide fallback UI for error states
  • error-logging - Log errors appropriately for debugging

9. Tailwind CSS

  • tailwind-utility-first - Apply utility classes directly in templates, avoid custom CSS
  • tailwind-class-order - Use consistent class ordering (layout → spacing → typography → visual)
  • tailwind-responsive-mobile-first - Use mobile-first responsive design (sm:, md:, lg:)
  • tailwind-component-extraction - Extract repeated utility patterns into Vue components
  • tailwind-dynamic-classes - Use computed properties or helper functions for dynamic classes
  • tailwind-complete-class-strings - Always use complete class strings, never concatenate
  • tailwind-state-variants - Use state variants (hover:, focus:, active:) for interactions
  • tailwind-dark-mode - Use dark: prefix for dark mode support
  • tailwind-design-tokens - Configure design tokens in Tailwind config for consistency
  • tailwind-avoid-apply-overuse - Limit @apply usage; prefer Vue components for abstraction

10. PrimeVue

  • primevue-use-natively - Use PrimeVue components as-is with their documented props and API
  • primevue-design-tokens - Customize appearance exclusively through design tokens and definePreset()
  • primevue-no-pt-overrides - NEVER use PassThrough (pt) API to restyle components
  • primevue-no-unstyled-mode - NEVER use unstyled mode to strip and rebuild component styles
  • primevue-no-wrapper-components - NEVER wrap PrimeVue components just to override their styling
  • primevue-props-api - Use built-in props (severity, size, outlined, rounded, raised, text) for variants
  • primevue-css-layers - Configure CSS layer ordering for clean Tailwind coexistence
  • primevue-typed-components - Leverage PrimeVue's TypeScript support for type safety
  • primevue-accessibility - Maintain WCAG compliance with proper aria attributes
  • primevue-lazy-loading - Use async components for large PrimeVue imports

Key Principles

Composition API Best Practices

The Composition API is the recommended approach for Vue.js 3. Follow these patterns:

  • Always use <script setup>: More concise, better TypeScript inference, and improved performance
  • Organize code by logical concern: Group related state, computed properties, and functions together
  • Extract reusable logic to composables: Follow the use prefix convention (e.g., useAuth, useFetch)
  • Keep setup code readable: Order: props/emits, reactive state, computed, watchers, methods, lifecycle hooks

Component Design Principles

Well-designed components are the foundation of maintainable Vue applications:

  • Single Responsibility: Each component should do one thing well
  • Props Down, Events Up: Follow unidirectional data flow
  • Prefer Composition over Inheritance: Use composables and slots for code reuse
  • Keep Components Small: If a component exceeds 200 lines, consider splitting it

Reactivity Guidelines

Understanding Vue's reactivity system is crucial:

  • ref vs reactive: Use ref() for primitives and values you'll reassign; use reactive() for objects you'll mutate
  • Computed for derived state: Never store derived state in refs; use computed() instead
  • Watch for side effects: Only use watch() for side effects like API calls or localStorage
  • Be mindful of reactivity loss: Don't destructure reactive objects without toRefs()

Props & Events Patterns

Proper component communication ensures maintainable code:

  • Type your props: Use TypeScript interfaces with defineProps<T>()
  • Validate complex props: Use validator functions for business logic validation
  • Emit typed events: Use defineEmits<T>() for type-safe event handling
  • Use v-model for two-way binding: Implement modelValue prop and update:modelValue emit

Common Patterns

Script Setup Structure

Recommended structure for <script setup>:

<script setup lang="ts">
// 1. Imports
import { ref, computed, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import type { User } from '@/types'

// 2. Props and Emits
const props = defineProps<{
  userId: string
  initialData?: User
}>()

const emit = defineEmits<{
  submit: [user: User]
  cancel: []
}>()

// 3. Composables
const router = useRouter()
const { user, loading, error } = useUser(props.userId)

// 4. Reactive State
const formData = ref({ name: '', email: '' })
const isEditing = ref(false)

// 5. Computed Properties
const isValid = computed(() => {
  return formData.value.name.length > 0 && formData.value.email.includes('@')
})

// 6. Watchers (for side effects only)
watch(() => props.userId, (newId) => {
  fetchUserData(newId)
})

// 7. Methods
function handleSubmit() {
  if (isValid.value) {
    emit('submit', formData.value)
  }
}

// 8. Lifecycle Hooks
onMounted(() => {
  if (props.initialData) {
    formData.value = { ...props.initialData }
  }
})
</script>

Composable Pattern

Correct: Well-structured composable

// composables/useUser.ts
import { ref, computed, watch } from 'vue'
import type { Ref } from 'vue'
import type { User } from '@/types'

export function useUser(userId: Ref<string> | string) {
  // State
  const user = ref<User | null>(null)
  const loading = ref(false)
  const error = ref<Error | null>(null)

  // Computed
  const fullName = computed(() => {
    if (!user.value) return ''
    return `${user.value.firstName} ${user.value.lastName}`
  })

  // Methods
  async function fetchUser(id: string) {
    loading.value = true
    error.value = null
    try {
      const response = await api.getUser(id)
      user.value = response.data
    } catch (e) {
      error.value = e as Error
    } finally {
      loading.value = false
    }
  }

  // Auto-fetch when userId changes (if reactive)
  if (isRef(userId)) {
    watch(userId, (newId) => fetchUser(newId), { immediate: true })
  } else {
    fetchUser(userId)
  }

  // Return
  return {
how to use vue-best-practices

How to use vue-best-practices on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add vue-best-practices
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/dedalus-erp-pas/foundation-skills --skill vue-best-practices

The skills CLI fetches vue-best-practices from GitHub repository dedalus-erp-pas/foundation-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/vue-best-practices

Reload or restart Cursor to activate vue-best-practices. Access the skill through slash commands (e.g., /vue-best-practices) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.466 reviews
  • Nikhil Iyer· Dec 24, 2024

    I recommend vue-best-practices for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Pratham Ware· Dec 20, 2024

    Useful defaults in vue-best-practices — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Chinedu Jain· Dec 12, 2024

    I recommend vue-best-practices for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Dev Anderson· Dec 8, 2024

    Useful defaults in vue-best-practices — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Maya Khan· Dec 4, 2024

    vue-best-practices fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Omar Diallo· Nov 27, 2024

    vue-best-practices is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Nia Ghosh· Nov 23, 2024

    vue-best-practices has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Charlotte Martinez· Nov 15, 2024

    Keeps context tight: vue-best-practices is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Yash Thakker· Nov 11, 2024

    vue-best-practices is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Chinedu Harris· Nov 3, 2024

    Keeps context tight: vue-best-practices is the kind of skill you can hand to a new teammate without a long onboarding doc.

showing 1-10 of 66

1 / 7