code-refactoring

code-refactoring is a skill for Claude Code, Codex from DauQuangThanh/hanoi-rainbow. It costs 95 tokens per session (991 once invoked), scanned A, original, MIT.

A guide for restructuring existing code so it is easier to read, change, and maintain without changing what it does.

In plain words
What is it for?
Use it to inspect code quality, add or check tests before changes, apply refactoring techniques, and make small verified improvements.
Why use it?
It helps find duplicated, overly complex, or poorly organized code and reduce the risk of breaking working behavior during cleanup.

Skill for Claude CodeCodex

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

Good fit Use it to inspect code quality, add or check tests before changes, apply refactoring techniques, and make small verified improvements.

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

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/dauquangthanh/hanoi-rainbow/code-refactoring.svg)](https://agentmods.dev/skills/dauquangthanh/hanoi-rainbow/code-refactoring)
Your own site
<a href="https://agentmods.dev/skills/dauquangthanh/hanoi-rainbow/code-refactoring"><img src="https://agentmods.dev/badge/skills/dauquangthanh/hanoi-rainbow/code-refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 991 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.00095 $0.00991
Opus 5 $0.00048 $0.00495
Sonnet 5 $0.00019 $0.00198
Haiku 4.5 $0.00010 $0.00099

Measured 7d ago against content hash 35349af452ab, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 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/code-refactoring/SKILL.md · 126 lines

How it starts

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

Code Refactoring

Overview

This skill guides systematic code refactoring to improve code quality, maintainability, and design while preserving functionality. Follow the safe refactoring workflow with comprehensive test coverage and incremental changes.

Refactoring Workflow

Step 1: Analyze Code and Identify Issues

Examine the codebase to identify code smells and quality issues:

  • Long methods (>20-30 lines) or large classes (>300-500 lines)
  • Duplicated code blocks or similar logic in multiple places
  • Unclear or misleading names for variables, methods, or classes
  • Complex conditional logic or deeply nested structures
  • Poor separation of concerns or tight coupling between components

For detailed code smell catalog: See code-smells.md

Step 2: Verify Test Coverage

Before refactoring ANY code:

  1. Check existing test coverage for the code to be refactored
  2. If tests are missing or inadequate, write tests FIRST
  3. Run all tests to establish baseline (all should pass)
  4. Never proceed without adequate test coverage

For test coverage strategies: See testing-strategies.md

Step 3: Choose Refactoring Technique

Select the appropriate refactoring pattern based on the issue:

  • Extract Method/Function: Break down long methods into smaller, focused ones
  • Extract Class: Split large classes with multiple responsibilities
  • Rename: Improve clarity with better names
  • Move Method/Field: Relocate functionality to more appropriate classes
  • Replace Conditional with Polymorphism: Simplify complex conditionals
  • Introduce Parameter Object: Group related parameters
  • Inline Method/Variable: Remove unnecessary indirection

For complete pattern catalog: See refactoring-patterns.md

Step 4: Apply Refactoring Incrementally

Make ONE small change at a time:

  1. Apply a single refactoring technique
  2. Run all tests immediately after the change
  3. If tests pass, commit the change
  4. If tests fail, revert and try a different approach
  5. Repeat for each refactoring needed

Read the full file on GitHub · 126 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. 7d ago First seen · 126 lines · 95 tokens per session scan A 35349af452ab

Subscribe to this mod's changes

code-refactoring is a skill published in the GitHub repository DauQuangThanh/hanoi-rainbow (16 stars, last pushed 7mo ago), licensed MIT. It adds 95 tokens to every session and 991 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-31.

Related

Other skills, from other repositories

code-review-hardening

Use this skill for rigorous, structured code review with a self-repair loop. Applies change-type-aware strategies (feat, fix, hotfix, refactor, migrate, docs). Findings are severity-classified, then auto-fixed where possible. Triggers on PR reviews, code review requests, or when reviewing any change set.

lindoelio/spec-driven-steroids · 70 tokens

quality-grading

Use this skill to grade code, specifications, or design documents across four quality dimensions using a 1-5 scoring scale. In grade-and-fix mode, the skill auto-improves artifacts scoring below 5 without prompting. Invoke when you want consistent quality assessment on design, implementation, or specification with…

lindoelio/spec-driven-steroids · 73 tokens

agent-work-auditor

Unified auditing skill for AI agent workflows. Provides change-type-aware, artifact-adaptive auditing with self-fix capabilities. Works standalone or with spec-driven extensions. Three-layer architecture: core (always active), modules (per-type), extensions (auto-detected).

lindoelio/spec-driven-steroids · 57 tokens

spec-driven-development

Spec-first workflow where an executable, testable specification is written before code and becomes the single source of truth that tests verify against, flowing spec → acceptance criteria → tasks → implementation.

andreibesleaga/GABBE · 40 tokens

bmad-review-edge-case-hunter

Walk every branching path and boundary condition in content, report only unhandled edge cases. Orthogonal to adversarial review - method-driven not attitude-driven. Use when you need exhaustive edge-case analysis of code, specs, or diffs.

amalik/convoke-agents · 55 tokens

bmad-review-adversarial-general

Perform a Cynical Review and produce a findings report. Use when the user requests a critical review of something.

amalik/convoke-agents · 29 tokens