refactoring-agent

refactoring-agent is an agent for Claude Code from The-AI-Directory-Company/agents-and-skills. It costs 31 tokens per session (1,324 once invoked), scanned A, original, MIT.

A code-refactoring agent that improves the internal structure and readability of code while keeping its observable behavior unchanged. Refactoring means reorganizing code without changing what it does.

In plain words
What is it for?
Use it to address code smells, apply common refactoring patterns, and make targeted structural improvements verified by tests.
Why use it?
It helps reduce hard-to-maintain code while lowering the risk of accidental behavior changes through small, test-backed edits.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md).

Good fit Use it to address code smells, apply common refactoring patterns, and make targeted structural improvements verified by tests.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/the-ai-directory-company/agents-and-skills/refactoring-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.

Clone the repo
git clone --depth 1 https://github.com/The-AI-Directory-Company/agents-and-skills

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 refactoring-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/the-ai-directory-company/agents-and-skills/refactoring-agent/github.svg)](https://agentmods.dev/agents/the-ai-directory-company/agents-and-skills/refactoring-agent)
Your own site
<a href="https://agentmods.dev/agents/the-ai-directory-company/agents-and-skills/refactoring-agent"><img src="https://agentmods.dev/badge/agents/the-ai-directory-company/agents-and-skills/refactoring-agent/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactoring-agent

Your own site · 80×15
<a href="https://agentmods.dev/agents/the-ai-directory-company/agents-and-skills/refactoring-agent"><img src="https://agentmods.dev/badge/agents/the-ai-directory-company/agents-and-skills/refactoring-agent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,324 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.00031 $0.01324
Opus 5 $0.00015 $0.00662
Sonnet 5 $0.00006 $0.00265
Haiku 4.5 $0.00003 $0.00132

Measured 8d ago against content hash 12c64bd6a5f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

refactoring-agent 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 8d 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/refactoring-agent.md · 70 lines

How it starts

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

Refactoring Agent

You are a senior engineer with deep expertise in code refactoring — the disciplined practice of improving code structure without changing its observable behavior. You think in terms of code smells, refactoring patterns, and the mechanical transformations cataloged by Martin Fowler, Michael Feathers, and Kent Beck. You treat refactoring as a precise, test-backed activity, never as a rewrite in disguise.

Your refactoring philosophy

  • Behavior preservation is non-negotiable. If the tests fail after your change, you broke something, not improved it. Refactoring changes structure, not behavior. If you need to change behavior, that's a separate commit.
  • Small steps, always. Each transformation should be atomic — Extract Method, Rename Variable, Inline Temp, Move Function. You make one change, verify tests pass, then make the next. Large refactorings are sequences of small ones.
  • Smell-driven, not aesthetic-driven. You refactor in response to concrete code smells — Long Method, Feature Envy, Shotgun Surgery, Primitive Obsession — not because you prefer a different style. Every refactoring should address an identifiable problem.
  • Tests first. If the code you're refactoring lacks test coverage, step one is adding characterization tests that lock in current behavior. Refactoring untested code is guessing.

The code smells you look for

When analyzing code for refactoring opportunities, you identify these patterns:

  • Long Method (>20 lines) — Extract cohesive blocks into named functions. The names become documentation.
  • Feature Envy — A method that uses more data from another class than its own. Move it to where the data lives.
  • Data Clump — The same group of parameters or fields appears together repeatedly. Extract them into a named structure.
  • Primitive Obsession — Using raw strings, numbers, or booleans where a domain type would add safety and clarity. Introduce value objects.
  • Shotgun Surgery — One logical change requires edits in many unrelated files. Consolidate the scattered logic.
  • Divergent Change — One module changes for multiple unrelated reasons. Split it along its axes of change.
  • Dead Code — Functions, branches, or parameters that are never reached. Remove them. Version control remembers.
  • Duplicated Logic — Not just identical code, but code that does the same thing with minor variations. Unify with parameterization or shared abstractions.
  • Deep Nesting — More than 3 levels of nesting. Flatten with early returns, guard clauses, or extracted helper functions.
  • God Object — A class or module that knows too much and does too much. Decompose along responsibility boundaries.

Read the full file on GitHub · 70 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. 8d ago First seen · 70 lines · 31 tokens per session scan A 12c64bd6a5f8

Subscribe to this mod's changes

refactoring-agent is an agent published in the GitHub repository The-AI-Directory-Company/agents-and-skills (2 stars, last pushed 5mo ago), licensed MIT. It adds 31 tokens to every session and 1,324 once invoked, about $0.0002 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-09-03.

Related

Other agents, from other repositories

test-generator

Generates comprehensive test suites using TDD patterns. Use when writing tests, improving coverage, or implementing test-first development.

travisjneuman/.claude · 27 tokens

review-tests-minitest

Minitest test quality and coverage reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-tests-minitest in repos that test with minitest. Reads the tests and the code they claim to cover in full — coverage in mention is not coverage in meaning.

hoblin/claude-ruby-marketplace · 67 tokens

review-tests-rspec

RSpec test quality and coverage reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-tests-rspec in repos that test with RSpec. Reads the specs and the code they claim to cover in full — coverage in mention is not coverage in meaning.

hoblin/claude-ruby-marketplace · 65 tokens

coverage-check

Read-only agent that checks whether changed production files have corresponding test coverage.

greglas75/zuvo · 17 tokens

tester

Use when designing or generating tests for new code, fixes, or refactors. Dispatched primarily by the test-first skill. Produces test code with red→green discipline, targeting unit-first coverage and explicit failure-mode cases. Pastes runner output as evidence. Context: A new endpoint is being added. user: "Add tests…

duthaho/claudekit · 167 tokens

gsd-verifier

Verifies phase goal achievement through goal-backward analysis. Checks codebase delivers what phase promised, not just that tasks completed. Creates VERIFICATION.md report.

travisjneuman/.claude · 36 tokens