refactor-project — Claude Code skill: project-wide refactoring
refactor-project — a skill for Claude Code, Codex, Cursor and other agents that runs automated refactoring across every file in the project at once. Cuts duplication, normalises patterns, and strips legacy code in a single pass.
MIT 122 installs ★ 597 updated 2026-10-09
npx skills add FradSer/dotclaude --skill refactor-project -a claude-codeWhat refactor-project does
The skill opens by checking for a git workspace via git rev-parse --is-inside-work-tree — project-wide mode won't start outside one. The current commit hash is captured and included in the final summary so you can roll back with git restore --worktree --staged ..
Execution runs in three phases. First, Glob discovers all source files and filters out node_modules/, .git/, dist/, build/, vendor/, and .venv/. Then the refactor:code-simplifier agent launches with an aggressive mode flag for legacy removal; it auto-loads the refactor:best-practices skill and applies language-specific patterns. No confirmation prompt interrupts the run after the scope summary is shown.
The summary lists files changed, cross-file duplicates removed, and practices applied. Public interfaces and existing behaviour stay intact unless you explicitly ask for a change.
What it helps with
- eliminate duplicated code across multiple files in one run
- standardise naming conventions and style throughout the codebase
- remove legacy code with aggressive-mode cleanup
- record a rollback point before a large-scale refactor
- run project-wide refactoring without per-step confirmations
Example prompts for the agent
- Run
/refactor-projectto refactor the entire codebase - Clean up duplicate logic and unify style across all source files
- Remove legacy code from the whole project
How to install refactor-project
1Skills CLI (Vercel)
npx skills add FradSer/dotclaude --skill refactor-project -a claude-code2Manually: put the files in place
~/.claude/skills/refactor-project/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/refactor-project/
1Skills CLI (Vercel)
npx skills add FradSer/dotclaude --skill refactor-project -a codex2Manually: put the files in place
.agents/skills/refactor-project/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add FradSer/dotclaude --skill refactor-project -a cursor2Manually: put the files in place
.cursor/skills/refactor-project/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install FradSer/dotclaude refactor/skills/refactor-project2Manually: put the files in place
.github/skills/refactor-project/SKILL.md1Skills CLI (Vercel)
npx skills add FradSer/dotclaude --skill refactor-project -a gemini-cli2Platform CLI
gemini skills install https://github.com/FradSer/dotclaude --path refactor/skills/refactor-projectManually: put the files in place
.devin/skills/refactor-project/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add FradSer/dotclaude --skill refactor-project -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about refactor-project
How do I install refactor-project in Claude Code?
Run npx skills add FradSer/dotclaude --skill refactor-project -a claude-code. The skill file will be placed at ~/.claude/skills/refactor-project/SKILL.md.
What does the refactor-project skill do?
It scans all source files, launches the refactor:code-simplifier agent with cross-file optimisation, and produces a summary with a rollback command tied to the recorded commit.
Does refactor-project require a git repository?
Yes. The skill runs git rev-parse --is-inside-work-tree on startup; project-wide mode is blocked if the check fails.
Source text
SKILL.md · MIT
--- name: refactor-project description: Executes automated project-wide refactoring with a focus on cross-file optimization. This skill should be used when the user asks for project-wide refactoring, cross-file simplification, consistency standardization across the codebase, duplication reduction, or invokes "/refactor-project". argument-hint: (no arguments needed) allowed-tools: ["Task", "Read", "Bash(git:*)", "Grep", "Glob"] user-invocable: true --- # Refactor Project Command Execute automated project-wide refactoring using `refactor:code-simplifier` agent with cross-file optimization focus. ## Pre-operation Checks **Goal**: Ensure project-wide execution is explicit and reproducible. **Actions**: 1. Run `git rev-parse --is-inside-work-tree`; if false, inform user that project-wide mode requires a git workspace 2. Record current revision with `git rev-parse --short HEAD` and include it in final summary for rollback context 3. Ignore command arguments and proceed with full-project discovery ## Phase 1: Analyze Project Scope **Goal**: Discover all code files and display scope summary. **Actions**: 1. Find all code files using Glob patterns for common extensions 2. Filter out `node_modules/`, `.git/`, `dist/`, `build/`, `vendor/`, `.venv/` 3. Group files by language/extension and identify primary source directories 4. Display scope summary (file count, languages, directories) then proceed automatically See `references/scope-analysis.md` for exclusion patterns and edge cases. ## Phase 2: Launch Refactoring Agent **Goal**: Execute `refactor:code-simplifier` agent with project-wide scope and cross-file focus. **Actions**: 1. Launch `refactor:code-simplifier` agent with all discovered code files 2. Pass cross-file optimization emphasis: duplication reduction, consistent patterns 3. Pass aggressive mode flag for legacy code removal 4. Agent auto-loads `refactor:best-practices` skill and applies language-specific patterns See `references/agent-configuration.md` for detailed Task parameters. ## Phase 3: Summary **Goal**: Report comprehensive summary of project-wide changes. **Actions**: 1. Report total files refactored (count and percentage of project) 2. List changes categorized by improvement type and cross-file improvements made 3. List best practices applied and legacy code removed 4. Suggest test suite to run and recommend reviewing changes in logical groups 5. Provide safer rollback command tied to recorded baseline (for example: `git restore --worktree --staged .`) See `references/output-requirements.md` for detailed summary format. ## Requirements - Execute immediately after displaying scope (no confirmation needed) - Refactor entire project across all discovered code files - Prioritize cross-file duplication reduction and consistent patterns - Preserve behavior and public interfaces unless user explicitly requests a behavior change
© FradSer · MIT · FradSer/dotclaude