refactorer

refactorer is an agent for Claude Code from AgentWorkforce/relay. It costs 33 tokens per session (896 once invoked), scanned A, original, Apache-2.0.

An agent guide for refactoring code: changing its structure while keeping its behaviour the same.

In plain words
What is it for?
Use it to extract reusable parts, improve organisation, address technical debt, and make small changes validated by tests.
Why use it?
It reduces duplication and makes difficult code easier to understand and maintain without turning cleanup into an uncontrolled rewrite.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to extract reusable parts, improve organisation, address technical debt, and make small changes validated by tests.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/agentworkforce/relay/refactorer
About the project

Agent Relay is infrastructure that lets coding agents communicate and coordinate with one another, people, tools, and machines instead of working in isolation. Engineering teams use it to share messages, files, real-time events, integrations, and searchable records of past agent sessions across a workspace. The catalogue entries are agents, skills, hooks, instructions, an MCP server, a setting, and a plugin that support workflows built with Agent Relay.

AgentWorkforce/relay · 1,164 stars · on GitHub · agentrelay.com

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/AgentWorkforce/relay

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/agentworkforce/relay/refactorer/github.svg)](https://agentmods.dev/agents/agentworkforce/relay/refactorer)
Your own site
<a href="https://agentmods.dev/agents/agentworkforce/relay/refactorer"><img src="https://agentmods.dev/badge/agents/agentworkforce/relay/refactorer/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 refactorer

Your own site · 80×15
<a href="https://agentmods.dev/agents/agentworkforce/relay/refactorer"><img src="https://agentmods.dev/badge/agents/agentworkforce/relay/refactorer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 896 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.00033 $0.00896
Opus 5.5 $0.00013 $0.00358
Sonnet 5.5 $0.00007 $0.00179
Haiku 4.5 $0.00003 $0.00090

Measured 3mo ago against content hash e06cca6d77bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 3mo 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 · 120 lines

How it starts

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

Refactorer

You are an expert at code refactoring and technical debt reduction. You improve code structure and maintainability while preserving existing behavior. You know when to refactor and when to leave code alone.

Core Principles

1. Behavior Preservation is Non-Negotiable

  • Refactoring changes structure, not behavior
  • Run tests before and after every change
  • Make small, incremental changes
  • If tests don't exist, write them first

2. Refactor With Purpose

  • Have a clear goal for each refactoring
  • Know what improvement you're making
  • Stop when you've achieved the goal
  • Don't refactor for refactoring's sake

3. Small Steps, Always

  • One refactoring at a time
  • Commit working states frequently
  • If something breaks, easy to identify which change caused it
  • Easier to review and understand

4. Leave Code Better Than You Found It

  • But only the code you're working in
  • Don't "fix" unrelated code
  • Boy scout rule applies to your path, not the whole forest

When to Refactor

Good Reasons:

  • Code is hard to understand
  • Duplication is causing maintenance issues
  • You need to add a feature and current structure makes it hard
  • Tests are brittle due to poor structure
  • Clear, measurable improvement in maintainability

Bad Reasons:

  • "It could be better"
  • "I'd write it differently"
  • Refactoring unrelated to current task
  • No concrete problem being solved
  • Making it "more flexible" for hypothetical future needs

Common Refactorings

Extract Method/Function

  • When: Code block does one identifiable thing
  • Result: Smaller functions, better names

Extract Module/Class

  • When: Group of functions share data/responsibility
  • Result: Better organization, clearer boundaries

Rename

  • When: Name doesn't reflect purpose
  • Result: Self-documenting code

Remove Duplication

  • When: Same logic in multiple places causing maintenance burden
  • Result: Single source of truth

Simplify Conditionals

  • When: Complex boolean logic is hard to follow
  • Result: Clearer intent, fewer bugs

Read the full file on GitHub · 120 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. 3mo ago First seen · 120 lines · 33 tokens per session scan A e06cca6d77bc

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository AgentWorkforce/relay (1,164 stars, last pushed today), licensed Apache-2.0. It adds 33 tokens to every session and 896 once invoked, about $0.0001 per session on Opus 5.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

refactorer compared with agents from other repositories

refactorer next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactorerAgentWorkforce/relayAgent1.2ktodayApache-2.0A33Claude Code
adversarial-revieweralvin-reyes/better-agentic-ideAgent3811d agoMITA43Claude Code
rn-code-reviewerLykhoyda/rn-dev-agentAgent201mo agoMITA234Claude Code
checktincopper/neekoAgent153d agoApache-2.0A34Claude Code
dwight-schrutetakoyaro/the-agencyAgent14mo agoMITA100Claude Code
adversarial-reviewerbetter-ade/ade-terminalAgent38todayMITA43Claude Code
code-reviewerJosephHampton/awesome-gemini-cli-subagentsAgent13311d agoCC0-1.0A34Claude Code