refactor · tartinerlabs — Claude Code skill: audit code, then fix it
A refactoring skill that flags dead code, deep nesting and weak patterns, then applies the fixes when you ask.
npx skills add tartinerlabs/skills --skill refactor -a claude-codeWhat refactor does
The refactor skill runs in two modes. By default it audits and reports; it edits files only when you ask it to fix, refactor, apply or clean something up. If your request is vague, it reports first and offers to apply the fixes.
Three rule sets sit behind it: general patterns and design principles for any language, plus TypeScript and JavaScript idiom rules that load only for .ts, .tsx, .js, .jsx, .mts and .cts files. It scans whatever you point it at — specific files, a directory, or the whole codebase. Every finding comes back as path:line with what is wrong and the fix, grouped by category, ending with a violation count per category.
Fixes stay small. The skill verifies the change keeps existing behaviour, touches only the issue it found, and avoids new abstractions unless they are clearly warranted. It needs Read, Glob, Grep and Edit to work — without write access it stays in report mode.
What it helps with
- spot dead code and unused branches
- flatten deeply nested functions
- check a file against TypeScript idiom rules
- get findings as
path:lineaddresses - apply targeted fixes without changing behaviour
Example prompts for the agent
- audit
src/utilsagainst the refactor rules and show me the report - find dead code in
src/apiand suggest fixes - apply the fixes from the report, keep behaviour the same
How to install refactor
1Skills CLI (Vercel)
npx skills add tartinerlabs/skills --skill refactor -a claude-code2Manually: put the files in place
~/.claude/skills/refactor/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/refactor/
1Skills CLI (Vercel)
npx skills add tartinerlabs/skills --skill refactor -a codex2Manually: put the files in place
.agents/skills/refactor/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add tartinerlabs/skills --skill refactor -a cursor2Manually: put the files in place
.cursor/skills/refactor/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install tartinerlabs/skills refactor2Manually: put the files in place
.github/skills/refactor/SKILL.md1Skills CLI (Vercel)
npx skills add tartinerlabs/skills --skill refactor -a gemini-cli2Platform CLI
gemini skills install https://github.com/tartinerlabs/skills --path plugins/quality/skills/refactorManually: put the files in place
.devin/skills/refactor/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add tartinerlabs/skills --skill refactor -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
How do I install refactor in Claude?
Run npx skills add tartinerlabs/skills --skill refactor -a claude-code. The skill file lands at ~/.claude/skills/refactor/SKILL.md.
What does refactor do?
It audits code for dead code, nesting and pattern violations and reports each finding with its location. On request it applies the fixes.
Which languages do the rules cover?
General patterns and design principles apply to any language. The TypeScript and JavaScript idiom rules apply only to .ts, .tsx, .js, .jsx, .mts and .cts files.
Source text
SKILL.md · MIT
--- name: refactor description: Use when refactoring, cleaning up code, reducing complexity, fixing code smells, or improving code quality. Audits code for dead code, nesting, and patterns. license: MIT allowed-tools: Read Glob Grep Edit model: sonnet effort: high context: fork agent: general-purpose compatibility: Any language; general + design rules always apply, the TS/JS idiom rules apply only to TS/JS files metadata: short-description: Refactor and reduce code complexity. --- You are an expert code reviewer focused on refactoring. Audit and report by default; edit files only when the user asks you to fix, refactor, apply, or clean something up. When the ask is unclear, report first and offer to apply the fixes. ## Rules Overview | Rules | Scope | File | |---|---|---| | General patterns | any language | `rules/general-patterns.md` | | TypeScript/JS idioms | `.ts`/`.tsx`/`.js`/`.jsx`/`.mts`/`.cts` only | `rules/ts-idioms.md` | | Design principles | any language | `rules/design-principles.md` | ## Workflow ### Step 1: Audit Scan the target scope (specific files, directory, or full codebase) against every rule in `rules/`. ### Step 2: Report Report each finding as `path:line` — what is wrong → the fix, grouped by category, and close with a per-category violation count. ### Step 3: Fix Apply refactorings. For each fix: 1. Verify the change preserves existing behaviour 2. Keep changes minimal — only fix the identified issue 3. Do not introduce new abstractions unless clearly warranted
© tartinerlabs · MIT · tartinerlabs/skills
Similar skills
Everything for Code review and refactoring →refactor by other authors comes first.