refactor-cleaner

refactor-cleaner is an agent for Claude Code from majiayu000/vibeguard. It costs 27 tokens per session (398 once invoked), scanned A, original, MIT.

A coding agent that cleans up existing code while keeping its behavior the same. Refactoring means improving code structure without changing what the software does.

In plain words
What is it for?
Use it to find and simplify technical debt, add missing tests before refactoring, make one structural change at a time, and verify the result.
Why use it?
It helps reduce duplicate code, oversized files, deep nesting, and inconsistent names while using tests to catch accidental changes.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter.

Good fit Use it to find and simplify technical debt, add missing tests before…

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/majiayu000/vibeguard/refactor-cleaner
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.

Clone the repo
git clone --depth 1 https://github.com/majiayu000/vibeguard

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactor-cleaner

README.md
[![agentmods](https://agentmods.dev/badge/agents/majiayu000/vibeguard/refactor-cleaner.svg)](https://agentmods.dev/agents/majiayu000/vibeguard/refactor-cleaner)
Your own site
<a href="https://agentmods.dev/agents/majiayu000/vibeguard/refactor-cleaner"><img src="https://agentmods.dev/badge/agents/majiayu000/vibeguard/refactor-cleaner.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 398 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00027 $0.00398
Opus 5 $0.00014 $0.00199
Sonnet 5 $0.00005 $0.00080
Haiku 4.5 $0.00003 $0.00040

Measured 7d ago against content hash 6eed9b396889, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 7d 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.

agents/refactor-cleaner.md · 52 lines

What it actually says

Refactor Cleaner Agent

Responsibilities

Refactor code under test protection, eliminating technical debt and keeping external behavior unchanged.

Workflow

  1. Assess current situation

    • Identify duplicate code (> 20 lines of semantically identical code)
    • Identify files that are too large (>800 lines)
    • Identify nesting that is too deep (> 4 levels)
    • Identify naming inconsistencies
  2. Confirm test coverage

    • Confirm that relevant code has test coverage before refactoring
    • If there are no tests, add tests first and then refactor.
    • Run a test to confirm that the baseline is all green
  3. Perform refactoring

    • Only do one refactoring at a time (extract functions/eliminate duplicates/rename)
    • Run tests after every refactoring
    • Keep commit atomic
  4. Verification

    • All tests passed
    • Behavior unchanged
    • Improved code metrics (number of lines, complexity)

Reconstruction mode

Mode Applicable Scenarios Notes
Extract function Repeat code > 20 lines Extract on 3rd iteration
Inline function Wrapper called only once Direct deletion
Extract module File > 800 lines Split by responsibility
Rename False name Global replacement

VibeGuard Constraints

  • 1st repeat write directly, 2nd tolerate, 3rd extract (U-02)
  • Don't extract abstractions for code that only appears once
  • Do not change code style during refactoring (U-07)
  • Do not commit multiple unrelated refactors at once (U-09)
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. 7d ago First seen · 52 lines · 27 tokens per session scan A 6eed9b396889

Subscribe to this mod's changes

refactor-cleaner is an agent published in the GitHub repository majiayu000/vibeguard (41 stars, last pushed today), licensed MIT. It adds 27 tokens to every session and 398 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.

Related

Other agents, from other repositories

ring:backend-go

Senior Backend Engineer specialized in Go for high-demand financial systems. Handles API development, microservices, databases, message queues, and business logic implementation.

LerianStudio/ring · 34 tokens

ring:commons-reviewer

Reviews correct usage of Lerian lib-commons non-observability packages (lifecycle, tenancy, http, idempotency, security, database, messaging, outbox-repo side), identifies reinvented-wheel opportunities, and enforces version consistency. Runs in parallel with other reviewers.

LerianStudio/ring · 63 tokens

ring:tenancy-reviewer

Reviews correct usage of lib-commons/multitenancy patterns, tenantId propagation, database isolation, and tenant-scoped resources. Runs in parallel with other reviewers.

LerianStudio/ring · 40 tokens

ring:backend-ts

Senior Backend Engineer specialized in TypeScript/Node.js for scalable systems. Handles API development with Express/Fastify/NestJS, databases with Prisma/Drizzle, and type-safe architecture.

LerianStudio/ring · 43 tokens

ring:bff-ts

Senior BFF (Backend for Frontend) Engineer specialized in Next.js API Routes with Clean Architecture, DDD, and Hexagonal patterns. Builds type-safe API layers that aggregate and transform data for frontend consumption.

LerianStudio/ring · 47 tokens

ring:perf-reviewer

Performance Reviewer covering code-level hotspots (allocations, goroutine leaks, N+1 queries, event loop blocking) and runtime/infra misconfigurations (GOMAXPROCS, GC tuning, CFS throttling, connection pool sizing). Runs in parallel with other reviewers.

LerianStudio/ring · 62 tokens