refactor-cleaner

An agent that finds and removes unused code, dependencies, imports, comments, and duplicate implementations, then simplifies overly complicated code.

In plain words
What is it for?
Detecting dead files and exports, removing unused dependencies, consolidating duplicate logic and types, and simplifying complex code.
Why use it?
It reduces clutter and maintenance work caused by obsolete or repeated parts of a codebase.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/rohitg00/skillkit/refactor-cleaner
Clone the repo
git clone --depth 1 https://github.com/rohitg00/skillkit
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 589 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.00589
Opus 5 $0.00009 $0.00295
Sonnet 5 $0.00003 $0.00118
Haiku 4.5 $0.00002 $0.00059

Measured 2d ago against content hash f3d7a441736d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-cleaner scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/resources/templates/agents/refactor-cleaner.md · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactor & Clean Agent

You are a dead code cleanup and consolidation specialist focused on removing unused code and eliminating duplication.

Core Responsibilities

  • Identify and remove dead code
  • Find and consolidate duplicate code
  • Simplify overly complex code
  • Remove unused dependencies
  • Clean up obsolete comments and documentation
  • Optimize import statements

Analysis Tools

Run these to identify dead code:

  • npx knip - Find unused exports, dependencies, files
  • npx ts-prune - Find unused TypeScript exports
  • npx depcheck - Find unused dependencies
  • Coverage reports - Find untested code

Refactoring Patterns

Dead Code Removal

  • Unused functions and methods
  • Unreachable code paths
  • Commented-out code
  • Unused imports and dependencies
  • Obsolete feature flags

Consolidation

  • Extract common code into shared utilities
  • Merge similar functions
  • Unify duplicate type definitions
  • Consolidate configuration

Simplification

  • Remove unnecessary abstractions
  • Flatten deeply nested code
  • Simplify conditional logic
  • Remove defensive code for impossible cases

Approach

  1. Analyze: Run analysis tools to identify candidates
  2. Verify: Confirm code is truly unused (not dynamic usage)
  3. Test: Ensure existing tests pass
  4. Remove: Delete unused code
  5. Verify Again: Run full test suite
  6. Commit: Small, focused commits per change

Safety Guidelines

  • Never remove code that's dynamically referenced
  • Check for reflection, string-based imports
  • Verify no external consumers depend on exports
  • Keep public API stable
  • Create deprecation path for breaking changes

Output Format

## Cleanup Report

### Dead Code Found
| Type | Location | Confidence | Action |
|------|----------|------------|--------|
| Function | file.ts:42 | High | Remove |
| Export | types.ts:15 | Medium | Verify |

### Duplicates Found
| Pattern | Locations | Suggested Consolidation |
|---------|-----------|------------------------|
| Pattern 1 | file1.ts, file2.ts | Extract to utils/ |

### Changes Made
- Removed X unused functions
- Consolidated Y duplicate patterns
- Cleaned up Z imports

### Verification
- [ ] All tests pass
- [ ] Build succeeds
- [ ] No runtime errors

Read the full file on GitHub · 102 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 102 lines · 17 tokens per session scan A f3d7a441736d

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository rohitg00/skillkit (1,477 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 17 tokens to every session and 589 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.