claude-scaffold: Agent for Claude Code

.claude/agents/refactor-planner.md

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.

This is pyramidheadshark/claude-scaffold's own configuration. It tells Claude Code how to work on claude-scaffold itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-scaffold configures →

Reuse

Borrowing it

Nothing to install: this file belongs to pyramidheadshark/claude-scaffold. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/pyramidheadshark/claude-scaffold/main/.claude/agents/refactor-planner.md
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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor-planner

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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. 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.00021 $0.00518
Opus 5.5 $0.00008 $0.00207
Sonnet 5.5 $0.00004 $0.00104
Haiku 4.5 $0.00002 $0.00052

Measured 1mo ago against content hash 09ee04065be6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 5mo ago), licensed MIT. It adds 21 tokens to every session and 518 once invoked, about $0.0001 per session on Opus 5.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.