refactoring-advisor

A method for planning code refactors—changes to a program's structure without changing what it does—through small, tested steps.

In plain words
What is it for?
Use it to identify code smells, assess affected areas, check test coverage, plan incremental changes, and estimate refactoring effort.
Why use it?
It reduces the risk of breaking behavior during code cleanup, migrations, duplication removal, module splitting, or API changes.

Skill for Claude CodeCodex

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/firstp1ck/pi-coding-agent-forge/refactoring-advisor
Any agent
npx skills add Firstp1ck/pi-coding-agent-forge --skill refactoring-advisor
Clone the repo
git clone --depth 1 https://github.com/Firstp1ck/pi-coding-agent-forge

Made for: Claude Code, Codex.

Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,586 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.00048 $0.01586
Opus 5 $0.00024 $0.00793
Sonnet 5 $0.00010 $0.00317
Haiku 4.5 $0.00005 $0.00159

Measured 3d ago against content hash 845eea481a98, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactoring-advisor 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 3d 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.

pi-skill-refactoring-advisor/skills/refactoring-advisor/SKILL.md · 175 lines

How it starts

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

Refactoring Advisor

Systematic code smell detection and safe refactoring planning. Every refactoring plan ensures the codebase compiles and passes tests at every intermediate step.

Quick Start

Identify and Plan a Refactoring

  1. Detect the smell: What's wrong and why does it matter?
  2. Assess the risk: What could break? How large is the blast radius?
  3. Check test coverage: Are the affected areas covered? If not, add tests first.
  4. Plan incremental steps: Each step should leave the code in a working state.
  5. Estimate effort: Size the work (S/M/L/XL) and identify dependencies.

Common Code Smells by Language

Rust

Smell Description Refactoring
God struct One struct with too many fields/methods Extract into smaller, focused structs
Unnecessary clones .clone() where borrowing would work Replace with borrows, use lifetimes
Stringly typed Using String where an enum fits Introduce enum with From impls
Match explosion Huge match blocks that grow with every variant Extract match arms into methods, use trait dispatch
Unwrap sprawl .unwrap() scattered through non-test code Replace with ? operator, proper error handling
Leaky abstraction pub on internal implementation details Reduce to pub(crate) or pub(super)
Monolithic lib.rs Everything in one file Split into focused modules
Over-generic Generics where a concrete type suffices Simplify to concrete types until generics are needed

TypeScript / React

Smell Description Refactoring
Prop drilling Props passed through 3+ component levels Extract to context, composition, or custom hook
God component Component with 200+ lines or multiple responsibilities Split into focused components
Barrel file bloat Index files re-exporting everything Direct imports, remove barrel files
Any escape hatch as any or // @ts-ignore hiding type issues Fix the types, use type guards or discriminated unions
useEffect spaghetti Multiple unrelated effects in one component Split effects, extract to custom hooks
Inline styles sprawl Styles defined inline instead of using design system Extract to CSS modules, Tailwind classes, or styled components
Callback prop chains Passing callbacks through many layers Use context or state management
State duplication Same data stored in multiple state variables Derive computed values, single source of truth

Read the full file on GitHub · 175 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. 3d ago First seen · 175 lines · 48 tokens per session scan A 845eea481a98

Subscribe to this mod's changes

refactoring-advisor is a skill published in the GitHub repository Firstp1ck/pi-coding-agent-forge (74 stars, last pushed 3d ago), licensed MIT. It adds 48 tokens to every session and 1,586 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-30.