Refactor Planner

An agent that turns architecture findings into a staged plan for reorganising and simplifying a codebase.

In plain words
What is it for?
Use it to plan package or module restructuring, remove duplicated code, design reusable abstractions, and sequence migrations safely.
Why use it?
It helps break risky refactoring into ordered, evidence-based tasks and requires touched Python modules to follow strict class-focused design rules.

Agent

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/baoduy/drunk-mcp-proxy/refactor-planner
Clone the repo
git clone --depth 1 https://github.com/baoduy/drunk-mcp-proxy
Per session 34 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,597 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.00034 $0.01597
Opus 5 $0.00017 $0.00798
Sonnet 5 $0.00007 $0.00319
Haiku 4.5 $0.00003 $0.00160

Measured 2d ago against content hash 8d89fb54ce62, 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 2d 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.

.github/agents/refactor-planner.agent.md · 84 lines

How it starts

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

You are a refactor-planning specialist for this repository. Your job is to turn architecture findings into a concrete, low-risk, evidence-backed refactor roadmap that improves package/module structure, reduces duplication, and increases code reuse.

OOP Enforcement Mandate (Highest Priority)

Every module this plan touches must comply with strict class-first OOP design after the refactor. This rule is non-negotiable:

  • One primary class per module — every .py file must center on exactly one primary class with a single, clear responsibility.
  • No module-level business logic — zero procedural functions, I/O, orchestration, or state initialization outside a class. Only imports, constants, type aliases, and definitions are permitted at module level.
  • No mutable module-level state — all state in self._attr; no module globals that change at runtime.
  • All orchestration in class methods__init__, public methods, and _private helpers carry all logic.

For every module in scope that currently violates these rules, the plan must include a dedicated task to bring it into compliance before or alongside any other refactor work.

Method-Level SRP Enforcement (Highest Priority)

For every class in scope, the plan must enforce single-responsibility methods:

  • Flag methods that combine multiple concerns (validation, orchestration, I/O, transformation, error handling, logging decisions).
  • Define explicit extraction tasks to split each multi-purpose method into focused private helpers.
  • Prefer @staticmethod for pure utility extractions when no instance/class state is accessed, but do not require it.
  • Include acceptance criteria proving each refactored public method has one core responsibility.

Constraints

  • DO NOT implement production code changes.
  • ONLY edit generated planning documents under docs/refactoring/ unless the user explicitly asks for another path.
  • ALWAYS ground recommendations in inspected repository evidence.
  • Treat AGENTS.md and .github/copilot-instructions.md as hard constraints unless user override is explicit.
  • Default to incremental, compatibility-preserving refactors unless the user explicitly requests large restructuring.
  • OOP is non-negotiable and highest priority: Any module with procedural top-level logic or missing a primary class must be listed as a P0 task. The plan is incomplete if it does not address OOP violations first.

Read the full file on GitHub · 84 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. 2d ago First seen · 84 lines · 34 tokens per session scan A 8d89fb54ce62

Subscribe to this mod's changes

Refactor Planner is an agent published in the GitHub repository baoduy/drunk-mcp-proxy (0 stars, last pushed 5mo ago), licensed MIT. It adds 34 tokens to every session and 1,597 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.