refactor

A guide for changing existing code so it is easier to read, maintain, or improve without changing what it does.

In plain words
What is it for?
Cleaning up functions, hooks, and modules, then comparing the old and new code and checking the test suite.
Why use it?
It helps remove repetition, deep nesting, unclear names, weak TypeScript types, and overly large files while preserving behavior.

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

Made for: Claude Code, Codex.

Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 165 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.00015 $0.00165
Opus 5 $0.00008 $0.00082
Sonnet 5 $0.00003 $0.00033
Haiku 4.5 $0.00002 $0.00016

Measured yesterday against content hash 5a33748df45c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactor 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 yesterday.

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.

fixtures/home/.claude/skills/refactor/SKILL.md · 20 lines

What it actually says

Refactor

Analyze the provided code and refactor it following these principles:

  1. Extract: Pull repeated patterns into shared functions or hooks
  2. Simplify: Reduce nesting, flatten conditionals, use early returns
  3. Name: Rename unclear variables and functions to express intent
  4. Type: Tighten TypeScript types — eliminate any, use discriminated unions
  5. Split: Break files over 200 lines into focused modules

Always preserve existing behavior — verify with the test suite before and after. Output a before/after comparison with explanations for each change.

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. yesterday First seen · 20 lines · 15 tokens per session scan A 5a33748df45c

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository AmElmo/loadout (9 stars, last pushed 4mo ago), licensed MIT. It adds 15 tokens to every session and 165 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

todos

This chat has a shared, live TODO plan — your tasks for the conversation, which the user also edits. Read this skill and reach for the todo tools whenever a request takes more than a couple of steps. It covers the plan model (group = task, items = its steps; loose items are the user's lane), how to work it: propose…

JetBrains/thinkrail · 127 tokens

writing-workflow-skills

Use when adding a new workflow skill to pi-thinkrail-workflow, changing an existing workflow skill's role, trigger, handoff, or structure, or checking a workflow skill against the workflow system's rules. Not for authoring general-purpose skills outside this package.

JetBrains/thinkrail · 60 tokens

memorix-troubleshooting

Use when Memorix MCP, setup, project binding, HTTP control plane, hooks, skills, or agent integration is missing, stale, or failing.

AVIDS2/memorix · 36 tokens

setting-up-a-project

Use whenever asked to set up, onboard, initialize, or spec a project — the front door when the workspace has no spec graph yet (brand-new or an existing codebase); also seeded by the app's Set-up-project card (/skill:setting-up-a-project). Not for feature work in an already-specced project — use the brainstorming…

JetBrains/thinkrail · 76 tokens

clarify

Adaptive requirements clarification with auto-depth routing. Shallow (Q&A) for simple tasks, Deep (exploration + DRAFT + PLAN) for complex ones. Escalates automatically when ambiguity persists.

mag123c/toktrack · 43 tokens

adr

Create and manage Architecture Decision Records. Documents significant technical decisions with context, alternatives, and consequences. Also supports evaluate (assess proposals) and design (system design) modes.

drafthq/draft · 37 tokens