Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add tartinerlabs/skills --skill refactor -a claude-code
Open on GitHub

What 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:line addresses
  • apply targeted fixes without changing behaviour

Example prompts for the agent

  • audit src/utils against the refactor rules and show me the report
  • find dead code in src/api and 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-code

2Manually: put the files in place

~/.claude/skills/refactor/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/refactor/

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.

refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. 22,321installs refactor parcadei Runs refactoring through analysis, planning, implementation, review and test validation. Use it when restructuring code while preserving behaviour. CX Codex +1 621installs refactor smallnest Restructures code safely based on Martin Fowler's catalog without altering external behavior. Fixes code smells through small, verifiable steps. CX Codex +1 518installs refactor pproenca A skill with 43 refactoring rules drawn from Martin Fowler's catalog and Clean Code. Useful when you want the agent to restructure code by a fixed set of rules instead of guessing. CX Codex +1 641installs refactor luongnv89 Walks the agent through six refactoring phases: code analysis, test check, code smell hunt, plan, incremental edits and review. CX Codex +1 ★ 45,153repo stars refactor-code davila7 A slash command that walks Claude through 17 refactoring steps, from analysis and tests to performance checks and review prep. 4,890installs safe-refactor JuliusBrussee Restructures code while preserving existing behavior, enforcing verification boundaries before structural edits. CX Codex +1 106,500installs review-and-refactor official github Reviews project code against local instructions and refactors parts that need changes. Use it before review or when cleaning up an existing codebase. 11,056installs refactor-safely tirth8205 Plans a refactor from a dependency graph, lists edits before a rename and checks the impact radius before large changes. CX Codex +1 1,100installs typescript-refactor pproenca A skill with 47 rules for refactoring TypeScript and React/TSX: type architecture, narrowing, generics, and modern TS 6.0 / React 19 features. CX Codex +1 788installs

From the same set5

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor