refactor-clean

Analyze dead code with knip, depcheck, and ts-prune, then delete after tests pass.

11|2|Updated Aug 1, 2025
One-click install
npx skills add https://github.com/sc30gsw/claude-code-customes --skill refactor-clean-sc30gsw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-clean
Source: https://github.com/sc30gsw/claude-code-customes/tree/main/.claude/skills/refactor-clean
Command: npx skills add https://github.com/sc30gsw/claude-code-customes --skill refactor-clean-sc30gsw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dead or unused code can bloat a codebase and introduce hidden risks. This Skill provides a safe workflow to identify such code using analysis tools, generate a report, and guide deletions only after tests pass.

Core Features & Use Cases

  • Analyze dead code with knip, depcheck, and ts-prune to surface unused exports, files, dependencies, and exports.
  • Generate a consolidated dead-code report with severity categories (SAFE, CAUTION, DANGER).
  • Execute a safe deletion workflow guarded by full test runs and rollback if tests fail.

Quick Start

Trigger the dead-code analysis workflow and validate changes by running the project's test suite before applying any deletions.

Frequently Asked Questions about refactor-clean

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

FAQPage Schema
How do I safely remove dead code from a TypeScript codebase?

To safely remove dead code, use static analysis tools like knip, depcheck, and ts-prune to identify unused exports and files, then execute deletions only after verifying that your full test suite passes.

What is the safest workflow for pruning unused exports and dependencies?

The safest workflow for pruning unused code generates a consolidated report categorized by severity, enforces a full test run before applying any deletions, and supports rollback if the test suite fails.

How does static analysis identify dead code before deletion?

Static analysis identifies dead code by scanning the project with tools like knip and ts-prune to surface unused dependencies, files, and exports, consolidating the results into a structured report with SAFE, CAUTION, and DANGER categories.

Can I rollback code deletions if my test suite fails?

Yes, rollback is supported if tests fail. The deletion workflow enforces running the full test suite before applying changes and automatically initiates a rollback if any test failures are detected.

Do I need a full test suite to delete unused files and dependencies?

Yes, a full test suite is required. The workflow enforces running tests before applying any deletions to ensure that removing unused files, dependencies, and exports does not introduce hidden risks or break functionality.

When should I avoid automated dead code cleanup?

You should avoid automated dead code cleanup when your project lacks a comprehensive test suite, as the deletion workflow relies on passing tests to verify safety and trigger rollback if failures occur.