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…

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.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.svg" alt="Measured on agentmods" 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 $0.00008 $0.00456
Sonnet 5 $0.00003 $0.00183
Haiku 4.5 $0.00002 $0.00091

Measured 6d ago against content hash 93fea8bc97e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d 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. 6d 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 (2 stars, last pushed today), licensed MIT. It adds 15 tokens to every session and 913 once invoked, about $0.0001 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.

Related

Other skills, from other repositories

datamol

Pythonic wrapper around RDKit with simplified interface and sensible defaults. Preferred for standard drug discovery including SMILES parsing, standardization, descriptors, fingerprints, clustering, 3D conformers, parallel processing. Returns native rdkit.Chem.Mol objects. For advanced control or custom parameters…

synthetic-sciences/openscience · 67 tokens

session-investigator

Investigate fast-agent session and history files to diagnose issues. Use when a session ended unexpectedly, when debugging tool loops, when correlating sub-agent traces with main sessions, or when analyzing conversation flow and timing. Covers session.json metadata, history JSON format, message structure, tool…

evalstate/fast-agent · 68 tokens

x-uptime

Enhanced uptime with structured YAML output showing uptime, users, and 1/5/15-minute load averages. 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 · 67 tokens

clinicaltrials-database

Query ClinicalTrials.gov via API v2. Search trials by condition, drug, location, status, or phase. Retrieve trial details by NCT ID, export data, for clinical research and patient matching.

synthetic-sciences/openscience · 47 tokens

openalex-database

Query and analyze scholarly literature using the OpenAlex database. This skill should be used when searching for academic papers, analyzing research trends, finding works by authors or institutions, tracking citations, discovering open access publications, or conducting bibliometric analysis across 240M+ scholarly…

synthetic-sciences/openscience · 76 tokens

x-mankier

Search and browse man pages from ManKier.com. Command line interface for ManKier man page repository. 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 · 62 tokens