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.
npx skills add DauQuangThanh/hanoi-rainbow --skill code-refactoringgit clone --depth 1 https://github.com/DauQuangThanh/hanoi-rainbowWrote 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.
[](https://agentmods.dev/skills/dauquangthanh/hanoi-rainbow/code-refactoring)<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>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.
| Model | Per session | Once 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 |
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.
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:
- Check existing test coverage for the code to be refactored
- If tests are missing or inadequate, write tests FIRST
- Run all tests to establish baseline (all should pass)
- 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:
- Apply a single refactoring technique
- Run all tests immediately after the change
- If tests pass, commit the change
- If tests fail, revert and try a different approach
- Repeat for each refactoring needed
What ships with it
8 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.
- references/code-smells.md 19 KB
- references/common-refactoring-scenarios.md 1.6 KB
- references/output-format.md 492 B
- references/refactoring-best-practices.md 5.1 KB
- references/refactoring-patterns.md 18 KB
- references/refactoring-process.md 19 KB
- references/testing-strategies.md 20 KB
- references/tools-and-automation.md 665 B
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.
- 7d ago First seen · 126 lines · 95 tokens per session scan A 35349af452ab
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.
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.
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…
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).
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.
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.
bmad-review-adversarial-general
Perform a Cynical Review and produce a findings report. Use when the user requests a critical review of something.