Developing Vue Components
When to use this skill
Use this skill when you need to:
- Create new Vue 3 components from scratch
- Modify existing Vue components (template, logic, or styles)
- Define or update component props, emits, and TypeScript types
- Write or update component SCSS styles
- Document component APIs and usage
- Refactor components for better type safety or structure
- Review components for best practices compliance
Component File Structure
compName.vue: Template and component logic , read more invue-guide.md
compName.ts: Props, emits, types, constants (public API) read more in typescript-guide.md
compName.scss: Component styles, read more in scss-guide.md
compName.md: Component documentation, read more in documentation-guide.md
Instructions
Creating a New Component
Follow these steps to create a new Vue component:
Create component folder: compName/
Document the component (spec-first):
- Create
compName.story.md if using Histoire, otherwise create compName.md
- Document intended props, emits, slots, and usage
- Define component behavior and user interaction patterns
- See documentation-guide.md for format
Define types and API (compName.ts):
- Define props interface with JSDoc comments
- Define emits interface
- Export types, constants, and utilities
- See typescript-guide.md for patterns
Implement component logic (compName.vue):
- Import types from
compName.ts
- Use
<script setup> with TypeScript
- Implement component logic based on documented behavior
- See vue-guide.md for structure
Build template and styling (compName.vue + compName.scss):
- Implement template structure in
compName.vue
- Style the component in
compName.scss using BEM or scoped styles
- Avoid magic values, use CSS variables
- See scss-guide.md for guidelines
Modifying an Existing Component
Understand current state:
- Read
compName.md for component intent
- Review existing implementation files
Make changes:
- Update
compName.ts if props/emits/types change
- Update
compName.vue for template or logic changes
- Update
compName.scss for styling changes
- Consult reference docs as needed
Update documentation:
- Update component documentation to reflect changes
- Update tests if behavior changed (if tests exist)
- Update stories if using Histoire (see vue-story skill)
Verify consistency:
- Ensure all files are aligned
- Check type safety (no
any or unknown)
- Verify tests pass (if tests exist)
Quality Checklist
Before completing work on any component, verify:
Best Practices
Follow these principles for maintainable, high-quality components:
Architecture:
- Single Responsibility Principle - each component does one thing well
- High cohesion, low coupling - minimize dependencies
- Clear and consistent API design
- Avoid prop drilling - use provide/inject or composables for deep data
- Design for testability and maintainability
Naming:
camelCase for component names, variables, functions, TypeScript interfaces
kebab-case for CSS class names and event names
- Descriptive names that convey purpose
Type Safety:
- Always define props and emits interfaces
- Avoid
any and unknown types
- Use JSDoc comments for props and emits
- Leverage TypeScript's inference when possible
Error Handling:
- Implement graceful degradation
- Provide user-friendly error messages
- Add appropriate console warnings/errors for developers
- Handle edge cases explicitly
Note:
- For detailed patterns and examples, consult the reference documentation in the
references/ directory.
- Starter templates are available in the
assets/ directory.
1---2name: dev-vue-component3description: Create, modify, and maintain Vue 3 components with TypeScript and SCSS. Use when building Vue components, modifying .vue files, defining component props/emits, styling with SCSS, or documenting component APIs. Handles component architecture, type safety, styling patterns, and documentation.4license: Apache-2.05---6
7# Developing Vue Components
8
9## When to use this skill
10
11Use this skill when you need to:
12
13- Create new Vue 3 components from scratch
14- Modify existing Vue components (template, logic, or styles)
15- Define or update component props, emits, and TypeScript types
16- Write or update component SCSS styles
17- Document component APIs and usage
18- Refactor components for better type safety or structure
19- Review components for best practices compliance
20
21## Component File Structure
22
23- `compName.vue`: Template and component logic , read more in[vue-guide.md](references/vue-guide.md)
24- `compName.ts`: Props, emits, types, constants (public API) read more in [typescript-guide.md](references/typescript-guide.md)
25- `compName.scss`: Component styles, read more in [scss-guide.md](references/scss-guide.md)
26- `compName.md`: Component documentation, read more in [documentation-guide.md](references/documentation-guide.md)
27
28## Instructions
29
30### Creating a New Component
31
32Follow these steps to create a new Vue component:
33
341. **Create component folder**: `compName/`
35
362. **Document the component** (spec-first):
37 - Create `compName.story.md` if using Histoire, otherwise create `compName.md`
38 - Document intended props, emits, slots, and usage
39 - Define component behavior and user interaction patterns
40 - See [documentation-guide.md](references/documentation-guide.md) for format
41
423. **Define types and API** (`compName.ts`):
43 - Define props interface with JSDoc comments
44 - Define emits interface
45 - Export types, constants, and utilities
46 - See [typescript-guide.md](references/typescript-guide.md) for patterns
47
484. **Implement component logic** (`compName.vue`):
49 - Import types from `compName.ts`
50 - Use `<script setup>` with TypeScript
51 - Implement component logic based on documented behavior
52 - See [vue-guide.md](references/vue-guide.md) for structure
53
545. **Build template and styling** (`compName.vue` + `compName.scss`):
55 - Implement template structure in `compName.vue`
56 - Style the component in `compName.scss` using BEM or scoped styles
57 - Avoid magic values, use CSS variables
58 - See [scss-guide.md](references/scss-guide.md) for guidelines
59
60### Modifying an Existing Component
61
621. **Understand current state**:
63 - Read `compName.md` for component intent
64 - Review existing implementation files
65
662. **Make changes**:
67 - Update `compName.ts` if props/emits/types change
68 - Update `compName.vue` for template or logic changes
69 - Update `compName.scss` for styling changes
70 - Consult reference docs as needed
71
723. **Update documentation**:
73 - Update component documentation to reflect changes
74 - Update tests if behavior changed (if tests exist)
75 - Update stories if using Histoire (see vue-story skill)
76
774. **Verify consistency**:
78 - Ensure all files are aligned
79 - Check type safety (no `any` or `unknown`)
80 - Verify tests pass (if tests exist)
81
82### Quality Checklist
83
84Before completing work on any component, verify:
85
86- [ ] Type-safe props and emits with JSDoc documentation
87- [ ] Component documentation is current and accurate
88- [ ] Styles follow project patterns (no magic values)
89- [ ] No hard-coded strings (use i18n if available)
90- [ ] Tests updated and passing (if tests exist)
91- [ ] Stories updated (if using Histoire - see vue-story skill)
92- [ ] Code follows naming conventions (camelCase for JS, kebab-case for CSS/events)
93- [ ] Error handling with graceful degradation
94
95## Best Practices
96
97Follow these principles for maintainable, high-quality components:
98
99**Architecture**:
100
101- Single Responsibility Principle - each component does one thing well
102- High cohesion, low coupling - minimize dependencies
103- Clear and consistent API design
104- Avoid prop drilling - use provide/inject or composables for deep data
105- Design for testability and maintainability
106
107**Naming**:
108
109- `camelCase` for component names, variables, functions, TypeScript interfaces
110- `kebab-case` for CSS class names and event names
111- Descriptive names that convey purpose
112
113**Type Safety**:
114
115- Always define props and emits interfaces
116- Avoid `any` and `unknown` types
117- Use JSDoc comments for props and emits
118- Leverage TypeScript's inference when possible
119
120**Error Handling**:
121
122- Implement graceful degradation
123- Provide user-friendly error messages
124- Add appropriate console warnings/errors for developers
125- Handle edge cases explicitly
126
127---
128
129**Note**:
130
131- For detailed patterns and examples, consult the reference documentation in the `references/` directory.
132- Starter templates are available in the `assets/` directory.