refactoring

refactoring is a skill for Claude Code from krzysztofsurdy/code-virtuoso. It costs 105 tokens per session (2,767 once invoked), scanned A, original, MIT.

A reference for changing the internal structure of code without changing what it does. It explains 89 refactoring techniques and 22 common code smells, with practical PHP examples and before-and-after comparisons.

In plain words
What is it for?
Use it to simplify methods, move code between classes, reduce complexity, identify code smells, and improve maintainability.
Why use it?
It helps clean up complicated or duplicated code while making the reason and method for each change clear. This reduces technical debt, meaning accumulated code problems that make future work harder.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the knowledge-virtuoso plugin — 15 skills shipped together

Good fit Use it to simplify methods, move code between classes, reduce complexity, identify…

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

Made for: Claude Code.

Or install knowledge-virtuoso, the plugin that ships this one along with the rest of its 15 skills.

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/krzysztofsurdy/code-virtuoso/refactoring.svg)](https://agentmods.dev/skills/krzysztofsurdy/code-virtuoso/refactoring)
Your own site
<a href="https://agentmods.dev/skills/krzysztofsurdy/code-virtuoso/refactoring"><img src="https://agentmods.dev/badge/skills/krzysztofsurdy/code-virtuoso/refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 105 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,767 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.00105 $0.02767
Opus 5 $0.00053 $0.01384
Sonnet 5 $0.00021 $0.00553
Haiku 4.5 $0.00011 $0.00277

Measured 7d ago against content hash d12de690fd35, 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 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.

skills/knowledge/refactoring/SKILL.md · 135 lines

How it starts

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

Refactoring

A thorough reference covering 89 refactoring techniques and code smells — featuring PHP 8.3+ examples, rationale, step-by-step mechanics, and before/after comparisons.

Refactoring Techniques (67)

Composing Methods

  • Extract Method — Pull code fragments into named methods → reference
  • Inline Method — Substitute a method call with its body → reference
  • Extract Variable — Give complex expressions meaningful names through explanatory variables → reference
  • Inline Temp — Substitute a temporary variable with its expression → reference
  • Replace Temp with Query — Swap temp variables for method calls → reference
  • Split Temporary Variable — Assign separate variables for separate purposes → reference
  • Remove Assignments to Parameters — Introduce local variables rather than reassigning parameters → reference
  • Replace Method with Method Object — Convert a complex method into its own class → reference
  • Substitute Algorithm — Swap an algorithm for a clearer alternative → reference

Moving Features Between Objects

  • Move Method — Relocate a method to the class that depends on it most → reference
  • Move Field — Relocate a field to the class that depends on it most → reference
  • Extract Class — Divide a class that handles too much → reference
  • Inline Class — Consolidate a class that does too little → reference
  • Hide Delegate — Introduce methods that conceal delegation chains → reference
  • Remove Middle Man — Allow clients to call the delegate directly → reference
  • Introduce Foreign Method — Attach a missing method to a class you cannot modify → reference
  • Introduce Local Extension — Build a wrapper or subclass for a library class → reference

Read the full file on GitHub · 135 lines

Files

What ships with it

60 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 · 135 lines · 105 tokens per session scan A d12de690fd35

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository krzysztofsurdy/code-virtuoso (20 stars, last pushed 3mo ago), licensed MIT. It adds 105 tokens to every session and 2,767 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-30.

Related

Other skills, from other repositories

gh-issues

Fetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5]…

SafeAI-Lab-X/ClawKeeper · 116 tokens

skill-creator

Create, edit, improve, or audit AgentSkills. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory (moving files to references/ or scripts/, removing stale content, validating…

SafeAI-Lab-X/ClawKeeper · 121 tokens

openclaw-pr-maintainer

Maintainer workflow for reviewing, triaging, preparing, closing, or landing OpenClaw pull requests and related issues. Use when Codex needs to validate bug-fix claims, search for related issues or PRs, apply or recommend close/reason labels, prepare GitHub comments safely, check review-thread follow-up, or perform…

SafeAI-Lab-X/ClawKeeper · 84 tokens

github

GitHub operations via gh CLI: issues, PRs, CI runs, code review, API queries. Use when: (1) checking PR status or CI, (2) creating/commenting on issues, (3) listing/filtering PRs or issues, (4) viewing run logs. NOT for: complex web UI interactions requiring manual browser flows (use browser tooling when available)…

SafeAI-Lab-X/ClawKeeper · 101 tokens

code-review-report

Turn code changes into a single-file HTML code review report that pairs the diff with context a diff can't show — design decisions, rejected alternatives, tradeoffs, unfinished work — plus prioritized review points. Use when preparing for review after finishing a sizable change, refactor, or feature, or whenever the…

2ykwang/agent-skills · 81 tokens

impl

A code-review workflow that checks whether an implementation matches the project's agreed plan and evaluation criteria. It uses `.claude/context.md` as the reference document.

tomoking2004/claude-plugins · 84 tokens