refactor

refactor is a skill for Claude Code, Codex from codeaholicguy/ai-devkit. It costs 49 tokens per session (709 once invoked), scanned A, original, Apache-2.0.

A guide for planning structural changes across code files while keeping existing behavior and public interfaces intact. A refactor reorganizes code without intentionally changing what it does.

In plain words
What is it for?
It helps assess refactor size, inspect existing code structure, plan changes, preserve contracts, and validate multi-file or multi-package reorganizations.
Why use it?
It helps reduce the risk of breaking users or dependent code during module moves, renames, extractions, and other broad changes.

Skill for Claude CodeCodex

Written for Claude Code and Codex: shipped in a Claude Code plugin, but also agents/openai.yaml present.

Part of the ai-devkit plugin — 29 skills, 1 hook shipped together

Good fit It helps assess refactor size, inspect existing code structure, plan changes, preserve contracts, and validate multi-file or multi-package reorganizations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/codeaholicguy/ai-devkit/refactor
About the project

AI DevKit is a local-first control layer that gives multiple AI coding agents shared configuration, a terminal dashboard, cross-agent messaging, local memory retrieval, and reusable engineering workflows. It is for developers and teams supervising agents such as Claude Code, Codex CLI, Gemini CLI, OpenCode, Pi, Cursor, Copilot, or Devin. The catalogue entries are composable skills and plugin components used within that agent-management system.

codeaholicguy/ai-devkit · 1,650 stars · on GitHub · ai-devkit.com

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.

Any agent
npx skills add codeaholicguy/ai-devkit --skill refactor
Clone the repo
git clone --depth 1 https://github.com/codeaholicguy/ai-devkit

Made for: Claude Code, Codex.

Or install ai-devkit, the plugin that ships this one along with the rest of its 29 skills, 1 hook.

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/codeaholicguy/ai-devkit/refactor/github.svg)](https://agentmods.dev/skills/codeaholicguy/ai-devkit/refactor)
Your own site
<a href="https://agentmods.dev/skills/codeaholicguy/ai-devkit/refactor"><img src="https://agentmods.dev/badge/skills/codeaholicguy/ai-devkit/refactor/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/codeaholicguy/ai-devkit/refactor"><img src="https://agentmods.dev/badge/skills/codeaholicguy/ai-devkit/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 709 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00049 $0.00709
Opus 5.5 $0.00020 $0.00284
Sonnet 5.5 $0.00010 $0.00142
Haiku 4.5 $0.00005 $0.00071

Measured 1mo ago against content hash e93f7d468803, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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.

skills/refactor/SKILL.md · 44 lines

How it starts

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

Refactor

Use for structural refactors. Use simplify-implementation for local readability, dead code, or small logic cleanup.

Rules

  • Preserve behavior and public contracts unless changes are explicit.
  • Classify first: small = local/no public movement; medium = multi-file/extraction/boundary/export touch; large = package/cross-package/staged migration/broad consumers.
  • For medium/large refactors, write a brief before editing: evidence, pressure, remaining delta, do/defer/avoid ranking, non-goals, contracts, target shape, validation, compatibility.
  • Do not propose target trees without current-code evidence: tree, file size/mixed concerns, imports/exports, consumers, validation commands.
  • Separate moves/renames from logic changes and design/API behavior questions.
  • Prefer existing conventions, provider locality, and the smallest structure that solves observed pressure.
  • Subtract before adding: remove dead wrappers, redundant validators, stale exports, and unused paths before introducing new structure.
  • Avoid taste refactors, premature abstractions, and thin one-file directories unless staged or conventional.
  • Validate with fresh command output.

Workflow

  1. Discover stack, configs, entry points, exact validation commands, and prior decisions when available.
  2. Map contracts: exports, APIs, routes, CLI, config, schemas, events, files, docs, examples, consumers.
  3. Map structure: directories, naming, boundaries, dependency direction, cycles, mixed concerns, duplication.
  4. Check reader load: can a new reader find where key state comes from and what can change it quickly? Collapse pass-through layers that do not hide policy, adaptation, or real complexity.
  5. If continuing work, compare current state and list only remaining delta.
  6. Choose refactor type and shape:
    • extraction, reorganization, or design refactor
    • flat/internal, feature-first, domain-first, layer-first, core/adapters/entrypoints, service/repository
    • adapter-heavy: provider-specific stays provider-local; shared pure logic -> shared/core/formatting; SDK/client code -> adapter/entrypoint/delivery
  7. Check boundary discipline: validate at CLI/config/network/external API edges; keep internal logic typed, domain-shaped, and pure where practical.
  8. Prefer domain structure over repeated conditionals: state machine, typed model, registry/map, reducer, or ownership-focused module when it deletes branches or invalid states.
  9. Rank moves as do now, defer, or avoid.
  10. Stage: baseline -> delete dead paths -> move/rename -> imports/call sites -> split/merge -> simplify -> exports/docs/tests.
  11. For internal API changes, inventory callers, migrate them, and delete the legacy API in the same wave when no external contract requires compatibility.
  12. Preserve or explain compatibility re-exports/wrappers/barrels like types.ts plus types/.
  13. Validate: tests, compile/typecheck, lint, build, public/downstream smoke checks, diff review.

Read the full file on GitHub · 44 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. 1mo ago First seen · 44 lines · 49 tokens per session scan A e93f7d468803

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository codeaholicguy/ai-devkit (1,650 stars, last pushed 2d ago), licensed Apache-2.0. It adds 49 tokens to every session and 709 once invoked, about $0.0002 per session on Opus 5.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.