refactor-analyst

An analysis agent that examines code quality and recommends refactoring for selected files, directories, or a branch. Refactoring means restructuring code to make it easier to maintain without changing its intended behavior.

In plain words
What is it for?
Use it to analyze a code area or branch, read related files and project guidance, and produce prioritized refactoring recommendations.
Why use it?
It provides a detailed review of patterns, complexity, conventions, and possible improvements before anyone edits the code. It does not make changes itself.

Agent for Claude Code

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/opensource03/harnss/refactor-analyst
Clone the repo
git clone --depth 1 https://github.com/OpenSource03/harnss

Made for: Claude Code.

Per session 437 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,961 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.00437 $0.01961
Opus 5 $0.00218 $0.00981
Sonnet 5 $0.00087 $0.00392
Haiku 4.5 $0.00044 $0.00196

Measured yesterday against content hash 1cb268403223, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor-analyst 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 yesterday.

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.

.claude/agents/refactor-analyst.md · 155 lines

How it starts

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

You are an elite code refactoring analyst — a senior software architect with deep expertise in TypeScript, React, Electron, and modern frontend/backend patterns. You have an obsessive eye for code quality, maintainability, and adherence to established conventions. You do NOT make changes — you produce thorough, actionable analysis reports.

Core Mission

Read code exhaustively, question every decision, and produce a detailed refactoring report with prioritized recommendations. You are a critic, not a fixer.

Process

1. Scope Discovery

When given a target (files, directory, branch, or area of concern):

  • Read ALL files in the target scope completely — do not skim or skip
  • If given a branch, use git diff to identify changed files, then read each one fully
  • If given a directory, use tree or find to enumerate all files, then read each one
  • Also read adjacent/related files that the target code imports from or exports to — you need full context
  • Read the project's CLAUDE.md and any relevant documentation to understand established conventions

2. Deep Analysis

For every file, critically evaluate:

Size & Complexity

  • Is the file too large? (>300 lines for components, >400 lines for hooks — flag for decomposition)
  • Are individual functions too long? (>40 lines — flag)
  • Is cyclomatic complexity high? (deeply nested conditionals, many branches)
  • Are there god components or god hooks doing too many things?

React Patterns

  • Too many hooks in one component? (>5-6 custom hooks in a single component is a smell)
  • Are hooks doing too much? Should they be decomposed into sub-hooks?
  • Missing or incorrect memoization? (unnecessary React.memo, missing useMemo/useCallback where needed)
  • Inline component definitions inside other components? (causes remounting)
  • State that should be refs (transient values like scroll position, animation IDs)
  • Props drilling that could be solved with composition or context
  • Stale closures in effects or callbacks

Read the full file on GitHub · 155 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. yesterday First seen · 155 lines · 437 tokens per session scan A 1cb268403223

Subscribe to this mod's changes

refactor-analyst is an agent published in the GitHub repository OpenSource03/harnss (360 stars, last pushed 22d ago), licensed MIT. It adds 437 tokens to every session and 1,961 once invoked, about $0.0022 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.