refactor-planner

refactor-planner is an agent for Claude Code from pyramidheadshark/claude-scaffold. It costs 21 tokens per session (518 once invoked), scanned A, original, MIT.

An agent that plans and carries out refactoring toward Hexagonal Architecture, stronger type safety, and test coverage.

In plain words
What is it for?
Auditing existing code, mapping dependencies, producing a refactoring plan, and applying the planned changes.
Why use it?
It helps organise code that has grown inconsistently and identifies dependencies before changes are made.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter; mentions 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/pyramidheadshark/claude-scaffold/refactor-planner
Clone the repo
git clone --depth 1 https://github.com/pyramidheadshark/claude-scaffold

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/pyramidheadshark/claude-scaffold/refactor-planner.svg)](https://agentmods.dev/agents/pyramidheadshark/claude-scaffold/refactor-planner)
Your own site
<a href="https://agentmods.dev/agents/pyramidheadshark/claude-scaffold/refactor-planner"><img src="https://agentmods.dev/badge/agents/pyramidheadshark/claude-scaffold/refactor-planner.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 518 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.00021 $0.00518
Opus 5 $0.00010 $0.00259
Sonnet 5 $0.00004 $0.00104
Haiku 4.5 $0.00002 $0.00052

Measured 6d ago against content hash 09ee04065be6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d 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 · 74 lines

How it starts

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

Agent: refactor-planner

Purpose

Plans and executes refactoring of existing code to align it with project standards (Hexagonal Architecture, type safety, test coverage). Produces a step-by-step refactoring plan before touching any code.

When to Use

When inheriting or onboarding existing code that does not follow standards. When a section of the codebase has grown organically and needs alignment. Never during active feature development — refactoring is a separate concern.

Workflow

Step 1: Audit

Map the existing code structure. Identify:

  • Business logic leaking into API layer
  • Missing type hints
  • Missing tests
  • Direct instantiation instead of dependency injection
  • Hardcoded configuration
  • Framework imports in domain layer

Step 2: Dependency Graph

Before moving any code, understand what depends on what. Changing a function used in 20 places requires a different strategy than changing one used in 2.

Step 3: Produce Refactoring Plan

## Refactoring Plan: {module/area}

### Goal
{What the code should look like after refactoring}

### Step 1: {name} — {estimated effort}
- Move `{function}` from `{file}` to `{target}`
- Update imports in: {list of files}
- Tests to add: {list}

### Step 2: {name} — {estimated effort}
...

### Risks
- {risk}: {mitigation}

### Definition of Done
- [ ] All existing tests pass
- [ ] New tests cover extracted logic
- [ ] mypy strict passes
- [ ] No regressions in behaviour

Step 4: Execute Incrementally

Execute one step at a time. After each step:

  • Run uv run pytest
  • Run uv run mypy src/
  • Commit with refactor: {step description}

Never mix refactoring commits with feature commits.

Instructions for Claude Code

  1. Do not start moving code until the plan is written and confirmed by the developer
  2. Keep each refactoring step small enough to be a single commit
  3. Preserve all existing test behaviour — refactoring must not change observable behaviour
  4. When adding missing tests as part of refactoring, add them BEFORE moving the code
  5. Update dev/status.md with each completed step

Read the full file on GitHub · 74 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. 6d ago First seen · 74 lines · 21 tokens per session scan A 09ee04065be6

Subscribe to this mod's changes

refactor-planner is an agent published in the GitHub repository pyramidheadshark/claude-scaffold (4 stars, last pushed 4mo ago), licensed MIT. It adds 21 tokens to every session and 518 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

architecture-reviewer

Architecture and design review agent — read-only. Evaluates structural decisions, identifies design smells, and flags risks before implementation. Never modifies code. Use before merging architectural changes or after a planner produces a plan.

FlorianBruniaux/claude-code-plugins · 45 tokens

planner

Strategic planning agent — read-only exploration before implementation. Use to decompose tasks, analyze codebases, and produce a detailed plan. Never modifies files.

FlorianBruniaux/claude-code-plugins · 33 tokens

planning-coordinator

Synthesis agent for dynamic research teams — read-only. Receives reports from all specialist research agents and produces a coherent, non-redundant implementation plan. Spawned automatically when 2+ agents are selected in /plan-start Phase 4.

FlorianBruniaux/claude-code-plugins · 54 tokens

pr-fix

Analyze one or more failing CI jobs on a GitHub PR (using logs already collected) and fix them - edit sources, validate locally, commit and push. Use after pr-watch reports failures. Returns a request for the user when it cannot fix cleanly.

hardisgroupcom/sfdx-hardis · 56 tokens

onboarding-sherpa

Codebase guide - makes new projects understandable within minutes.

fatihkan/badi · 16 tokens

requirements-reviewer

Reviews a draft requirements.md against the conversation history and glean scratch files. Detects coverage gaps (missing user-stated requirements), hallucinations (ACs without conversational source), and quality issues (EARS structure, CONFIRMED/ASSUMPTION labels, scope clarity, Out of Scope adequacy). Triggered…

iroha924/mumei · 99 tokens