code-refactoring

code-refactoring is a skill for Claude Code, Codex from autohandai/community-skills. It costs 55 tokens per session (2,875 once invoked), scanned A, original, Apache-2.0.

A code-cleanup guide for making existing programs easier to read and simpler without changing what they do.

In plain words
What is it for?
It helps split large functions, apply common design principles, check that behavior is preserved, and clean up code after bugs or before new features.
Why use it?
It helps remove repeated or overly complicated code and reduce technical debt, making future changes safer.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Codex.

Good fit It helps split large functions, apply common design principles, check that behavior is preserved, and clean up code after bugs or before new features.

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

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 code-refactoring

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/autohandai/community-skills/code-refactoring"><img src="https://agentmods.dev/badge/skills/autohandai/community-skills/code-refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,875 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.00055 $0.02875
Opus 5.5 $0.00022 $0.01150
Sonnet 5.5 $0.00011 $0.00575
Haiku 4.5 $0.00006 $0.00287

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

Security

Grade A, and why

code-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 2mo 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.

code-refactoring/SKILL.md · 496 lines

How it starts

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

Code Refactoring

When to use this skill

  • Code review: Discovering complex or duplicated code
  • Before adding new features: Cleaning up existing code
  • After bug fixes: Removing root causes
  • Resolving technical debt: Regular refactoring

Instructions

Step 1: Extract Method

Before (long function):

function processOrder(order: Order) {
  // Validation
  if (!order.items || order.items.length === 0) {
    throw new Error('Order must have items');
  }
  if (!order.customerId) {
    throw new Error('Order must have customer');
  }

  // Price calculation
  let total = 0;
  for (const item of order.items) {
    total += item.price * item.quantity;
  }
  const tax = total * 0.1;
  const shipping = total > 100 ? 0 : 10;
  const finalTotal = total + tax + shipping;

  // Inventory check
  for (const item of order.items) {
    const product = await db.product.findUnique({ where: { id: item.productId } });
    if (product.stock < item.quantity) {
      throw new Error(`Insufficient stock for ${product.name}`);
    }
  }

  // Create order
  const newOrder = await db.order.create({
    data: {
      customerId: order.customerId,
      items: order.items,
      total: finalTotal,
      status: 'pending'
    }
  });

  return newOrder;
}

After (method extraction):

async function processOrder(order: Order) {
  validateOrder(order);
  const total = calculateTotal(order);
  await checkInventory(order);
  return await createOrder(order, total);
}

function validateOrder(order: Order) {
  if (!order.items || order.items.length === 0) {
    throw new Error('Order must have items');
  }
  if (!order.customerId) {
    throw new Error('Order must have customer');
  }
}

function calculateTotal(order: Order): number {
  const subtotal = order.items.reduce((sum, item) => sum + item.price * item.quantity, 0);
  const tax = subtotal * 0.1;
  const shipping = subtotal > 100 ? 0 : 10;
  return subtotal + tax + shipping;
}

async function checkInventory(order: Order) {
  for (const item of order.items) {
    const product = await db.product.findUnique({ where: { id: item.productId } });
    if (product.stock < item.quantity) {
      throw new Error(`Insufficient stock for ${product.name}`);
    }
  }
}

async function createOrder(order: Order, total: number) {
  return await db.order.create({
    data: {
      customerId: order.customerId,
      items: order.items,
      total,
      status: 'pending'
    }
  });
}

Read the full file on GitHub · 496 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. 2mo ago First seen · 496 lines · 55 tokens per session scan A 7ec07652b766

Subscribe to this mod's changes

code-refactoring is a skill published in the GitHub repository autohandai/community-skills (14 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 55 tokens to every session and 2,875 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-09-03.

Related

code-refactoring compared with skills from other repositories

code-refactoring next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
code-refactoringautohandai/community-skillsSkill144mo agoApache-2.0A55Claude Code, Codex
agentsop-repo-mapagentsope/SkillAlchemySkill51322d agoMITA108Claude Code, Codex
fix-architectureOvid/paadSkill159yesterdayMITA70Claude Code, Codex
agentic-reviewOvid/paadSkill159yesterdayMITA54Claude Code, Codex
open-pr-cleanTOMOSIA-VIETNAM/open-prSkill462d agoMITA42Cursor
open-pr-watchTOMOSIA-VIETNAM/open-prSkill462d agoMITA88Cursor
open-pr-fixTOMOSIA-VIETNAM/open-prSkill462d agoMITA0Cursor