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.
npx agentmods add agents/mehrad-dm/mastermind/refactorergit clone --depth 1 https://github.com/mehrad-dm/mastermindWrote 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.
[](https://agentmods.dev/agents/mehrad-dm/mastermind/refactorer)<a href="https://agentmods.dev/agents/mehrad-dm/mastermind/refactorer"><img src="https://agentmods.dev/badge/agents/mehrad-dm/mastermind/refactorer.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00086 | $0.00875 |
| Opus 5 | $0.00043 | $0.00438 |
| Sonnet 5 | $0.00017 | $0.00175 |
| Haiku 4.5 | $0.00009 | $0.00088 |
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.
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, 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".
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.
- 4d ago First seen · 56 lines · 0 tokens per session scan A 59412a987537
refactorer is an agent published in the GitHub repository mehrad-dm/mastermind (24 stars, last pushed 4d ago), licensed MIT. It adds 86 tokens to every session and 875 once invoked, about $0.0004 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-30.
Other agents, from other repositories
code-reviewer
Reviews code for project guideline compliance, bugs, and quality issues. Use after writing code, before commits, or before PRs. Specify files to review or defaults to unstaged git changes. High-confidence issues only (80+) to minimize noise.
codebase-analyst
Use proactively to understand HOW code works. Analyzes implementation details, traces data flow, and documents technical workings with precise file:line references. The more specific your request, the better the analysis.
plan-creator
Use this agent to create comprehensive strategic plan documents combining business strategy and technical architecture. Specializes in context gathering, YAGNI enforcement, and producing actionable blueprints with visual communication.
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.
kodelyth-advisor
Master engineering advisor — Kodelyth. A decade-seasoned principal engineer who has architected systems at $300B-scale companies. Reads between the lines, feels what the user is struggling with, and gives precise, senior-grade direction instantly. No hand-holding, no noise — just the exact answer. Use when you need…
incident-commander
Production incident response specialist — Kodelyth. A decade-seasoned SRE who has led incident response at $300B-scale companies. Runs the triage, containment, communication, and postmortem for active production incidents. Stays calm when everything is on fire. Knows exactly what to do, in what order, and who to tell.…