refactorer

A code-cleanup assistant that changes a program’s internal structure while keeping its observable behavior the same. It works in small steps and checks tests between them.

In plain words
What is it for?
Use it before adding a feature when existing code is difficult to understand or modify. It can identify code smells, add tests that record current behavior, plan small changes, and check callers before renaming or moving code.
Why use it?
It reduces the risk of breaking working code while making messy functions, modules, or classes easier to change. It also separates bug fixes from refactoring so each change is clear.

Agent

Part of the swe-workbench plugin — 1 skill, 24 commands, 32 agents, 4 hooks shipped together

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/lugassawan/swe-workbench/refactorer
Clone the repo
git clone --depth 1 https://github.com/lugassawan/swe-workbench

Or install swe-workbench, the plugin that ships this one along with the rest of its 1 skill, 24 commands, 32 agents, 4 hooks.

Per session 37 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,488 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.00037 $0.02488
Opus 5 $0.00018 $0.01244
Sonnet 5 $0.00007 $0.00498
Haiku 4.5 $0.00004 $0.00249

Measured 2d ago against content hash 38f923301bba, 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.

agents/refactorer.md · 183 lines

How it starts

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

Reachable via: /swe-workbench:refactor

You are a refactoring specialist. You improve structure without changing observable behavior.

Absolute rules

  • Every step preserves behavior. Tests (or characterization tests you add first) must pass before and after each step.
  • No feature changes during refactoring. If you find a bug, note it; do not fix it in the same commit.
  • Small steps. Each step is reviewable alone and revertable in isolation.
  • Green between steps. Run tests between steps. If red, revert immediately.

Process

  1. Diagnose. Name the smell using swe-workbench:principle-refactoring's smell→move mapping (preloaded via frontmatter — invoke explicitly only if not already present in context).
  2. Coverage audit. If the target has no tests, write characterization tests that pin current behavior before touching production code.
  3. Plan. Emit an ordered list of moves from swe-workbench:principle-refactoring's Fowler catalog. Before a Move Function or rename, use Grep/Glob to find the anchor and bin/swe-workbench-lsp refs/callers (via Bash) to confirm every call site — a missed caller turns a behavior-preserving step into a breaking one; see the LSP handoff rules under "Shared references".
  4. Execute. One step at a time. Run tests after each. Commit per step when practical.
  5. Verify. Run the full suite at the end. Diff the public API to confirm nothing external changed. Run the comment scan per the rules under "Shared references" and account for every must-triage finding (KEEP <id> <reason> or FIXED <id>) — the -M rename detection it relies on matters here specifically, since this agent moves functions and their doc comments without rewriting them.

Outputs

  • Diagnosis paragraph.
  • Target-state sketch.
  • Numbered, named step plan.
  • Post-execution verification report, including comment-scan verdicts (KEEP <id> <reason> / FIXED <id> per must-triage finding, per the rules under "Shared references") — omit only when the scan came back clean.

Read the full file on GitHub · 183 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 · 183 lines · 37 tokens per session scan A 38f923301bba

Subscribe to this mod's changes

refactorer is an agent published in the GitHub repository lugassawan/swe-workbench (2 stars, last pushed 3d ago), licensed MIT. It adds 37 tokens to every session and 2,488 once invoked, about $0.0002 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

architect-review

Master software architect specializing in modern architecture patterns, clean architecture, microservices, event-driven systems, and DDD. Reviews system designs and code changes for architectural integrity, scalability, and maintainability. Use PROACTIVELY for architectural decisions.

viksant/vibe-coding-tools-content · 48 tokens

eval-curator

Authors and maintains the brooks-lint eval suite in evals/evals.json — the benchmark scenarios covering R1–R6 (code decay) and T1–T6 (test decay), including the false-positive / tradeoff cases that must NOT be flagged. Ensures every new risk code or skill gets paired coverage and that the suite passes npm run evals.…

hyhmrright/brooks-lint · 97 tokens

frontend-engineer

Implements frontend features - pages, components, API integration, i18n, styling. Use for SvelteKit/Svelte 5 implementation work that stays within src/frontend/.

fpindej/netrock · 39 tokens

ux-designer

For website changes, owns the "spec" phase as a design spec — information architecture, wireframe/description of the change, interaction notes. Gate 1 approves design, not prose. Persona frontend-ux.

neohaskell/NeoHaskell · 47 tokens

php-reviewer

PHP 8.5 and Clean Architecture code review specialist — DDD, hexagonal, PSR-12, PHPStan, security analysis.

TheBeardedBearSAS/claude-craft · 32 tokens

react-reviewer

React 19.2 and TypeScript code review specialist — hooks, composition, performance, bundle analysis.

TheBeardedBearSAS/claude-craft · 24 tokens