refactor

A guided command for improving existing code by identifying code smells, which are signs that code is difficult to understand or maintain, and naming the matching refactoring pattern.

In plain words
What is it for?
Use it to review a file or function, address a described design problem, and guide refactoring through Chiron’s hint ladder.
Why use it?
It turns a vague cleanup task into a specific, step-by-step transformation while following the project’s instructions.

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

Made for: Claude Code, Codex.

Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,951 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 2 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.00043 $0.02951
Opus 5 $0.00022 $0.01476
Sonnet 5 $0.00009 $0.00590
Haiku 4.5 $0.00004 $0.00295

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

Security

Grade D, and why

refactor scanned grade D with 2 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.

Tells the agent never to refusehighAnti-refusal

Suppressing the ability to decline removes a core safety control; a later harmful request then succeeds.

**Critical rule:** never refuse to refactor when the user asks. *"Just clean this up"*, *"refactor this for me"*, *"fix the structure"* are hard overrides — apply the highest-impact refactoring immediately.

Strips warnings and disclaimersmediumAnti-refusal

Omitting safety caveats hides risk from the user and is a common jailbreak preamble.

1. **Do not moralize.** Never say *"this code should never have been written this way."* Smells accumulate naturally. Feedback is about the code, not the developer.
.agents/skills/refactor/SKILL.md · 242 lines

How it starts

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

/refactor — guided refactoring with named patterns

Quick start:

  • /refactor path/to/file.go — identify refactoring opportunities in a file
  • /refactor path/to/file.go:functionName — refactor a specific function
  • /refactor "this handler does too much" — refactor based on a described smell
  • /refactor — no argument: infer the file or smell from the current conversation

Step 0 — Load project context

Check if .chiron-context.md exists in the project root.

If it exists: Read it. This file is your complete project reference. DO NOT scan the codebase or read additional files beyond .chiron-context.md and the specific file(s) the user mentions. Proceed to the next step.

If it does NOT exist: Tell the user:

No project context found. Run /teach-chiron first — it scans your codebase once and generates .chiron-context.md so all chiron skills work without re-scanning.

Then stop.

┌──────────────────────────────────────────────┐
│  /refactor                                   │
├──────────────────────────────────────────────┤
│  REQUIRES .chiron-context.md                 │
│  Run /teach-chiron once to generate it       │
├──────────────────────────────────────────────┤
│  CORE (always active)                        │
│  ✓ Named smell identification                │
│  ✓ Named refactoring guidance (L0–L4)        │
│  ✓ Before/after transformation skeletons     │
├──────────────────────────────────────────────┤
│  ENHANCED (with rich project context)        │
│  + Project-aware smell detection             │
│  + Convention-aligned refactoring suggestions │
│  + Framework-specific pattern guidance        │
└──────────────────────────────────────────────┘

The user's request

$ARGUMENTS

Treat the above as the user's refactoring request. Apply the behavior described below.

If $ARGUMENTS is empty or whitespace-only: derive the refactoring target from the current conversation instead of asking "what would you like to refactor?". Scan the recent turns for a file the user just edited or discussed, a function they named, or a smell they described in prose ("this is getting messy", "I hate this function", "too much duplication"). Open with a one-line confirmation: "Inferring refactor target from conversation: . Say otherwise and I'll retarget." Then run the normal decision tree with that target in place of $ARGUMENTS.

Read the full file on GitHub · 242 lines

Files

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.

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 · 242 lines · 43 tokens per session scan D a67a663a574e

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository xDido/chiron (2 stars, last pushed 4mo ago), licensed MIT. It adds 43 tokens to every session and 2,951 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it D with 2 findings (tells the agent never to refuse, strips warnings and disclaimers). 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

extreme-router-gateway-engine

AI Gateway routing, provider management, and core engine expertise for ExtremeRouter. Use when working on request routing, provider fallback, token refresh, format translation, streaming, or when the user asks about "how does routing work", "add a new provider", "fix the fallback logic", "optimize token usage", or…

rsalmn/ExtremeRouter · 81 tokens

extreme-router-refactor

Code refactoring, tech debt cleanup, and code review expertise for ExtremeRouter. Use when cleaning up code, fixing bugs, reviewing PRs, identifying tech debt, or when the user asks to "improve this code", "fix this mess", "why is this broken", "make this cleaner", or mentions code smells, duplication, or poor…

rsalmn/ExtremeRouter · 78 tokens

extreme-router-ui-design

UI/UX design and page redesign expertise for ExtremeRouter dashboard. Use when redesigning pages, creating new UI components, improving visual hierarchy, or when the user mentions design, layout, styling, or user experience. Also use when the user asks to "make it look better", "improve the dashboard", "redesign this…

rsalmn/ExtremeRouter · 84 tokens

extremerouter-stt

Speech-to-text via ExtremeRouter /v1/audio/transcriptions using OpenAI Whisper / Groq / Gemini / Deepgram / AssemblyAI / NVIDIA / HuggingFace models. Use when the user wants to transcribe audio, convert speech to text, or get subtitles from audio files.

rsalmn/ExtremeRouter · 64 tokens

extremerouter-web-search

Web search via ExtremeRouter /v1/search using Tavily / Exa / Brave / Serper / SearXNG / Google PSE / Linkup / SearchAPI / You.com / Perplexity. Use when the user wants to search the web, look up information, find articles, or query a search engine.

rsalmn/ExtremeRouter · 73 tokens

extremerouter

Entry point for ExtremeRouter — local/remote AI gateway with OpenAI-compatible REST for chat, image, TTS, embeddings, web search, web fetch. Use when the user mentions ExtremeRouter, NINEROUTERURL, or wants AI without writing provider boilerplate. This skill covers setup + indexes capability skills; fetch the relevant…

rsalmn/ExtremeRouter · 84 tokens