Skip to content
Agentmart
Submit a tool

refactor-clean

Clean up dead code, unused imports, and improve code organization.

Skill by eroslifestyle

IndexedMIT★ 1
Write a review

Install

Works with Claude Code. Read the repository before you give any tool access to your data.

npx agentmarket install skill/eroslifestyle-refactor-clean

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Clean up dead code, unused imports, and improve code organization. Use /refactor for automated cleanup.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/refactor-clean

Tools it pre-approves 7

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Read,
  • Write,
  • Edit,
  • Glob,
  • Grep,
  • Bash,
  • Task

What's inside

Skill name
refactor-clean
Description
Clean up dead code, unused imports, and improve code organization. Use /refactor for automated cleanup.
License
MIT
Allowed tools
Read,, Write,, Edit,, Glob,, Grep,, Bash,, Task
Instructions
122 lines in SKILL.md · view on GitHub

Before installing

  • Pre-approves some shell commands

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Refactor Clean Skill - Automated Code Cleanup

## Purpose

Identify and clean up dead code, unused imports, overly long functions,
duplicated blocks, and other code quality issues in a codebase.

## Trigger

User invokes `/refactor [path] [--auto]` or orchestrator delegates cleanup tasks.
- `[path]`: optional, limits scope to specific directory or file
- `[--auto]`: skip confirmation, apply all changes immediately

## Algorithm

### Phase 1: SCAN (Read-Only Analysis)

1. **DISCOVER** project files via Glob (filter by language)
2. **SCAN** for issues in parallel using Grep and Read:

   **a) Unused Imports**
   - Grep for import statements
   - Grep for usage of each imported name in the same file
   - Flag imports where the name is never referenced after import

   **b) Dead Code**
   - Functions/methods never called anywhere in the project
   - Unreachable code after return/break/continue/raise
   - Variables assigned but never read

   **c) Commented-Out Code**
   - Blocks of 3+ consecutive commented lines that look like code
   - Pattern: `#\s*(def |class |if |for |while |return |import )`

   **d) Long Functions**
   - Functions exceeding 50 lines (candidates for splitting)
   - Read function to understand logical sections

   **e) Code Duplication**
   - Grep for identical or near-identical blocks (5+ lines)
   - Identify extraction candidates

3. **DELEGATE** deep analysis to Languages Refactor Specialist L2 via Task tool

### Phase 2: PROPOSE (Present Changes)

4. **BUILD** changes table:

```markdown
## Proposed Changes

| # | File | Line | Issue | Action | Impact |
|---|------|------|-------|--------|--------|
| 1 | src/utils.py | 3 | Unused import: os | REMOVE import | None |
| 2 | src/handler.py | 45-120 | Function too long (75 lines) | SPLIT into 3 functions | Low |
| 3 | src/old.py | 1-50 | Entire file unused | DELETE file | None |
```

5. **PRESENT** table to user for review

### Phase 3: APPLY (Execute Changes)

6. **CHECK** for `--auto` flag or wait for user confirmation
7. **APPLY** changes via Edit tool (all independent edits in parallel)
8. **RUN** tests via Bash to verify no regressions
9. **REPORT** results

## Output Format

```markdown
# Refactor Report

## Scan Results
- Files scanned: <N>
- Issues found: <N>
- Auto-fixable: <N>
- Needs manual review: <N>

## Proposed Changes
<changes table from Phase 2>

## Applied Changes
| # | Status | Notes |
|---|--------|-------|
| 1 | APPLIED | Removed unused import |
| 2 | APPLIED | Split into process_input(), validate(), format_output() |
| 3 | SKIPPED | User declined |

## Test Results
- Command: <test command>
- Result: PASS / FAIL
- Details: <if fail, show which tests broke>
```

## Issue Detection Patterns by Language

### Python
- Unused imports: `^(import |from .* import )` then check usage
- Dead functions: `^def \w+` then grep for calls
- Long functions: count lines between `def` and next `def`/class/EOF

### JavaScript/TypeScript
- Unused imports: `^import ` then check usage
- Dead exports: `^export (function|const|class)` then check imports
- Long functions: count lines in function body

### Go
- Unused imports: compiler will flag these (run `go build`)
- Dead functions: unexported functions never called locally

## Rules

- NEVER apply changes without showing the proposal table first (unless --auto)
- ALWAYS run tests after applying changes
- If tests fail after changes, REVERT the last batch and report
- Group related changes (e.g., removing an import + removing the function that used it)
- Preserve all comments that are actual documentation (not commented-out code)
- Do NOT refactor test files unless explicitly requested
- Do NOT change public API signatures (function names, parameters) without flagging

From eroslifestyle/Claude-Orchestrator-Plugin, MIT.

More from eroslifestyle/Claude-Orchestrator-Plugin

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Mar 3, 2026 (7 months ago)
Last release
Mar 3, 2026 (7 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from eroslifestyle

Cite this page

refactor-clean skill. Agent Mart. https://agentmart.dev/skills/eroslifestyle-refactor-clean (last updated 2026-10-24)