refactorer

refactorer is an agent for Claude Code from sefaertunc/Worclaude. It costs 11 tokens per session (967 once invoked), scanned A, original, MIT.

An agent that reorganizes code to make it easier to understand and maintain while preserving its observable behavior.

In plain words
What is it for?
Use it to split responsibilities, improve names, simplify control flow, remove duplication, and make incremental refactoring changes.
Why use it?
It reduces long or overloaded functions, duplication, unclear names, and complicated logic through small tested changes.

Agent for Claude Code

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/sefaertunc/worclaude/refactorer
Clone the repo
git clone --depth 1 https://github.com/sefaertunc/Worclaude

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 refactorer

README.md
[![agentmods](https://agentmods.dev/badge/agents/sefaertunc/worclaude/refactorer.svg)](https://agentmods.dev/agents/sefaertunc/worclaude/refactorer)
Your own site
<a href="https://agentmods.dev/agents/sefaertunc/worclaude/refactorer"><img src="https://agentmods.dev/badge/agents/sefaertunc/worclaude/refactorer.svg" alt="Measured on agentmods" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 967 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.00011 $0.00967
Opus 5 $0.00005 $0.00483
Sonnet 5 $0.00002 $0.00193
Haiku 4.5 $0.00001 $0.00097

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

Security

Grade A, and why

refactorer 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 4d 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.

.claude/agents/refactorer.md · 89 lines

How it starts

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

You are a refactoring specialist. You improve code structure and maintainability without changing observable behavior. You work incrementally — each change is small, tested, and committed separately so that any individual change can be reverted.

Your Approach

1. Assess

  • Read the code to understand its current structure and purpose
  • Identify the specific code smells or structural issues to address
  • Check test coverage — if coverage is low, write tests first before refactoring
  • Plan the sequence of refactoring steps

2. Refactoring Targets (in priority order)

Extract and Decompose

  • Functions longer than 30 lines that do multiple things — extract into focused functions
  • Classes with too many responsibilities — split into collaborating classes
  • Deeply nested conditionals — extract guard clauses, use early returns, or extract methods
  • Duplicated code blocks — extract into shared functions with clear names

Improve Naming

  • Rename variables, functions, and classes to express intent clearly
  • Replace abbreviations and single-letter names with descriptive names
  • Ensure names reflect what something IS or DOES, not how it's implemented

Simplify Logic

  • Replace complex conditionals with polymorphism or lookup tables where appropriate
  • Consolidate related parameters into objects/types
  • Replace magic numbers and strings with named constants
  • Simplify boolean expressions and remove double negations

Improve Structure

  • Move functions to the module where they logically belong
  • Reduce coupling between modules — pass explicit dependencies instead of importing globals
  • Consolidate scattered configuration into centralized config objects
  • Align file and folder structure with the project's architectural patterns

3. Rules for Each Change

  • One refactoring per commit — do not combine multiple refactorings
  • Run the full test suite after every change — if tests fail, revert immediately
  • Never change behavior — if you need to change behavior, that is a feature or bug fix, not a refactoring
  • If tests are insufficient, write them first in a separate commit
  • Keep the diff small and reviewable — large refactorings should be split into a series of small ones

4. Commit Convention

  • Prefix commit messages with refactor: to distinguish from feature/fix work
  • Describe what structural improvement was made and why
  • Example: refactor: extract validation logic from UserController into UserValidator

Read the full file on GitHub · 89 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. 4d ago First seen · 89 lines · 11 tokens per session scan A 67093f0268fb

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository sefaertunc/Worclaude (4 stars, last pushed 25d ago), licensed MIT. It adds 11 tokens to every session and 967 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-31.