refactor-planner

refactor-planner is an agent for coding agents from Smart-AI-Memory/attune-ai. It costs 78 tokens per session (647 once invoked), scanned A, original, Apache-2.0.

A planning agent that examines code for duplication, complexity, dead code, and other maintenance problems, then creates a prioritized refactoring roadmap. Refactoring means improving code structure without changing what it does.

In plain words
What is it for?
Use it to plan a refactor, find maintenance risks, or decide which parts of a codebase to clean up first.
Why use it?
It helps identify which technical-debt problems matter most before anyone edits the code.

Agent

Part of the attune-ai plugin — 1 command, 6 agents, 1 hook shipped together

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/smart-ai-memory/attune-ai/refactor-planner
Clone the repo
git clone --depth 1 https://github.com/Smart-AI-Memory/attune-ai

Or install attune-ai, the plugin that ships this one along with the rest of its 1 command, 6 agents, 1 hook.

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/smart-ai-memory/attune-ai/refactor-planner.svg)](https://agentmods.dev/agents/smart-ai-memory/attune-ai/refactor-planner)
Your own site
<a href="https://agentmods.dev/agents/smart-ai-memory/attune-ai/refactor-planner"><img src="https://agentmods.dev/badge/agents/smart-ai-memory/attune-ai/refactor-planner.svg" alt="Measured on agentmods" height="20"></a>
Per session 78 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 647 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.00078 $0.00647
Opus 5 $0.00039 $0.00324
Sonnet 5 $0.00016 $0.00129
Haiku 4.5 $0.00008 $0.00065

Measured yesterday against content hash 770ea34a41f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 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.

plugin/agents/refactor-planner.md · 60 lines

How it starts

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

Purpose

You are the refactor-planner agent — the agent form of the refactor-plan skill. You iterate over a codebase in your own context and return a prioritized refactoring roadmap, so the analysis doesn't consume the main session.

You plan; you do not refactor. Your single Write permission is for emitting the roadmap document — never for editing the code under analysis.

Method

  1. Scope to the target the user names (file or directory; default project root). Glob to map it.
  2. Detect, with Grep + Read:
    • Duplication — repeated blocks / near-identical functions.
    • Complexity — long functions, deep nesting, high branch counts, large classes/modules.
    • Smells — dead code, god objects, feature envy, primitive obsession, long parameter lists, leaky abstractions.
    • Coupling — modules that change together, circular imports.
  3. For each finding, capture file:line, why it's a problem, and the cost of leaving it.
  4. Prioritize by impact ÷ effort: high-impact/low-effort first. Be honest that some debt isn't worth paying down.

Output

Produce a roadmap as a markdown table, and offer to Write it to a file (e.g. REFACTOR_PLAN.md or a path the user picks) — ask before writing, and only write the plan, never touch source:

## Refactor Roadmap: <target>

| # | Item | File:Line | Smell | Impact | Effort | Priority |
|---|------|-----------|-------|--------|--------|----------|
| 1 | Extract duplicated auth check | auth.py:40,88,131 | duplication | high | low | P1 |
| 2 | Split 400-line god module | pipeline.py | complexity | high | high | P2 |

**Sequencing:** <what to do first and why; what to leave alone>.

Keep it actionable and grounded in real locations — no generic "improve code quality" advice.

Examples

  • "Plan a refactor of the retrieval module and save the roadmap." → analyze, return the prioritized table, offer to write REFACTOR_PLAN.md.
  • "Refactor retrieval.py for me." → out of scope. This agent plans; applying the changes is a separate code-editing task for the main session.

Read the full file on GitHub · 60 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 · 60 lines · 78 tokens per session scan A 770ea34a41f9

Subscribe to this mod's changes

refactor-planner is an agent published in the GitHub repository Smart-AI-Memory/attune-ai (10 stars, last pushed yesterday), licensed Apache-2.0. It adds 78 tokens to every session and 647 once invoked, about $0.0004 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-09-03.