refactoring-expert

refactoring-expert is an agent for Claude Code from nortonx/ai-tooling-free. It costs 20 tokens per session (633 once invoked), scanned A, original, MIT.

A code-refactoring guide for improving existing code while keeping its behavior unchanged. Refactoring means restructuring code to make it clearer and easier to maintain.

In plain words
What is it for?
Finding duplication, long functions, deep nesting, unclear names, and tightly connected code; adding characterization tests when needed; and applying behavior-preserving improvements.
Why use it?
It provides a cautious process for changing legacy code, including checking callers, establishing a passing test baseline, and verifying changes as you go.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md). Also seen: model in frontmatter; mentions CLAUDE.md.

Good fit Finding duplication, long functions, deep nesting, unclear names, and tightly connected code; adding characterization tests when needed; and applying behavior-preserving improvements.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/nortonx/ai-tooling-free/refactoring-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/nortonx/ai-tooling-free

Made for: Claude Code.

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/nortonx/ai-tooling-free/refactoring-expert.svg)](https://agentmods.dev/agents/nortonx/ai-tooling-free/refactoring-expert)
Your own site
<a href="https://agentmods.dev/agents/nortonx/ai-tooling-free/refactoring-expert"><img src="https://agentmods.dev/badge/agents/nortonx/ai-tooling-free/refactoring-expert.svg" alt="Measured on agentmods" height="20"></a>
Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 633 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.00020 $0.00633
Opus 5 $0.00010 $0.00316
Sonnet 5 $0.00004 $0.00127
Haiku 4.5 $0.00002 $0.00063

Measured 8d ago against content hash 28caa86d5910, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

refactoring-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 8d 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/refactoring-expert.md · 61 lines

How it starts

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

Refactoring Expert — Behavior-Preserving Improvements

First Steps

  1. Read CLAUDE.md (if present) for code style, conventions, and linting rules
  2. Run the test suite first — you need a green baseline before any refactoring
  3. Grep for the code you're about to change. Understand all callers and dependencies before moving things

Refactoring Workflow

  1. Assess — Read the code. Identify the specific smell: duplication, long method, deep nesting, unclear naming, tight coupling
  2. Scope — Define the boundary. What files will change? What won't? Declare it upfront
  3. Test — Verify existing coverage. If the code has no tests, write characterization tests first
  4. Refactor — Apply one refactoring at a time. Each step should pass tests independently
  5. Verify — Run the full test suite after each change. If anything breaks, revert and investigate

Refactoring Priorities (by impact)

  1. Extract — Break long functions (>30 lines) into named, testable pieces
  2. Rename — Names should describe intent, not implementation (processDatavalidateAndStoreOrder)
  3. Simplify — Reduce nesting (early returns, guard clauses). Flatten complex conditionals
  4. Consolidate — Eliminate duplication only when the duplicated code changes together. Not all repetition is bad
  5. Decouple — Reduce dependencies between modules. Inject rather than import directly

Output Format

## Refactoring Summary
[What was improved and why]

## Changes
- `file:lines` — [what changed and the specific smell it addresses]

## Test Results
[Full suite output showing no regressions]

Rule of Three Examples

WAIT — 2 occurrences, coincidental similarity Upload validates size in upload.ts:42; PDF parse validates size in pdf.ts:88. Both check bytes but limits and error shapes differ. Two is coincidence — leave duplicated, revisit when a third appears.

EXTRACT — 3+ occurrences with shared intent Three endpoints (users.ts, orders.ts, reports.ts) encode pagination cursors identically. Extract encodeCursor(offset, limit) — all three will change together when the cursor format evolves.

Read the full file on GitHub · 61 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. 8d ago First seen · 61 lines · 20 tokens per session scan A 28caa86d5910

Subscribe to this mod's changes

refactoring-expert is an agent published in the GitHub repository nortonx/ai-tooling-free (1 stars, last pushed 23d ago), licensed MIT. It adds 20 tokens to every session and 633 once invoked, about $0.0001 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

code-reviewer

Code review specialist for identifying bugs, security vulnerabilities, and code quality issues. Use when reviewing pull requests, auditing code changes, or checking adherence to coding standards. For example: PR review, security audit of new code, or style guide enforcement. Context: User wants a code review before…

josstei/maestro-orchestrate · 207 tokens

code_reviewer

Code review specialist for identifying bugs, security vulnerabilities, and code quality issues. Use when reviewing pull requests, auditing code changes, or checking adherence to coding standards. For example: PR review, security audit of new code, or style guide enforcement.

josstei/maestro-orchestrate · 53 tokens

refactor-cleaner

Dead code removal, code cleanup, and safe modernization without behavioral changes.

drvoss/everything-copilot-cli · 18 tokens

code-reviewer

Code quality, maintainability, and best practices review with high signal-to-noise ratio.

drvoss/everything-copilot-cli · 21 tokens

go-observability-reviewer

Go observability reviewer covering structured logging gaps, broken trace context propagation, Prometheus cardinality explosions, span lifecycle errors (missing defer span.End(), unrecorded errors), and sensitive fields in logs. Use when Go code changes import go.uber.org/zap, log/slog, go.opentelemetry.io…

johnqtcg/awesome-skills · 119 tokens

go-concurrency-reviewer

Go concurrency safety reviewer covering race conditions, deadlocks, goroutine leaks, mutex misuse, channel lifecycle, context propagation, and graceful shutdown. Use when Go code changes contain go func, channels, sync primitives (Mutex, RWMutex, WaitGroup), errgroup, singleflight, select statements, or context…

johnqtcg/awesome-skills · 85 tokens