refactoring

refactoring is a skill for Claude Code, Codex from furkangonel/cowrangler. It costs 15 tokens per session (913 once invoked), scanned A, original, MIT.

A guide to improving a program's internal structure without changing what users or other software observe it doing.

In plain words
What is it for?
Use it to extract functions, replace unexplained numbers with named constants, simplify conditions, and apply other safe structural improvements.
Why use it?
It encourages small, controlled changes and requires tests before and after each refactoring step.

Skill for Claude CodeCodex

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

Good fit Use it to extract functions, replace unexplained numbers with named constants, simplify conditions, and apply other safe structural improvements.

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

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 refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/furkangonel/cowrangler/refactoring/github.svg)](https://agentmods.dev/skills/furkangonel/cowrangler/refactoring)
Your own site
<a href="https://agentmods.dev/skills/furkangonel/cowrangler/refactoring"><img src="https://agentmods.dev/badge/skills/furkangonel/cowrangler/refactoring/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 refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/furkangonel/cowrangler/refactoring"><img src="https://agentmods.dev/badge/skills/furkangonel/cowrangler/refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 913 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.00015 $0.00913
Opus 5.5 $0.00006 $0.00365
Sonnet 5.5 $0.00003 $0.00183
Haiku 4.5 $0.00002 $0.00091

Measured 3mo ago against content hash 93fea8bc97e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

refactoring 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 3mo 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.

bundled_skills/refactoring/SKILL.md · 139 lines

How it starts

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

Refactoring SOP

Golden Rule

Refactoring must not change observable behavior. Tests must pass before AND after every refactoring step.

Pre-Refactoring Checklist

  • Tests exist for the code being refactored (write them first if not)
  • The current behavior is clearly understood
  • A clear goal for the refactoring is defined
  • Changes are isolated to one concern at a time

Refactoring Catalog

Extract Function

When: A block of code does one identifiable thing; the block is too long; code is duplicated.

// BEFORE
function printReport(data: ReportData) {
  // ... 20 lines of calculation ...
  const total = data.items.reduce((sum, i) => sum + i.price * i.qty, 0);
  const tax = total * 0.18;
  // ... 20 lines of formatting ...
}

// AFTER
function calculateTotal(items: Item[]) {
  return items.reduce((sum, i) => sum + i.price * i.qty, 0);
}
function calculateTax(total: number, rate = 0.18) {
  return total * rate;
}

Replace Magic Numbers with Named Constants

// BEFORE
if (user.sessionAge > 86400) { logout(); }

// AFTER
const SESSION_EXPIRY_SECONDS = 86400; // 24 hours
if (user.sessionAge > SESSION_EXPIRY_SECONDS) { logout(); }

Simplify Conditionals — Early Return / Guard Clauses

// BEFORE (arrow-shaped code)
function processOrder(order: Order) {
  if (order) {
    if (order.items.length > 0) {
      if (order.status === "pending") {
        // actual logic...
      }
    }
  }
}

// AFTER (flat, readable)
function processOrder(order: Order) {
  if (!order) return;
  if (order.items.length === 0) return;
  if (order.status !== "pending") return;
  // actual logic...
}

Remove Duplication (DRY)

// BEFORE
function validateEmail(email: string) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
function validateLoginEmail(email: string) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);  // duplicated!
}

// AFTER
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
function isValidEmail(email: string) {
  return EMAIL_REGEX.test(email);
}

Read the full file on GitHub · 139 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. 3mo ago First seen · 139 lines · 15 tokens per session scan A 93fea8bc97e5

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository furkangonel/cowrangler (1 stars, last pushed 2mo ago), licensed MIT. It adds 15 tokens to every session and 913 once invoked, about $0.0001 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-31.

Related

refactoring compared with skills from other repositories

refactoring next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactoringfurkangonel/cowranglerSkill12mo agoMITA15Claude Code, Codex
clinicaltrials-databasesynthetic-sciences/openscienceSkill4.5kyesterdayApache-2.0A47Claude Code, Codex
openalex-databasesynthetic-sciences/openscienceSkill4.5kyesterdayApache-2.0A76Claude Code, Codex
glycoengineeringsynthetic-sciences/openscienceSkill4.5kyesterdayApache-2.0A75Claude Code, Codex
esmsynthetic-sciences/openscienceSkill4.5kyesterdayApache-2.0A86Claude Code, Codex
pysamsynthetic-sciences/openscienceSkill4.5kyesterdayApache-2.0A47Claude Code, Codex
session-investigatorevalstate/fast-agentSkill4.0kyesterdayApache-2.0A68Claude Code, Codex