refactoring-guide

refactoring-guide is a skill for Claude Code from terrylica/cc-skills. It costs 27 tokens per session (2,127 once invoked), scanned A, original, MIT.

A guide to restructuring code into clearer modules and boundaries. Refactoring means changing code structure without changing its intended behaviour.

In plain words
What is it for?
Use it when splitting files, extracting modules, reducing dependencies between components, reviewing code structure, or planning architecture changes.
Why use it?
It addresses coupling and poor module boundaries that can make future changes risky, rather than judging code only by how similar it looks.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the quality-tools plugin — 11 skills shipped together , and of cc-skills

Good fit Use it when splitting files, extracting modules, reducing dependencies between components, reviewing code structure, or planning architecture changes.

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

Made for: Claude Code.

Or install quality-tools, the plugin that ships this one along with the rest of its 11 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-guide

README.md
[![agentmods](https://agentmods.dev/badge/skills/terrylica/cc-skills/refactoring-guide.svg)](https://agentmods.dev/skills/terrylica/cc-skills/refactoring-guide)
Your own site
<a href="https://agentmods.dev/skills/terrylica/cc-skills/refactoring-guide"><img src="https://agentmods.dev/badge/skills/terrylica/cc-skills/refactoring-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,127 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Rogue Agent · line 126
    Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.
    Fix: Prevent the skill from modifying its own code, SKILL.md, or configuration files. Treat skill files as read-only at runtime.
How audits are shown
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.00027 $0.02127
Opus 5 $0.00014 $0.01064
Sonnet 5 $0.00005 $0.00425
Haiku 4.5 $0.00003 $0.00213

Measured 2d ago against content hash 78e1ab2847dc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

refactoring-guide 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 2d 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.

plugins/quality-tools/skills/refactoring-guide/SKILL.md · 129 lines

How it starts

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

Refactoring Guide

Principles that LLMs consistently get wrong during refactoring. This skill corrects systematic blind spots around coupling analysis, type-level design, module boundaries, and safe migration strategies.

The core problem: LLMs optimize for what code looks like (structural similarity), but good modularization optimizes for how code changes together (temporal cohesion). Every principle here addresses that gap.

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use

  • Refactoring tasks: Extract module, split file, reduce coupling, reorganize
  • Code review: Spot smells and suggest the right fix (not the superficial one)
  • Architecture decisions: Module boundaries, dependency direction, integration points
  • Proactively: When you detect any signal from the Detection Heuristics table below

Workflow

When refactoring, follow this sequence:

  1. Detect — Scan the code against the Detection Heuristics table. Identify which smells are present.
  2. Diagnose — For each smell, read the corresponding reference file to understand the correct principle.
  3. Plan — Design the refactoring using the right technique. For multi-file changes (>3 files), use the Mikado Method (see references/architecture.md).
  4. Execute — Apply changes. For shared interfaces, use expand-contract (see references/tactical-moves.md).
  5. Verify — Confirm the refactoring reduced the specific coupling type identified in step 1.

Detection Heuristics

Scan for these signals to identify which principle to apply:

Signal Likely Smell Principle Reference
Same group of parameters passed to 3+ functions Data clump Parse, don't validate — extract parameter object type-design.md §1
Method uses more of another class's fields than its own Feature envy Move method to where data lives module-boundaries.md
if isinstance / type switch with >2 branches Missing polymorphism Replace conditional with polymorphism type-design.md §2
Import cycle between modules Acyclic violation Extract shared or invert dependency module-boundaries.md §2
Boolean parameter on public API Flag argument Split into separate methods or use enum tactical-moves.md §5
# TODO: remove after migration older than 3 months Dead code Delete it now tactical-moves.md §1
Function has both return and side effects (db/file/network) Mixed concerns Functional core, imperative shell architecture.md §1
Test requires mocking >3 dependencies Over-coupling Missing a seam — identify and create one structural-coupling.md §1
Changing one feature touches >3 directories Wrong slicing Package by feature, not layer module-boundaries.md §1
Two modules that always change in the same PR Under-modularized Common closure — merge them module-boundaries.md §3
One module changes for unrelated reasons Divergent change Split by reason-for-change structural-coupling.md §4
One logical change touches 5+ files Shotgun surgery Merge the scattered concern structural-coupling.md §4
init() must be called before process() Temporal coupling Type-state pattern type-design.md §4
External API types used deep in business logic Leaked integration Anti-corruption layer at boundary architecture.md §2
Same struct mutated in 3+ different modules Unclear data ownership Designate owning module for each data type structural-coupling.md §5
Vendor SDK types used in core logic Volatility leak Wrap behind narrow stable interface structural-coupling.md §6
Module exposes setters instead of operations Undefended invariants Expose intention-revealing operations module-boundaries.md §5
Infrastructure exceptions surface in business logic Error leakage Translate errors at module boundary module-boundaries.md §6
Pass-through layer with no logic (just forwards calls) Fake modularity Remove unnecessary indirection tactical-moves.md §9
Module named utils, common, helpers, shared Dumping ground Split by actual consumer clusters module-boundaries.md §4
Domain logic inside controllers, handlers, or jobs Misplaced business logic Extract to domain module architecture.md §1
Services scattered across modules constructing own deps Missing composition root Centralize wiring at app entry point architecture.md §5
God service that coordinates AND decides everything Mixed orchestration Separate orchestration from computation architecture.md §1

Read the full file on GitHub · 129 lines

Files

What ships with it

7 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. 2d ago First seen · 129 lines · 27 tokens per session scan A 78e1ab2847dc

Subscribe to this mod's changes

refactoring-guide is a skill published in the GitHub repository terrylica/cc-skills (62 stars, last pushed yesterday), licensed MIT. It adds 27 tokens to every session and 2,127 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-09-05.

Related

Other skills, from other repositories

generic-react-code-reviewer

Review React/TypeScript code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md workflow compliance. Enforces TypeScript strict mode, GPU-accelerated animations, WCAG AA accessibility, bundle size limits, and surgical simplicity. Use when completing features, before commits, or…

travisjneuman/.claude · 71 tokens

generic-fullstack-code-reviewer

Review full-stack code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md compliance. Enforces TypeScript strict mode, input validation, GPU-accelerated animations, and design system consistency. Use when completing features, before commits, or reviewing pull requests.

travisjneuman/.claude · 64 tokens

generic-static-code-reviewer

Review static site code for bugs, security issues, performance problems, accessibility gaps, and CLAUDE.md compliance. Enforces pure HTML/CSS/JS standards, minimal page weight, mobile-first design. Use when completing features, before commits, or reviewing changes.

travisjneuman/.claude · 59 tokens

generic-code-reviewer

Review code for bugs, security vulnerabilities, performance issues, accessibility gaps, and CLAUDE.md workflow compliance. Supports any tech stack - HTML/CSS/JS, React, TypeScript, Node.js, Python, NestJS, Next.js, and more. Use when completing features, before commits, or reviewing pull requests.

travisjneuman/.claude · 70 tokens

plan-review-architecture

Architecture-dimension reviewer for written plans. Use when running plan-review or directly when an architectural review is wanted. Activate for keywords like "architecture review", "data flow", "failure modes", "rollback", "edge cases", "test matrix". Scores 5 sub-dimensions 0-10, produces ranked fixes. Always cite…

duthaho/claudekit · 87 tokens

reviewing

Claude-on-Claude code review protocol — reviews implementation against spec requirements and code quality standards.

LucasDuys/forge · 19 tokens