refactorer

refactorer is an agent for Claude Code from mehrad-dm/mastermind. It costs 86 tokens per session (888 once invoked), scanned A, original, MIT.

A code-refactoring agent that reorganizes working software while keeping its behavior unchanged. Refactoring means improving the internal design without changing what users see.

In plain words
What is it for?
Use it to split up complex code, improve data structures, separate dependencies, and apply named refactoring patterns while preserving behavior.
Why use it?
It reduces design and architecture problems in code that already works, such as tangled dependencies, oversized modules, and unclear data models.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the mastermind plugin — 32 skills, 4 agents, 1 hook shipped together

Good fit Use it to split up complex code, improve data structures, separate dependencies, and apply named refactoring patterns while preserving behavior.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/mehrad-dm/mastermind/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/mehrad-dm/mastermind

Made for: Claude Code.

Or install mastermind, the plugin that ships this one along with the rest of its 32 skills, 4 agents, 1 hook.

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/mehrad-dm/mastermind/refactorer/github.svg)](https://agentmods.dev/agents/mehrad-dm/mastermind/refactorer)
Your own site
<a href="https://agentmods.dev/agents/mehrad-dm/mastermind/refactorer"><img src="https://agentmods.dev/badge/agents/mehrad-dm/mastermind/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/mehrad-dm/mastermind/refactorer"><img src="https://agentmods.dev/badge/agents/mehrad-dm/mastermind/refactorer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 86 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 888 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.00086 $0.00888
Opus 5.5 $0.00034 $0.00355
Sonnet 5.5 $0.00017 $0.00178
Haiku 4.5 $0.00009 $0.00089

Measured 15d ago against content hash 76bb14072ca8, 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 15d 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 · 56 lines

How it starts

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

You are the MasterMind refactorer. You improve the design of code that already works, without changing what it does. Fowler's discipline: "make the change easy, then make the easy change." This is not a bug hunt (that's code-reviewer) and not surface tidying (that's /simplify); it's structural redesign toward the standard in core/mindset.md and core/principles.md.

Load first

Read ~/.mastermind/engineering/core/principles.md, ~/.mastermind/engineering/core/mindset.md, ~/.mastermind/engineering/core/rigor.md, and the active field's stack-defaults.md.

Reference catalog (field-agnostic)

You have no web tools: work from the vocabulary you already carry, not from a fetch. The canonical catalog is Fowler's refactorings + code smells + the GoF patterns: name the move you're making (extract function · inline · move method · replace conditional with polymorphism · introduce parameter object · replace temp with query) and the smell you're removing (long function · large class · feature envy · shotgun surgery · primitive obsession · data clump). Naming it keeps the change deliberate and reviewable. Use it as vocabulary, not a checklist: a pattern earns its place only if it makes the code simpler: otherwise you've added indirection and called it design.

In React/frontend, prefer composition-first idioms: composition over inheritance, children and slots over configuration flags, hooks for shared behavior, lifting state only as far as it must go. Inheritance-heavy GoF solutions are usually the wrong fit there. The active field's curriculum.md and lessons.md are readable locally and are the field-specific authority; prefer them over recall.

(Human reference, not fetchable from here: refactoring.guru for the catalog, patterns.dev for the frontend patterns.)

Non-negotiable: behavior is preserved

  • Safety net first. Confirm tests cover the target and pass. If a risky area is untested, say so and get a yes before writing characterization tests: a suite is the user's call, not yours (~/.mastermind/engineering/core/rigor.md). If they decline, restrict the refactor to what typecheck, lint and driving the flow can verify, or hand it back as Not done. No way to prove behavior is unchanged → build the proof first; an unverifiable refactor is a rewrite.
  • One at a time: structure or behavior. If you spot a bug mid-refactor, note it and leave it for its own change: a silent fix hides a behavior change inside a "refactor".

Read the full file on GitHub · 56 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. 15d ago Changed · +86 tokens per session 76bb14072ca8
  2. 1mo ago First seen · 56 lines · 0 tokens per session scan A 59412a987537

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository mehrad-dm/mastermind (23 stars, last pushed 6d ago), licensed MIT. It adds 86 tokens to every session and 888 once invoked, about $0.0003 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

Other agents, from other repositories

reviewer

Code review specialist for quality/security analysis.

can1357/oh-my-pi · 10 tokens

security-reviewer

Read-only security specialist for evidence-backed repository vulnerability discovery.

can1357/oh-my-pi · 14 tokens

backdoor-hunter

Adversarial backdoor and malicious-code detector. Use when reviewing third-party code, vendored libraries, contractor PRs, dependency updates, or after any compromise alert. Hunts obfuscated payloads, hidden network beacons, time bombs, and unauthorized eval/exec patterns.

sifxprime/kodelyth-ecc · 60 tokens

code-stealer-detector

Adversarial code-provenance auditor. Use when reviewing PRs, accepting AI-generated code, doing M&A due diligence, or before going open-source. Detects copy-pasted Stack Overflow snippets, copyleft contamination, leaked private code, and AI-generated code with unverified provenance.

sifxprime/kodelyth-ecc · 64 tokens

api-guardian

API contract protector — Kodelyth. A decade-seasoned API architect who has designed and versioned APIs used by millions of developers at $300B-scale platforms. Detects breaking changes before they ship, enforces versioning discipline, validates request/response contracts, and ensures your API never silently breaks a…

sifxprime/kodelyth-ecc · 80 tokens

detective

Use this agent when the user needs comprehensive project analysis, including health checks, technology stack detection, gap analysis, code quality assessment, security scanning, or architectural review. This agent should be invoked for Option 4 (Health Check) or Option 3 (Soundboard) scenarios, during initial project…

nxtg-ai/forge-plugin · 473 tokens