code-refactor

Detect magic numbers in Vue files and generate component splitting prompts.

1|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/linzb93/ai-coding-docs --skill code-refactor-linzb93
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-refactor
Source: https://github.com/linzb93/ai-coding-docs/tree/main/vue3/skills/code-refactor
Command: npx skills add https://github.com/linzb93/ai-coding-docs --skill code-refactor-linzb93

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Large Vue components and hardcoded comparison values make codebases hard to maintain. This Skill automates the detection of magic numbers in strict equality checks and analyzes oversized Vue components to produce ready-to-use AI refactoring prompts. ## Core Features & Use Cases - Magic Number Detection: Scans all .vue files under a target directory and reports hardcoded numbers or strings used in === and !== comparisons, with a whitelist to ignore patterns like .length checks. - Vue Component Split Analysis: Finds the largest .vue file in a directory (or analyzes a specified file), reports Template/Script/Style line proportions, and detects v-for loops longer than 30 lines. - AI Refactoring Prompt Generation: Outputs a detailed prompt instructing an AI to split the component into Hooks, Utils, and child Components within the same module directory, following JSDoc rules. - Use Case: Run the vue-split task on your src directory before a sprint refactor; paste the generated prompt into an AI assistant to receive a concrete split plan with new file code. ## Quick Start Ask the AI to run the code-refactor script with the vue-split type on your src directory to analyze the largest Vue component and generate a refactoring prompt.

Frequently Asked Questions about code-refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect magic numbers in Vue files?▼

Run the script with --type magic-numbers to recursively scan .vue files under the target directory. It reports every hardcoded number or numeric string used in === or !== comparisons, skipping whitelisted patterns like .length checks.

How to split a large Vue component into smaller pieces?▼

Run the script with --type vue-split and a --path pointing to a directory or file. It analyzes line distribution across Template, Script, and Style sections, detects v-for loops over 30 lines, and outputs a prompt you can send to an AI to generate Hooks, Utils, and child Components.

Does the magic number detection ignore any comparisons?▼

Yes, it uses a whitelist of regex patterns to skip lines, and by default ignores comparisons involving .length. You can add more ignore rules directly in the ignoredPatterns array inside the magic-numbers script.

What happens when no Vue file exceeds the size threshold?▼

When scanning a directory, the vue-split task finds the largest .vue file and stops if it has 700 or fewer non-empty lines, reporting that no refactoring is needed. You can still force analysis by passing a specific file path.

Can I add new refactoring checks to this tool?▼

Yes, the tool uses a strategy pattern. Add a new script exporting a run function in the scripts directory and register it in the strategies map in index.js to make it available via the --type argument.