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.
npx agentmods add skills/chandrudp29/skillhub/refactor-agentnpx skills add chandrudp29/skillhub --skill refactor-agentgit clone --depth 1 https://github.com/chandrudp29/skillhubWrote 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.
[](https://agentmods.dev/skills/chandrudp29/skillhub/refactor-agent)<a href="https://agentmods.dev/skills/chandrudp29/skillhub/refactor-agent"><img src="https://agentmods.dev/badge/skills/chandrudp29/skillhub/refactor-agent.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00032 | $0.01321 |
| Opus 5 | $0.00016 | $0.00660 |
| Sonnet 5 | $0.00006 | $0.00264 |
| Haiku 4.5 | $0.00003 | $0.00132 |
Grade A, and why
refactor-agent 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.
How it starts
The opening of the file, as written. The whole thing — 201 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactor Agent
Safe refactoring that improves code without breaking it. Tests before, tests after.
When to Use
- "This function is too long"
- "This code is hard to understand"
- "There's too much duplication"
- "Cyclomatic complexity is too high"
- Before adding a feature to messy code
The Refactoring Rule
Never refactor and change behavior in the same commit.
Refactoring = same inputs, same outputs, better structure. If you're changing behavior, that's a different commit.
Before You Refactor
- Make sure tests exist. If they don't, write them first.
- Run the tests. They must be green before you start.
- Understand what the code does — don't refactor code you don't understand.
- Identify the specific smell you're fixing. Don't refactor everything at once.
The Six Most Valuable Refactors
1. Extract Function
When a function does more than one thing, or a block of code deserves a name:
# Before — what does this block do?
def process_order(order):
total = 0
for item in order.items:
price = item.price
if item.is_member:
price = price * 0.9
if item.quantity > 10:
price = price * 0.85
total += price * item.quantity
if total > 1000:
order.shipping = 0
else:
order.shipping = 15
order.total = total + order.shipping
order.status = "confirmed"
send_confirmation_email(order)
# After — each piece has a name
def process_order(order):
order.total = calculate_order_total(order)
order.shipping = calculate_shipping(order.total)
order.status = "confirmed"
send_confirmation_email(order)
def calculate_item_price(item) -> float:
price = item.price
if item.is_member:
price *= 0.9
if item.quantity > 10:
price *= 0.85
return price * item.quantity
def calculate_order_total(order) -> float:
return sum(calculate_item_price(item) for item in order.items)
def calculate_shipping(order_total: float) -> float:
return 0 if order_total > 1000 else 15
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 3d ago First seen · 201 lines · 32 tokens per session scan A 110c052d057f
refactor-agent is a skill published in the GitHub repository chandrudp29/skillhub (13 stars, last pushed 2mo ago), licensed MIT. It adds 32 tokens to every session and 1,321 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.
Other skills, from other repositories
aposd-audit
Quantitative design audit. Counts pass-throughs, duplication, doc gaps, naming issues, and exceptions across 5 dimensions, scored 0-4.
refactoring-patterns
Use this skill when improving existing code without changing its behavior. It defines when and how to refactor safely.
evolutionary-naming
Use when refactoring code with poor names, when asked to improve naming, or when a user struggles to name a class/method/variable. Symptoms include -Manager/-Util suffixes, single-letter variables, process/handle/do verbs, primitive obsession, god methods with multiple responsibilities. Two modes — audit (broad scan…
software-code-refactoring
Improve production code quality while preserving all existing test behavior. Commonly used for the Refactor phase of TDD red-green-refactor, but applicable to any codebase with tests. Use when production code works but needs cleanup — reducing duplication, improving naming, simplifying complexity, aligning with…
simplify-codebase
Simplification audit or authorized codebase simplification whose stated objective is to remove accidental complexity. Use for evidence-backed deletion or consolidation of dead code, duplicate state, redundant APIs or layers, ownerless abstractions, obsolete compatibility or design records, and over-engineering in any…
cyclomatic-complexity
Refactor code to reduce cyclomatic complexity so it stays readable, maintainable, and aligned with the long-term vision of the codebase, not just optimized for AI comprehension. Use whenever the user asks to refactor, simplify, clean up, or review code quality; mentions complexity, maintainability, readability…