vue · patrickjs — Cursor rule: Vue.js practices for your project
A Cursor rule that tells the agent how to write Vue: Composition API, Pinia, typing and routing. Useful when the project already has .vue and .ts files.
.cursor/rules/vue.mdcWhat vue does
The file .cursor/rules/vue.mdc plugs into Cursor and steers the agent's Vue code. It covers component structure, Composition API, state management, performance, routing, forms, TypeScript, testing and build tooling. The rule favours Composition API over Options API, Pinia for stores, and Vite for development.
Scope comes from globs: **/*.vue, **/*.ts, components/**/*. So it fires on Vue and TypeScript files rather than the whole repo. alwaysApply is set to false, which keeps the rule out of every chat.
One thing to weigh: these are general recommendations, not a linter. If your project deliberately runs Options API or Vuex, the rule pushes the agent the other way, so edit it to match your codebase.
What it helps with
- write components with Composition API instead of Options API
- move shared logic into composables
- build modular Pinia stores
- type props, emits and stores
- set up lazy loading for components and routes
Example prompts for the agent
- add a new task list component following the vue rule
- refactor this component to Composition API
- why is v-show better than v-if here
How to install vue
Manually: put the files in place
.cursor/rules/vue.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/vue.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/vue.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/vue.mdManually: put the files in place
.clinerules/vue.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about vue
How do I install vue in Cursor?
Create .cursor/rules/vue.mdc in your project root and paste the rule contents into it. Cursor picks it up for the paths listed in globs.
What does the vue rule do?
It gives the agent a set of Vue practices: Composition API, composables, Pinia, typing, Vue Router, forms and tests. The agent follows them while writing or editing code.
Which files does the rule apply to?
**/*.vue, **/*.ts and components/**/*. Auto-apply is off, so the rule is not injected into every request.
Source text
vue.mdc · CC0-1.0
--- description: "Vue.js best practices and patterns for modern web applications" globs: **/*.vue, **/*.ts, components/**/* alwaysApply: false --- # Vue.js Best Practices ## Component Structure - Use Composition API over Options API - Keep components small and focused - Use proper TypeScript integration - Implement proper props validation - Use proper emit declarations - Keep template logic minimal ## Composition API - Use proper ref and reactive - Implement proper lifecycle hooks - Use composables for reusable logic - Keep setup function clean - Use proper computed properties - Implement proper watchers ## State Management - Use Pinia for state management - Keep stores modular - Use proper state composition - Implement proper actions - Use proper getters - Handle async state properly ## Performance - Use proper component lazy loading - Implement proper caching - Use proper computed properties - Avoid unnecessary watchers - Use proper v-show vs v-if - Implement proper key management ## Routing - Use Vue Router properly - Implement proper navigation guards - Use proper route meta fields - Handle route params properly - Implement proper lazy loading - Use proper navigation methods ## Forms - Use v-model properly - Implement proper validation - Handle form submission properly - Show proper loading states - Use proper error handling - Implement proper form reset ## TypeScript Integration - Use proper component type definitions - Implement proper prop types - Use proper emit declarations - Handle proper type inference - Use proper composable types - Implement proper store types ## Testing - Write proper unit tests - Implement proper component tests - Use Vue Test Utils properly - Test composables properly - Implement proper mocking - Test async operations ## Best Practices - Follow Vue style guide - Use proper naming conventions - Keep components organized - Implement proper error handling - Use proper event handling - Document complex logic ## Build and Tooling - Use Vite for development - Configure proper build setup - Use proper environment variables - Implement proper code splitting - Use proper asset handling - Configure proper optimization
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules
Similar IDE rules
All IDE rules for Frontend and UI →vue by other authors comes first.