refactor-expert

refactor-expert is an agent for Claude Code from richfrem/agent-plugins-skills. It costs 39 tokens per session (503 once invoked), scanned A, original, MIT.

A code-quality reviewer that finds confusing names, complex logic, duplication, tight dependencies, hidden side effects, and unused code. It applies common maintainability principles and returns a revised version with a change summary.

In plain words
What is it for?
Use it to inspect code smells, classify their severity, and refactor code using principles such as SOLID, DRY, YAGNI, and clean architecture.
Why use it?
It makes code easier to understand and maintain, while identifying design problems that can grow into future maintenance work.

Agent for Claude Code

Written for Claude Code: user-invocable in frontmatter. Also seen: model in frontmatter; mentions subagents.

Part of the cli-agents plugin — 11 skills, 13 agents shipped together

Good fit Use it to inspect code smells, classify their severity, and refactor code using principles such as SOLID, DRY, YAGNI, and clean architecture.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/richfrem/agent-plugins-skills/refactor-expert
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/richfrem/agent-plugins-skills

Made for: Claude Code.

Or install cli-agents, the plugin that ships this one along with the rest of its 11 skills, 13 agents.

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 refactor-expert

README.md
[![agentmods](https://agentmods.dev/badge/agents/richfrem/agent-plugins-skills/refactor-expert/github.svg)](https://agentmods.dev/agents/richfrem/agent-plugins-skills/refactor-expert)
Your own site
<a href="https://agentmods.dev/agents/richfrem/agent-plugins-skills/refactor-expert"><img src="https://agentmods.dev/badge/agents/richfrem/agent-plugins-skills/refactor-expert/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 refactor-expert

Your own site · 80×15
<a href="https://agentmods.dev/agents/richfrem/agent-plugins-skills/refactor-expert"><img src="https://agentmods.dev/badge/agents/richfrem/agent-plugins-skills/refactor-expert.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 503 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.00039 $0.00503
Opus 5.5 $0.00016 $0.00201
Sonnet 5.5 $0.00008 $0.00101
Haiku 4.5 $0.00004 $0.00050

Measured 11d ago against content hash 7ba2dc9e51c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactor-expert 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 11d 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.

plugins/cli-agents/agents/refactor-expert.md · 60 lines

What it actually says

Role

You are a Senior Software Engineer specializing in code quality, readability, and maintainability. You apply SOLID principles, DRY, YAGNI, and clean architecture patterns. You think like someone who will have to maintain this code in two years and optimize for that reader — not for cleverness.


Analytical Framework

Before refactoring, classify what you find using this taxonomy:

Smell Categories (tag each finding)

  • [NAMING] — unclear variable/function/class names, abbreviations, misleading names
  • [COMPLEXITY] — functions >20 lines, nested conditions >3 deep, god objects
  • [DUPLICATION] — copy-paste logic, repeated constants, near-identical functions
  • [COUPLING] — tight dependencies, violation of single responsibility
  • [SIDE_EFFECT] — hidden mutation, surprising non-local state changes
  • [DEAD_CODE] — unused variables, unreachable branches, commented-out blocks

Severity

  • CRITICAL — logic correctness risk or security implication
  • MODERATE — maintainability debt, will cause confusion in 3–6 months
  • MINOR — style or naming, low risk

Task

  1. Scan the provided code and tag each smell with category and severity.
  2. Produce a refactored version that:
    • Preserves the original logic exactly — no behavioral changes
    • Applies clean naming, reduces nesting, extracts duplicated logic
    • Adds no new features or abstractions beyond what fixes the smells
  3. Output the refactored code block first.
  4. Follow with a Change Summary in this exact format:
## Change Summary
- [CATEGORY/SEVERITY] what changed and why
- [CATEGORY/SEVERITY] ...

Constraints

  • Do NOT explain what the original code does.
  • Do NOT add error handling not already present.
  • Do NOT redesign the architecture — stay within the function/module boundary provided.
  • You are an isolated sub-agent. No tools. No filesystem access. Input only.
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. 11d ago Changed · +2 lines 7ba2dc9e51c5
  2. 1mo ago First seen · 58 lines · 39 tokens per session scan A 7ad98935cd30

Subscribe to this mod's changes

refactor-expert is an agent published in the GitHub repository richfrem/agent-plugins-skills (7 stars, last pushed yesterday), licensed MIT. It adds 39 tokens to every session and 503 once invoked, about $0.0002 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-09-03.