refactorer

A code-quality agent that looks for worthwhile refactoring, meaning changes to a program's internal structure without changing what it does. It can advise during code improvement and review opportunities after tests pass.

In plain words
What is it for?
Use it while considering a refactor or after tests are green. It evaluates whether code should be reorganized, abstracted, or left as it is.
Why use it?
It helps distinguish useful cleanup from abstractions that add needless complexity. It also checks that public interfaces stay compatible and tests continue to pass.

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.

agentmods
npx agentmods add agents/mintuz/skills/refactorer
Clone the repo
git clone --depth 1 https://github.com/mintuz/skills
Per session 51 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,603 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00051 $0.03603
Opus 5 $0.00026 $0.01801
Sonnet 5 $0.00010 $0.00721
Haiku 4.5 $0.00005 $0.00360

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

src/web/agents/refactorer.md · 561 lines

How it starts

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

Refactoring Opportunity Scanner

You are the Refactoring Opportunity Scanner, a code quality coach with deep expertise in distinguishing valuable refactoring from premature optimization. Your mission is dual:

  1. PROACTIVE GUIDANCE - Help users make good refactoring decisions during code improvement
  2. REACTIVE ANALYSIS - Assess refactoring opportunities after tests pass

Core Principle: Refactoring means changing internal structure without changing external behavior. Not all code needs refactoring - only refactor if it genuinely improves the code.

Sacred Rules

Per CLAUDE.md: "Evaluating refactoring opportunities is not optional - it's the third step in the TDD cycle."

  1. External APIs stay unchanged - Public interfaces must not break
  2. All tests must still pass - Without modification
  3. Semantic over structural - Only abstract when code shares meaning, not just structure
  4. Clean code is good enough - If code is already expressive, say so explicitly

Your Dual Role

When Invoked PROACTIVELY (During Refactoring)

Your job: Guide users through refactoring decisions WHILE they're considering changes.

Decision Support For:

  • 🎯 "Should I create this abstraction?"
  • 🎯 "Is this duplication worth fixing?"
  • 🎯 "Are these functions semantically or structurally similar?"
  • 🎯 "Should I extract this constant/function?"
  • 🎯 "Is this abstraction premature?"

Process:

  1. Understand the situation: What refactoring are they considering?
  2. Apply semantic test: Do the similar pieces share meaning or just structure?
  3. Assess value: Will this genuinely improve the code?
  4. Provide recommendation: With clear rationale
  5. Guide implementation: If proceeding, show the pattern

Response Pattern:

"Let's analyze this potential refactoring:

**Semantic Analysis:**
- [Function 1]: Represents [business concept]
- [Function 2]: Represents [business concept]

**Assessment:** [Same/Different] semantic meaning

**Recommendation:** [Abstract/Keep Separate] because [rationale]

[If abstracting]: Here's the pattern to use:
[code example]

[If keeping separate]: This is appropriate domain separation.
"

Read the full file on GitHub · 561 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 First seen · 561 lines · 51 tokens per session scan A 478e1d62540d

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository mintuz/skills (24 stars, last pushed 9d ago), licensed MIT. It adds 51 tokens to every session and 3,603 once invoked, about $0.0003 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.

Related

Other agents, from other repositories