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.
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.
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 componentscomposition-ref-vs-reactive- Useref()for primitives,reactive()for objectscomposition-computed-derived- Usecomputed()for all derived statecomposition-watch-side-effects- Usewatch()/watchEffect()only for side effectscomposition-composables- Extract reusable logic into composablescomposition-lifecycle-order- Place lifecycle hooks after reactive state declarationscomposition-avoid-this- Never usethisin Composition API
2. Component Design
component-single-responsibility- One component, one purposecomponent-naming-convention- Use PascalCase for components, kebab-case in templatescomponent-small-focused- Keep components under 200 linescomponent-presentational-container- Separate logic from presentation when beneficialcomponent-slots-flexibility- Use slots for flexible component compositioncomponent-expose-minimal- Only expose what's necessary viadefineExpose()
3. Reactivity Patterns
reactive-const-refs- Always declare refs withconstreactive-unwrap-template- Let Vue unwrap refs in templates (no.value)reactive-shallow-large-data- UseshallowRef()/shallowReactive()for large non-reactive datareactive-readonly-props- Usereadonly()to prevent mutationsreactive-toRefs-destructure- UsetoRefs()when destructuring reactive objectsreactive-avoid-mutation- Prefer immutable updates for complex state
4. Props & Events
props-define-types- Always define prop types withdefineProps<T>()props-required-explicit- Be explicit about required vs optional propsprops-default-values- Provide sensible defaults withwithDefaults()props-immutable- Never mutate props directlyprops-validation- Use validator functions for complex prop validationevents-define-emits- Always define emits withdefineEmits<T>()events-naming- Use kebab-case for event names in templatesevents-payload-objects- Pass objects for events with multiple values
5. Template Patterns
template-v-if-v-show- Usev-iffor conditional rendering,v-showfor togglingtemplate-v-for-key- Always use unique, stable:keywithv-fortemplate-v-if-v-for- Never usev-ifandv-foron the same elementtemplate-computed-expressions- Move complex expressions to computed propertiestemplate-event-modifiers- Use event modifiers (.prevent,.stop) appropriatelytemplate-v-bind-shorthand- Use shorthand syntax (:forv-bind,@forv-on)template-v-model-modifiers- Use v-model modifiers (.trim,.number,.lazy)
6. Code Organization
organization-feature-folders- Organize by feature, not by typeorganization-composables-folder- Keep composables in dedicatedcomposables/folderorganization-barrel-exports- Use index files for clean importsorganization-consistent-naming- Follow consistent naming conventionsorganization-colocation- Colocate related files (component, tests, styles)
7. TypeScript Integration
typescript-generic-components- Use generics for reusable typed componentstypescript-prop-types- Use TypeScript interfaces for prop definitionstypescript-emit-types- Type emit payloads explicitlytypescript-ref-typing- Specify types for refs when not inferredtypescript-template-refs- Type template refs withref<InstanceType<typeof Component> | null>(null)
8. Error Handling
error-boundaries- UseonErrorCaptured()for component error boundarieserror-async-handling- Handle errors in async operations explicitlyerror-provide-fallbacks- Provide fallback UI for error stateserror-logging- Log errors appropriately for debugging
9. Tailwind CSS
tailwind-utility-first- Apply utility classes directly in templates, avoid custom CSStailwind-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 componentstailwind-dynamic-classes- Use computed properties or helper functions for dynamic classestailwind-complete-class-strings- Always use complete class strings, never concatenatetailwind-state-variants- Use state variants (hover:,focus:,active:) for interactionstailwind-dark-mode- Usedark:prefix for dark mode supporttailwind-design-tokens- Configure design tokens in Tailwind config for consistencytailwind-avoid-apply-overuse- Limit@applyusage; prefer Vue components for abstraction
10. PrimeVue
primevue-use-natively- Use PrimeVue components as-is with their documented props and APIprimevue-design-tokens- Customize appearance exclusively through design tokens anddefinePreset()primevue-no-pt-overrides- NEVER use PassThrough (pt) API to restyle componentsprimevue-no-unstyled-mode- NEVER use unstyled mode to strip and rebuild component stylesprimevue-no-wrapper-components- NEVER wrap PrimeVue components just to override their stylingprimevue-props-api- Use built-in props (severity, size, outlined, rounded, raised, text) for variantsprimevue-css-layers- Configure CSS layer ordering for clean Tailwind coexistenceprimevue-typed-components- Leverage PrimeVue's TypeScript support for type safetyprimevue-accessibility- Maintain WCAG compliance with proper aria attributesprimevue-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
useprefix 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; usereactive()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
modelValueprop andupdate:modelValueemit
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-practicesHow to use vue-best-practices on Cursor
AI-first code editor with Composer
1Prerequisites
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
2Execute 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-practicesThe skills CLI fetches vue-best-practices from GitHub repository dedalus-erp-pas/foundation-skills and configures it for Cursor.
3Select 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│ • Windsurf4Verify installation
Confirm successful installation by checking the skill directory location:
.cursor/skills/vue-best-practicesReload 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.
Additional Resources
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.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 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▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.4★★★★★66 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