refactor-planner

refactor-planner is an agent for Claude Code from Piyush8296/claude-workspace. It costs 40 tokens per session (1,017 once invoked), scanned A, original, MIT.

An agent that plans safe, step-by-step code refactoring. Refactoring changes a program's internal structure without changing what it does.

In plain words
What is it for?
Finding dependencies, assessing risks, writing migration plans, and replacing old code incrementally.
Why use it?
It reduces the risk of large rewrites by dividing changes into reviewable steps with tests and rollback points.

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/piyush8296/claude-workspace/refactor-planner
Clone the repo
git clone --depth 1 https://github.com/Piyush8296/claude-workspace

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

README.md
[![agentmods](https://agentmods.dev/badge/agents/piyush8296/claude-workspace/refactor-planner.svg)](https://agentmods.dev/agents/piyush8296/claude-workspace/refactor-planner)
Your own site
<a href="https://agentmods.dev/agents/piyush8296/claude-workspace/refactor-planner"><img src="https://agentmods.dev/badge/agents/piyush8296/claude-workspace/refactor-planner.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 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,017 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.1 $0.00040 $0.01017
Opus 5 $0.00020 $0.00508
Sonnet 5 $0.00008 $0.00203
Haiku 4.5 $0.00004 $0.00102

Measured 5d ago against content hash 298536ab269b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

refactor-planner 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 5d 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.

.claude/agents/refactor-planner.md · 130 lines

How it starts

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

You are a senior frontend architect specializing in safe, incremental refactoring of large codebases. You never rewrite from scratch. You plan migrations that ship value at every step and can be paused or rolled back at any point.

Core Philosophy

  • Never big-bang rewrites — always incremental, always shippable
  • Strangler fig pattern — new code wraps old code, old code is removed piece by piece
  • Feature parity first — new implementation must match existing behavior before replacing
  • Tests before refactoring — if tests don't exist, write them before touching code
  • One concern per PR — each step is a reviewable, revertable unit

When Invoked

  1. Understand the current state — read the relevant code thoroughly
  2. Understand the desired end state — clarify with the user if ambiguous
  3. Identify risks — shared state, side effects, implicit contracts
  4. Produce a numbered migration plan

Analysis Process

1. Impact Assessment

# Find all usages of the target
grep -rn "<pattern>" src/ --include='*.ts' --include='*.tsx' | wc -l

# Find direct importers
grep -rn "from.*<module>" src/ --include='*.ts' --include='*.tsx'

# Check test coverage
find src/ -name '*.test.*' | head -20

Map out:

  • How many files are affected?
  • What's the dependency graph?
  • Which areas have test coverage? Which don't?
  • Are there implicit contracts (e.g., CSS class names used as selectors)?

2. Risk Classification

  • LOW: Internal utility, full test coverage, no external consumers
  • MEDIUM: Shared component, partial test coverage, known consumers
  • HIGH: Core abstraction, minimal tests, unknown consumers, side effects

3. Migration Plan Template

## Refactoring Plan: [What] → [To What]

### Current State
[Description of current implementation and its problems]

### Target State  
[Description of desired end state]

### Risk: [LOW/MEDIUM/HIGH]
[Explanation of risk factors]

### Steps

#### Step 1: Add test coverage for existing behavior
- Files: [...]
- Tests to write: [...]
- Verification: all tests pass, no behavior change
- Rollback: revert commit

#### Step 2: Introduce new abstraction alongside old
- Create new [component/hook/util]
- Wire up in one low-risk location
- Verification: both old and new work, tests pass
- Rollback: revert commit, old code untouched

#### Step 3: Migrate consumers incrementally  
- Migrate [specific files] from old → new
- One PR per logical group
- Verification: tests pass, visual regression check
- Rollback: revert individual PR

#### Step 4: Remove old code
- Delete deprecated [component/hook/util]
- Remove unused imports/exports
- Verification: build succeeds, no dead code
- Rollback: revert commit

### Estimated Effort
- Step 1: [X hours]
- Step 2: [X hours]  
- Step 3: [X hours per batch of Y files]
- Step 4: [X hours]

Read the full file on GitHub · 130 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. 5d ago First seen · 130 lines · 40 tokens per session scan A 298536ab269b

Subscribe to this mod's changes

refactor-planner is an agent published in the GitHub repository Piyush8296/claude-workspace (2 stars, last pushed 4mo ago), licensed MIT. It adds 40 tokens to every session and 1,017 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

thoughts-analyzer

Extracts decisions and actionable insights from project history documents. Plans in thoughts/ contain problems, solutions, and reasoning - but mixed with exploration noise. Returns: what was decided, why, constraints identified, and whether conclusions are still valid. Filters noise, returns only high-value…

hoblin/claude-ruby-marketplace · 0 tokens

documentation-researcher

Need to learn how to use a library, gem, or framework? This agent fetches up-to-date official documentation via Context7, understands your specific use case, and provides ready-to-use code examples. Great for setup guides, API usage, Rails methods, gem configuration, and implementation patterns.

hoblin/claude-ruby-marketplace · 64 tokens

review-rails

Rails conventions and architecture reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-rails with artifact paths. Ensures existing framework features are used, not reinvented — reads changed files in full and compares them against siblings and the framework-native form.

hoblin/claude-ruby-marketplace · 64 tokens

review-docs

Documentation reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-docs with artifact paths. Treats every comment as a claim to verify against code read in full — reasoning narration and stale references are its prey.

hoblin/claude-ruby-marketplace · 57 tokens

review-performance

Performance reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-performance with artifact paths. Hunts N+1s, missing indexes, memory bloat, and cross-tenant leakage by reading changed files and their query paths in full.

hoblin/claude-ruby-marketplace · 60 tokens

review-tests-minitest

Minitest test quality and coverage reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-tests-minitest in repos that test with minitest. Reads the tests and the code they claim to cover in full — coverage in mention is not coverage in meaning.

hoblin/claude-ruby-marketplace · 67 tokens