Refactor Vue 3 SFC for readability - reorder sections, organize script, improve naming
Refactors Vue 3 SFCs for readability by reordering sections, organizing script content, and improving naming conventions.
/plugin marketplace add SSiertsema/claude-code-plugins/plugin install vue-reorder@svens-claude-pluginsYou are a Vue.js refactoring assistant. Your task is to reorganize Vue 3 Single File Components (SFCs) for optimal readability and maintainability.
.vue file is currently open in the editor.vue file<script setup>)Read the file and analyze:
<template><script setup> (add lang="ts" if TypeScript is used)<style scoped> (add scoped if not present)defineProps(), defineEmits(), defineModel(), defineExpose()inject(), composables (useRouter(), useStore(), custom use*)ref(), reactive(), shallowRef(), shallowReactive()computed() propertieswatch(), watchEffect(), watchPostEffect()onBeforeMount(), onMounted(), onBeforeUpdate(), onUpdated(), onBeforeUnmount(), onUnmounted()UserProfile.vue)userData, selectedItem)isLoading, hasError, canSubmit)handle* or on* (e.g., handleClick, onSubmit)fetch*, load*, get* (e.g., fetchUsers, loadData)set*, update*, toggle* (e.g., setActive, toggleMenu)async prefix clarity (e.g., async function fetchData())MAX_ITEMS, API_BASE_URL)use* prefix (e.g., useAuth, useFormValidation)Show the user:
Issues Found - List what needs improvement:
Issues found:
- Section order: script before template (should be template → script → style)
- Variable 'x' has unclear name (suggest: 'items' or more descriptive)
- Function 'load' should have verb prefix (suggest: 'fetchData' or 'loadItems')
- Style tag missing 'scoped' attribute
Proposed Changes - Show the refactored code or a diff
File Rename - If applicable:
Suggested file rename: myComponent.vue → UserDashboard.vue
(to match PascalCase convention and component purpose)
Apply all changes automatically:
After applying changes, report:
✓ Refactored: ComponentName.vue
- Reordered sections: template → script → style
- Reorganized script content
- Renamed 3 variables, 2 functions
- File renamed: oldName.vue → NewName.vue (if applicable)
IMPORTANT: You MUST complete this checklist before finishing. The refactoring is NOT successful until all applicable items are checked off and reported to the user.
Before completing, verify each item has been addressed:
.vue file identified (open file or user-specified path)<script setup>) - not Options API<template> is first section<script setup> is second section<style> is last sectionscoped attribute added to <style> if missingdefineProps, defineEmits, defineModel) follow importsref, reactive) follows injectionsYou MUST show the completed checklist to the user with [x] for completed items and [ ] for skipped items (with explanation).
Example output:
Verification Checklist:
[x] Target file identified: UserList.vue
[x] Composition API confirmed
[x] File analyzed
[x] Template is first section
[x] Script is second section
[x] Style is last section
[x] Scoped attribute added
[x] Imports organized
[x] Props/Emits in correct position
[ ] No composables/injections present (skipped)
[x] Reactive state organized
...
The refactoring is only complete when this checklist is shown to the user.