refactor

refactor is a skill for Claude Code, Codex from adonai-labs/agent-runway. It costs 95 tokens per session (1,382 once invoked), scanned A, original, MIT.

A structured approach for improving code structure without changing what the program does. It covers readability, maintainability, and common design principles across programming languages, with detailed examples for C# and .NET.

In plain words
What is it for?
Use it to simplify large methods or services, extract separate responsibilities, replace complex conditionals with clearer designs, and safely reorganise existing code.
Why use it?
It makes complex code easier to understand and maintain while using tests to guard against accidental behaviour changes. If tests are missing, it calls for tests that capture the current behaviour first.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to simplify large methods or services, extract separate responsibilities, replace complex conditionals with clearer designs, and safely reorganise existing code.

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

Made for: Claude Code, Codex.

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/adonai-labs/agent-runway/refactor.svg)](https://agentmods.dev/skills/adonai-labs/agent-runway/refactor)
Your own site
<a href="https://agentmods.dev/skills/adonai-labs/agent-runway/refactor"><img src="https://agentmods.dev/badge/skills/adonai-labs/agent-runway/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,382 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.
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.00095 $0.01382
Opus 5 $0.00048 $0.00691
Sonnet 5 $0.00019 $0.00276
Haiku 4.5 $0.00010 $0.00138

Measured 7d ago against content hash 869bacf9468e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 7d 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.

src/core/skills/refactor/SKILL.md · 134 lines

How it starts

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

Refactor

Invoke Command

/refactor <description or file reference>

Examples:

  • /refactor OrderService is too large
  • /refactor extract validation logic from CreateOrderHandler
  • /refactor replace switch on payment type with strategy pattern
  • /refactor this method is doing too much (with file open)

Not sure which skill to use? Start with /start — it classifies intent and routes to the right skill.


Core Principle

Change structure, not behaviour. Every refactoring step must leave tests green.

If there are no tests, write characterisation tests first — they are the safety net.


Workflow

Step 1 — Understand Before Touching

Read safe-refactoring.md before starting any refactoring session.

  • What does this code do end-to-end?
  • Why does it need refactoring? Name the specific problem — see complexity-signals.md to confirm refactoring is justified.
  • Are there existing tests? If not, write characterisation tests first — see the safety net section in safe-refactoring.md.
  • What is the blast radius — what else depends on this?

Step 2 — Detect Smells Systematically

Run the relevant searches from systematic-smells.md against the target code. Document what you find.

Then name the specific problem using the smell table in reference.md before proposing a fix. If the smell is not in the table, describe it in terms of the complexity signals from complexity-signals.md.

Step 3 — Decide Scope and Priority

Use complexity-signals.md to determine:

  • Is this a micro, targeted, or structural refactoring?
  • Is this code a change hotspot (changes frequently + high complexity)?
  • For structural refactors, consult the architect skill before proceeding.

Priority order:

  1. Remove duplication — it multiplies every other problem
  2. Improve naming — often reveals deeper design issues
  3. Extract methods — restore readability and testability
  4. Introduce abstractions — only when a pattern clearly repeats
  5. Restructure to correct layer — move misplaced logic to where it belongs

Read the full file on GitHub · 134 lines

Files

What ships with it

4 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. 7d ago First seen · 134 lines · 95 tokens per session scan A 869bacf9468e

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository adonai-labs/agent-runway (2 stars, last pushed 17d ago), licensed MIT. It adds 95 tokens to every session and 1,382 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-31.