refactor

refactor is a skill for Claude Code, Codex from oprogramadorreal/optimus-claude. It costs 99 tokens per session (2,548 once invoked), scanned A, original, MIT.

A code-review and restructuring workflow that checks a project against its own coding, architecture, styling, and testing guidelines.

In plain words
What is it for?
Use it to plan and carry out focused or project-wide refactoring, especially when preparing code for broader automated test coverage.
Why use it?
It identifies changes that can make code easier to test and more consistent, then waits for approval before applying them.

Skill for Claude CodeCodex

Part of the optimus plugin — 19 skills, 15 agents, 3 hooks shipped together

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

Made for: Claude Code, Codex.

Or install optimus, the plugin that ships this one along with the rest of its 19 skills, 15 agents, 3 hooks.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/oprogramadorreal/optimus-claude/refactor.svg)](https://agentmods.dev/skills/oprogramadorreal/optimus-claude/refactor)
Your own site
<a href="https://agentmods.dev/skills/oprogramadorreal/optimus-claude/refactor"><img src="https://agentmods.dev/badge/skills/oprogramadorreal/optimus-claude/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,548 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.00099 $0.02548
Opus 5 $0.00049 $0.01274
Sonnet 5 $0.00020 $0.00510
Haiku 4.5 $0.00010 $0.00255

Measured today against content hash 21af8f4ef1df, 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 today.

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/SKILL.md · 125 lines

How it starts

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

Project-Wide Code Refactoring

Analyze existing source code against the project's own guidelines across four lenses — inline for a small scope, fanned out to parallel agents otherwise — present a prioritized refactoring plan, then apply only user-approved changes with test verification. Two goals:

  1. Guideline compliance — align code with coding-guidelines.md, architecture.md, styling.md, and testing.md
  2. Testability — restructure code so /optimus:unit-test can safely increase coverage without risky refactoring

Step 1: Prerequisites and scope

If the current directory has no .git/ directory, read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md and apply it. In a multi-repo workspace, load each targeted repo's .claude/CLAUDE.md and .claude/docs/ (not the workspace root's) and apply that repo's context to its files; if the scope doesn't determine a repo, ask which one.

If .claude/CLAUDE.md or .claude/docs/coding-guidelines.md is missing, recommend /optimus:init first. On the user's choice to continue, fall back to the bundled baseline: read $CLAUDE_PLUGIN_ROOT/skills/init/templates/docs/coding-guidelines.md and work against it plus general best practices, and note in the report that findings are generic, not project-specific.

Focus: a bare testability or guidelines argument sets the focus and is consumed from the scope text — a keyword inside a quoted string is scope, not focus ("improve testability in auth" → no focus). If both appear, take the first and say the other needs its own pass. Everything remaining is natural-language scope.

Scope: if the arguments describe a scope, map it to directory paths by scanning the project structure — no question needed. Otherwise use AskUserQuestion (header "Scope"):

  • Full project — all source directories (default when the user just says "refactor")
  • Directory — specific path(s) for targeted cleanup
  • Changed since — files modified since a commit, tag, or date

Read the full file on GitHub · 125 lines

Files

What ships with it

6 files 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. today Changed 21af8f4ef1df
  2. 3d ago First seen · 125 lines · 99 tokens per session scan A 4c55e93dfd2e

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository oprogramadorreal/optimus-claude (73 stars, last pushed today), licensed MIT. It adds 99 tokens to every session and 2,548 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

advogado-criminal

Advogado criminalista especializado em Maria da Penha, violencia domestica, feminicidio, direito penal brasileiro, medidas protetivas, inquerito policial e acao penal.

sickn33/agentic-awesome-skills · 42 tokens

x-scorecard

OpenSSF Scorecard for assessing open source project security. Check security best practices and compliance. Dependency: This is an x-cmd module. Install x-cmd first (see x-cmd skill for installation options). see x-cmd skill for installation.

x-cmd/x-cmd · 57 tokens

ios-hig-design

Design native iOS interfaces following Apple Human Interface Guidelines. Use when the user mentions "iPhone app", "iPad layout", "SwiftUI", "UIKit", "Dynamic Island", "safe areas", "HIG compliance", "SF Symbols", "haptic feedback", "iOS accessibility", "make my app feel native", or "follow Apple design guidelines".…

wondelai/skills · 145 tokens

2026-legal-research-agent

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape. Activate on "find expungement data", "scrape state laws", "legal research", "court URLs", "statute sources", "Clean Slate laws", "automatic…

majiayu000/claude-skill-registry · 103 tokens

amazon-suspension-appeal

Account suspension prevention and appeal — policy violations, Plan of Action writing, reinstatement process.

nexscope-ai/Amazon-Skills · 25 tokens

catalyst-center-readonly

Query Cisco Catalyst Center read-only — device inventory, site hierarchy, wireless, assurance health, compliance, software images, events. All 514 read-only API operations reachable through 8 grouped dispatchers. Use when asked what Catalyst Center manages, where a device sits, what its health or compliance state is…

automateyournetwork/netclaw · 78 tokens