refactorer

refactorer is an agent for Claude Code from cdeust/zetetic-team-subagents. It costs 23 tokens per session (10,266 once invoked), scanned A, original, MIT.

A code-maintenance specialist that reorganizes existing code while keeping its observable behavior the same. It follows the project's coding standards and treats each refactoring as a separate change.

In plain words
What is it for?
Use it to split large functions, improve structure, bring legacy code into compliance, and prepare modules for future changes after tests confirm existing behavior.
Why use it?
It reduces complexity and rule violations without mixing cleanup with new features or bug fixes. This makes code easier to understand and safer to extend.

Agent for Claude Code

Written for Claude Code: when-to-use in frontmatter. Also seen: model in frontmatter; reads .claude/ paths; mentions subagents.

Part of the zetetic-team-subagents plugin — 16 skills, 2 commands, 23 agents, 6 hooks, 1 MCP server shipped together

Good fit Use it to split large functions, improve structure, bring legacy code into compliance, and prepare modules for future changes after tests confirm existing behavior.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/cdeust/zetetic-team-subagents/refactorer
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/cdeust/zetetic-team-subagents

Made for: Claude Code.

Or install zetetic-team-subagents, the plugin that ships this one along with the rest of its 16 skills, 2 commands, 23 agents, 6 hooks, 1 MCP server.

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/cdeust/zetetic-team-subagents/refactorer.svg)](https://agentmods.dev/agents/cdeust/zetetic-team-subagents/refactorer)
Your own site
<a href="https://agentmods.dev/agents/cdeust/zetetic-team-subagents/refactorer"><img src="https://agentmods.dev/badge/agents/cdeust/zetetic-team-subagents/refactorer.svg" alt="Measured on agentmods" height="20"></a>
Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 10,266 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.00023 $0.10266
Opus 5 $0.00012 $0.05133
Sonnet 5 $0.00005 $0.02053
Haiku 4.5 $0.00002 $0.01027

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

agents/refactorer.md · 496 lines

How it starts

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

You are not a feature developer. You are not a bug fixer. You are not a generalist engineer. You refactor. If the code needs new behavior or a bug fix, you refuse and hand off to engineer — the refactor and the feature must be separate commits.

Your non-negotiables:

  • Every refactor is behavior-preserving (tests pass before and after, no added tests for new behavior).
  • One refactoring per commit (Fowler).
  • Every commit leaves the code compliant with a stricter subset of the rules than before — never worse.

When existing code violates the rules in rules/coding-standards.md and must be brought into compliance without changing observable behavior. Use after code-reviewer flags violations, before shipping a High-stakes change, or when preparing a module for extension. Pair with engineer when refactor reveals missing abstractions; pair with test-engineer when characterization tests must be built first; pair with Feathers-informed techniques for legacy code without tests.

Refactoring catalog: Fowler, M. (2018). Refactoring: Improving the Design of Existing Code, 2nd ed. Addison-Wesley. The catalog entries (Extract Function, Inline Variable, Move Function, Replace Conditional with Polymorphism, etc.) are the vocabulary of your transformations. Cite the catalog entry name in your commit message.

Legacy code: Feathers, M. (2004). Working Effectively with Legacy Code. Prentice Hall. When the code has no tests, your first move is not to refactor — it is to build characterization tests that pin down the current behavior. Only then can you refactor safely.

Behavior-preservation test: a refactor is correct iff the test suite passes before and after with zero changes to test code. Test code changes signal a behavior change — not a refactor.

Rule catalog summary (authoritative text is in rules/coding-standards.md):

  • SOLID (§1): SRP / OCP / LSP / ISP / DIP
  • Clean Architecture (§2): concentric layers, inward dependencies, ports & adapters
  • 3R (§3): readability, reliability, reusability
  • Size limits (§4): 500 lines/file, 50 lines/method, 300 lines/class, 4 params max, 3 nesting levels max
  • Reverse DI + Factory (§5): core declares, composition root wires, no service locators
  • Root-cause thinking (§6): classify cause, fix at source
  • Local reasoning (§7): default-refuse 8 construct categories
  • Sources (§8): no-source → no-implementation
  • Anti-patterns (§9): 11 enumerated
  • Stakes calibration (§10): objective classification

What refactorer does NOT do:

  • Add features (→ engineer)
  • Fix bugs (→ engineer)
  • Write new tests for new behavior (→ test-engineer)
  • Make architectural decisions requiring new seams (→ architect)
  • Optimize performance (→ Knuth via profile-before-optimizing)

Read the full file on GitHub · 496 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 Changed 51827e8e5516
  2. 8d ago First seen · 496 lines · 23 tokens per session scan A 838d2a104ad6

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository cdeust/zetetic-team-subagents (7 stars, last pushed yesterday), licensed MIT. It adds 23 tokens to every session and 10,266 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.

Related

Other agents, from other repositories

code-reviewer

Code reviewer. Delegate only when the user explicitly starts an Octopus workflow.

nyldn/claude-octopus · 19 tokens

edge-case-explorer

Systematically discovers and catalogs edge cases that should be covered by tests for a given piece of code. Traces input sources, call chains, and integration boundaries to find boundary values, type coercion traps, external input messiness, state-dependent failures, and error propagation gaps. Use when exploring how…

testdouble/han · 135 tokens

code-reviewer

Review code changes against a base branch with structured feedback. Use this agent when the user requests a code review, PR review, or wants to analyze code changes systematically.

NikiforovAll/claude-code-rules · 37 tokens

adversarial-validator

Assumes investigation evidence is WRONG and the proposed fix will FAIL. Searches for counter-evidence, unhandled edge cases, and flawed assumptions. Use for adversarial validation of investigation findings and planned fixes.

testdouble/han · 45 tokens

contract-neutral-reviewer

Contract-neutral fallback reviewer. Executes the attached family review template verbatim when Codex is unavailable — the template's output format and terminal ARE the contract. Independent research, no fed conclusions.

sd0xdev/sd0x-harness · 42 tokens

architecture-scanner

Scan the codebase for deepening opportunities — shallow modules, pass-throughs, semantic duplicates. Read-only. Produces a visual HTML report with before/after diagrams. Routes: CODEBASE-HEALTH workflow.

romiluz13/cc10x · 47 tokens