refactor-clean

Remove dead code and consolidate duplicate code blocks in a codebase.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/hafidzlvm/opencode --skill refactor-clean-hafidzlvm
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactor-clean
Source: https://github.com/hafidzlvm/opencode/tree/main/.dsh/skills/refactor-clean
Command: npx skills add https://github.com/hafidzlvm/opencode --skill refactor-clean-hafidzlvm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate unused functions, unreachable branches, and copy-pasted duplicates over time, making maintenance harder and increasing the risk of inconsistent bug fixes. This Skill guides an AI assistant through identifying and removing that cruft. ## Core Features & Use Cases - Dead Code Removal: Detect and delete unused functions, variables, and unreachable code paths. - Duplicate Consolidation: Find repeated code blocks and merge them into shared, reusable implementations. - Use Case: After a large feature refactor, invoke this Skill with a target module to strip out leftover unused helpers and merge duplicated validation logic into a single utility function. ## Quick Start Invoke /refactor-clean with the file or directory you want cleaned, for example by asking to remove dead code and consolidate duplicates in the src/utils folder.

Frequently Asked Questions about refactor-clean

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

FAQPage Schema
How do I remove dead code from my project?▼

Invoke this Skill with the target file or directory, and the assistant will scan for unused functions, variables, and unreachable branches, then propose or apply removals. Review the suggested changes before committing to ensure nothing referenced dynamically is deleted.

How to consolidate duplicate code blocks automatically?▼

The Skill identifies repeated logic across files and merges it into a single shared implementation, updating call sites accordingly. Provide the scope you want analyzed, such as a module or package, to keep the consolidation focused.

Is automated dead code removal safe to run?▼

Dead code removal is generally safe for statically referenced code, but reflection, dynamic imports, or string-based lookups can create hidden usages. Always run your test suite after cleanup and review deletions involving public APIs or entry points.

When should I not run automated refactoring cleanup?▼

Avoid running it right before a release or on code with incomplete test coverage, since subtle behavioral changes may go unnoticed. It works best on well-tested modules where deletions and consolidations can be verified quickly.