# Runelight Vue Refactor Guide How to turn existing Vue 3 SFCs into `.g.vue` UI models without creating wrappers. For React, see the [React Refactor Guide](./runelight-refactor-guide.md). The canonical workflow for AI agents lives in [`skills/refactor-to-runelight-vue/SKILL.md`](../skills/refactor-to-runelight-vue/SKILL.md). This guide is the human-readable version: the decision framework, the key moves, and the traps to avoid. If the project isn't wired for Runelight yet, follow the [Setup Playbook](../installer/runelight-setup.md) first. For authoring patterns in the resulting `.g.vue`, see the [Vue Authoring Guide](./runelight-vue-authoring-guide.md). --- ## The One Rule `.g.vue` owns the real SFC template, script, styles, and enumerable visual states. It is not a wrapper around an old component. If the visual UI cannot be safely moved into `.g.vue`, skip that component. Never create a thin forwarding layer just to show progress. ## Choosing Targets Start from a user-visible visual surface, not from a file tree sweep. **Good targets** render visible DOM and own visual branches: loading, empty, error, overflow, open, selected, disabled, permission states. **Bad targets** are orchestration: route glue, provider nesting, layout slots, feature composition, data plumbing. Descend through them until you find real visual surfaces. ## Decision Flow ``` Does it render visible DOM? no → DESCEND (look at children) Does it own visual states worth previewing? no → SKIP Can those states be represented by props, frame scope, or injection values? no → SKIP Would the .g.vue just wrap the old SFC? yes → DESCEND (you'd be creating a wrapper) Is the SFC pure or mostly local visual state? yes → MIGRATE Does the template depend on composables, stores, queries, or local script state? yes → SCOPE ``` ## Migrate: Pure SFC The simplest refactor. The `.g.vue` file becomes the production component. 1. Move the real template, script, styles, props, and helpers into `Component.g.vue`. 2. Keep the component name and props contract stable. 3. Add a `` block with meaningful visual states. 4. Update imports from `./Component.vue` to `./Component.g.vue`. 5. Preserve public APIs through barrels where they exist. ## Scope: Stateful SFC Unlike React, the production `