refactor

refactor is a skill for Claude Code from darkroomengineering/cc-settings. It costs 58 tokens per session (782 once invoked), scanned A, original, MIT.

A workflow for restructuring existing code while keeping its behavior unchanged; refactoring means improving the code's internal organization without changing what it does.

In plain words
What is it for?
It is for extracting code into modules, renaming code across a project, and restructuring code that is not part of the current changes.
Why use it?
It provides a defined process for breaking up modules, renaming code across files, and reducing technical debt.

Skill for Claude Code

Written for Claude Code: context: fork in frontmatter. Also seen: mentions Codex.

Part of the darkroom plugin — 24 skills, 11 agents, 4 hooks shipped together

Good fit It is for extracting code into modules, renaming code across a project, and restructuring code that is not part of the current changes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/darkroomengineering/cc-settings/refactor
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 darkroomengineering/cc-settings --skill refactor
Clone the repo
git clone --depth 1 https://github.com/darkroomengineering/cc-settings

Made for: Claude Code.

Or install darkroom, the plugin that ships this one along with the rest of its 24 skills, 11 agents, 4 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/darkroomengineering/cc-settings/refactor/github.svg)](https://agentmods.dev/skills/darkroomengineering/cc-settings/refactor)
Your own site
<a href="https://agentmods.dev/skills/darkroomengineering/cc-settings/refactor"><img src="https://agentmods.dev/badge/skills/darkroomengineering/cc-settings/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/darkroomengineering/cc-settings/refactor"><img src="https://agentmods.dev/badge/skills/darkroomengineering/cc-settings/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 58 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 782 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.00058 $0.00782
Opus 5.5 $0.00023 $0.00313
Sonnet 5.5 $0.00012 $0.00156
Haiku 4.5 $0.00006 $0.00078

Measured 14d ago against content hash f571daeedfad, 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 14d 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 · 76 lines

How it starts

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

Refactoring Workflow

Standalone Codex

Create each new agent with spawn_agent, deliver context to a running agent with send_message, trigger another turn for an idle existing agent with followup_task, wait with wait_agent, and stop a current turn with interrupt_agent only when necessary. Never spawn codex-verifier and never run codex-run.ts from inside Codex.

Writers share the working tree unless the live host explicitly offers isolation. Assign non-overlapping ownership and serialize planner handoff, implementer, and test-writer phases; only read-only reviewers may overlap. Codex implementers are not promised Claude worktree isolation.

You are in Maestro orchestration mode. Delegate immediately.

Workflow

  1. Clarify - A refactor's target shape is rarely fixed by the request. Before exploring, run clarifying rounds through the host's question tool until no fork is left: target shape, what must not change, and what "done" looks like; recommendation first on each
  2. Explore - Spawn explore agent to analyze current code
  3. Plan - Spawn planner agent to design refactoring approach
  4. Implement - Spawn implementer agent to refactor
  5. Test - Spawn tester agent to verify behavior unchanged
  6. Review - Spawn reviewer agent to check quality
  7. Learn - Store patterns discovered during refactoring

Agent Delegation

Spawn explore and planner first — they accept thin prompts because they discover what they need from the codebase:

Agent(explore, "Analyze the code to refactor: $ARGUMENTS. Identify patterns, issues, dependencies.")
Agent(planner, "Design refactoring approach based on analysis. Keep behavior unchanged.")

Claude: then assemble the implementer prompt from the actual planner output. The Claude implementer runs in an isolated worktree with no access to prior agent results, so paste the real plan — not "according to plan":

  • The user's refactor target ($ARGUMENTS) verbatim
  • The planner's step-by-step plan, including file paths and each move/rename/extract operation
  • Any "preserve behavior" invariants the planner called out
  • The test command that must remain green
  • Scope: "only the files in the plan; do not touch anything else"

Read the full file on GitHub · 76 lines

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. 14d ago Changed · -8 lines f571daeedfad
  2. 28d ago Changed 720fb468e7b0
  3. 1mo ago Changed cf97fc5ff198
  4. 1mo ago Changed · +1 lines 9fab9b070cac
  5. 1mo ago Changed · +2 tokens per session 444f8c507ff4
  6. 1mo ago Changed · -3 lines 2eb5c8e6a198
  7. 2mo ago First seen · 86 lines · 56 tokens per session scan A 0adc29bc60a6

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository darkroomengineering/cc-settings (52 stars, last pushed today), licensed MIT. It adds 58 tokens to every session and 782 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.