Refactor Planner

Refactor Planner is a skill for Claude Code, Codex from Notysoty/openagentskills. It costs 22 tokens per session (1,534 once invoked), scanned A, original, MIT.

A guide for planning changes to messy code while keeping its existing behaviour. Refactoring means improving code structure without intentionally changing what it does.

In plain words
What is it for?
Use it to assess a function, module, or larger codebase that works but is difficult to maintain. It produces an ordered plan designed to keep tests passing and behaviour unchanged.
Why use it?
It breaks risky rewrites into smaller, reversible steps and identifies dependencies and likely regression points before changes are made.

Skill for Claude CodeCodex

Which agent this was written for is unclear — built for cline. Also seen: mentions Claude Code; mentions Codex; built for cline.

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 skills/notysoty/openagentskills/refactor-planner
Any agent
npx skills add Notysoty/openagentskills --skill refactor-planner
Clone the repo
git clone --depth 1 https://github.com/Notysoty/openagentskills

Made for: Claude Code, Codex.

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/skills/notysoty/openagentskills/refactor-planner.svg)](https://agentmods.dev/skills/notysoty/openagentskills/refactor-planner)
Your own site
<a href="https://agentmods.dev/skills/notysoty/openagentskills/refactor-planner"><img src="https://agentmods.dev/badge/skills/notysoty/openagentskills/refactor-planner.svg" alt="Measured on agentmods" height="20"></a>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,534 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.00022 $0.01534
Opus 5 $0.00011 $0.00767
Sonnet 5 $0.00004 $0.00307
Haiku 4.5 $0.00002 $0.00153

Measured 5d ago against content hash be69ab8fea80, 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.

skills/refactor-planner/SKILL.md · 154 lines

How it starts

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

Refactor Planner

What this skill does

This skill directs the agent to analyze a block of code (or an entire module) and produce an ordered, safe refactoring plan. Rather than rewriting everything at once, it breaks the work into small, reversible steps — each one leaving the tests green and the behavior unchanged. It identifies code smells, maps dependencies, flags high-risk areas, and sequences the changes so you can ship incrementally without introducing regressions.

Use this when you have messy, hard-to-understand code that works but needs cleaning up before you can safely add features.

How to use

Claude Code / Cline

Copy this file to .agents/skills/refactor-planner/SKILL.md in your project root.

Then ask the agent:

  • "Use the Refactor Planner skill on src/utils/dataProcessor.ts."
  • "Plan a safe refactor of this function using the Refactor Planner skill."

Paste in the code you want refactored, or point to a file path.

Cursor

Add the "Prompt / Instructions" section below to your .cursorrules file, or paste it directly into the Cursor AI pane before sharing the code you want refactored.

Codex

Paste the target code into the chat along with the instructions from the section below. For large files, include the full file plus any files that import from it so Codex can map dependencies.

The Prompt / Instructions for the Agent

When asked to plan a refactor, follow these steps precisely:

  1. Read the code thoroughly. If a file path is given, read the full file. Also read any files that import from it or that it imports from, so you understand the dependency graph.

  2. Identify code smells. Look for:

    • Functions longer than 40 lines
    • Deeply nested conditionals (more than 3 levels)
    • Duplicated logic (copy-paste code)
    • Magic numbers and hardcoded strings
    • God objects or functions that do too many things
    • Inconsistent naming conventions
    • Mutable shared state
    • Missing or misleading comments
    • Dead code (unreachable or unused)

Read the full file on GitHub · 154 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 · 154 lines · 22 tokens per session scan A be69ab8fea80

Subscribe to this mod's changes

Refactor Planner is a skill published in the GitHub repository Notysoty/openagentskills (9 stars, last pushed 22d ago), licensed MIT. It adds 22 tokens to every session and 1,534 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 skills, from other repositories

absolute-simplify

Use when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path. Reduces complexity, flattens nesting, removes redundancy and dead code, scores each change by value (holding low-value churn), then runs tests to prove nothing broke. Invoke on…

maddhruv/absolute · 178 tokens

setup-craft-skills

Run once per repository to get the most out of the other craft skills (explain-back, name-things, delete-this, seams, loud-errors, boyscout, why-comments, fit-in). Scaffolds an optional shared CONTEXT.md — domain glossary, language/stack, conventions, and untouchables — that those skills read to match your project's…

mikestangdevs/craft-skills · 139 tokens

explain-back

Use before trusting, merging, or building on top of code you (or an agent) just wrote or are about to change. The agent explains the code back in plain language — what it does, why it exists, what breaks if it's wrong — and refuses to proceed until the mental model is confirmed. Use when a diff looks fine but nobody…

mikestangdevs/craft-skills · 103 tokens

loud-errors

Use when you spot a swallowed, vague, or context-losing error — an empty catch, a bare except: pass, catch (e) { console.log(e) } that then continues, throw new Error("something went wrong"), an error logged then ignored, or a caught exception that drops its cause. Makes failures loud and specific: each error says…

mikestangdevs/craft-skills · 138 tokens

seams

Use when you want to unit-test logic but can't without a database, network, clock, or a pile of mocks — or when a function fetches, computes, branches on policy, and writes all in one breath. Splits the decision (pure logic) from the action (I/O and side effects) along the natural seam, so the logic becomes testable…

mikestangdevs/craft-skills · 137 tokens

boyscout

Use when touching an existing file to make a change, so you leave it slightly cleaner than you found it without derailing into a giant refactor. Identifies small, safe, in-scope improvements adjacent to the change you're already making — a better name, a deleted dead line, an extracted helper, a clarified condition …

mikestangdevs/craft-skills · 107 tokens