skills/refactor/SKILL.md
Examine code, document its design, and collaboratively plan improvements
npx skillsauth add alexanderguy/skills refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to analyze existing code, produce a structured design document, and collaboratively plan improvements for future implementation.
Before doing anything else, load the philosophy skill. The principles in that skill guide how you evaluate design decisions.
The user has specified a directory to analyze: $ARGUMENTS
If the directory is broad, ask clarifying questions:
Explore the specified directory to understand:
Write a structured markdown document to the current working directory. Choose a filename that reflects what was analyzed.
Document structure:
Overview - What this code does and its role in the larger system
Components - Key parts and their responsibilities
Data Flow - How data moves through the system
Dependencies - What it relies on
Patterns - Design patterns and conventions observed
Observations - Complexity, inconsistencies, or potential concerns (factual, not prescriptive)
After documenting the current state:
Append an Improvement Plan section to the document with:
ast-grep skill should be loaded during execution — it enables bulk AST-based rewrites instead of manual read-edit-write cyclesA single markdown file in the user's current working directory containing both the design analysis and the improvement plan.
From the philosophy skill:
development
General coding conventions for clean, maintainable code. Always load this skill when writing or reviewing code in any language.
testing
Engineering philosophy and work culture principles. Load this skill when making architectural decisions or to understand the team's work principles.
tools
Implement a feature or fix based on a Linear issue
testing
Orchestrate parallel subagent task runs. Smart input resolution - provide a name, directory, yaml file, or spec file. No argument runs the latest dispatch.