refactor

refactor is a skill for Claude Code, Codex from luongnv89/claude-howto. It costs 64 tokens per session (2,789 once invoked), scanned A, original, MIT.

A step-by-step method for improving a program’s internal code structure without changing what it does.

In plain words
What is it for?
Use it to analyze a codebase, assess test coverage, plan refactoring, and apply incremental improvements.
Why use it?
It reduces technical debt and code smells while using tests and small changes to help prevent regressions.

Skill for Claude CodeCodex

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

About the project

luongnv89/claude-howto is a visual, example-based guide to Claude Code, a coding tool that supports agents, hooks, skills, slash commands, and MCP servers. Developers use it to learn Claude Code through practical workflows and copyable templates, including the commands, agents, skills, plugins, and instructions catalogued here.

luongnv89/claude-howto · 41,371 stars · on GitHub · luongnv.com

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.

agentmods
npx agentmods add skills/luongnv89/claude-howto/refactor
Any agent
npx skills add luongnv89/claude-howto --skill refactor
Clone the repo
git clone --depth 1 https://github.com/luongnv89/claude-howto

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 refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/luongnv89/claude-howto/refactor.svg)](https://agentmods.dev/skills/luongnv89/claude-howto/refactor)
Your own site
<a href="https://agentmods.dev/skills/luongnv89/claude-howto/refactor"><img src="https://agentmods.dev/badge/skills/luongnv89/claude-howto/refactor.svg" alt="Measured on agentmods" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00064 $0.02789
Opus 5 $0.00032 $0.01394
Sonnet 5 $0.00013 $0.00558
Haiku 4.5 $0.00006 $0.00279

Measured 6d ago against content hash 459b8b4aacdc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

refactor 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 6d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/analyze-complexity.py, scripts/detect-smells.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

03-skills/refactor/SKILL.md · 435 lines

How it starts

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

Code Refactoring Skill

A systematic approach to refactoring code based on Martin Fowler's Refactoring: Improving the Design of Existing Code (2nd Edition). This skill emphasizes safe, incremental changes backed by tests.

"Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure." — Martin Fowler

Core Principles

  1. Behavior Preservation: External behavior must remain unchanged
  2. Small Steps: Make tiny, testable changes
  3. Test-Driven: Tests are the safety net
  4. Continuous: Refactoring is ongoing, not a one-time event
  5. Collaborative: User approval required at each phase

Workflow Overview

Phase 1: Research & Analysis
    ↓
Phase 2: Test Coverage Assessment
    ↓
Phase 3: Code Smell Identification
    ↓
Phase 4: Refactoring Plan Creation
    ↓
Phase 5: Incremental Implementation
    ↓
Phase 6: Review & Iteration

Phase 1: Research & Analysis

Objectives

  • Understand the codebase structure and purpose
  • Identify the scope of refactoring
  • Gather context about business requirements

Questions to Ask User

Before starting, clarify:

  1. Scope: Which files/modules/functions need refactoring?
  2. Goals: What problems are you trying to solve? (readability, performance, maintainability)
  3. Constraints: Are there any areas that should NOT be changed?
  4. Timeline pressure: Is this blocking other work?
  5. Test status: Do tests exist? Are they passing?

Actions

  • Read and understand the target code
  • Identify dependencies and integrations
  • Document current architecture
  • Note any existing technical debt markers (TODOs, FIXMEs)

Output

Present findings to user:

  • Code structure summary
  • Identified problem areas
  • Initial recommendations
  • Request approval to proceed

Phase 2: Test Coverage Assessment

Why Tests Matter

"Refactoring without tests is like driving without a seatbelt." — Martin Fowler

Read the full file on GitHub · 435 lines

Files

What ships with it

5 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. 6d ago First seen · 435 lines · 64 tokens per session scan A 459b8b4aacdc

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository luongnv89/claude-howto (41,371 stars, last pushed 3d ago), licensed MIT. It adds 64 tokens to every session and 2,789 once invoked, about $0.0003 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

docs-page

三栏文档页: 侧导航 + 正文 + 右 TOC.

nexu-io/html-anything · 20 tokens

tutorial-patterns

Tutorial and how-to guide patterns for progressive learning experiences. Covers Diátaxis tutorial/how-to structure, quickstart design, step-by-step walkthrough writing, anti-patterns, and progressive disclosure. Use proactively when writing tutorials, how-to guides, getting-started docs, or README files.

Everyone-Needs-A-Copilot/claude-copilot · 61 tokens

dg-piagent

Use when working with pi-agent / @earendil-works/pi-coding-agent SDK — 创建 agent、自定义工具、 编写扩展、修改系统提示词、管理会话、配置模型、处理认证、加载 skills/prompts/context files、 实现完全控制模式、或任何需要调用 pi-agent SDK API 的任务时使用。 也用于企业内网接口接入评估:用户给出企业/内网 LLM 接口文档或地址,问「能不能接」「怎么配」时, 按接口核对清单给出接入建议 + models.json 配置初稿。…

buchidonggua/dg-ai-notes · 205 tokens

frontmcp-config

Use when configuring a FrontMCP server through frontmcp.config or the @FrontMcp options. Covers auth modes (public, transparent, local, remote), OAuth plus credential vault and secureStore, CORS, HTTP port / entry-path prefix / unix socket, security headers (CSP, HSTS, X-Frame-Options, X-Content-Type-Options), rate…

agentfront/frontmcp · 187 tokens

frontmcp-auth-ui

Use when customizing, branding, or replacing the built-in FrontMCP OAuth pages (the login, consent, federated-select, incremental-authorization, and error pages) with your own React components. Covers the auth.ui slot-to-file map and auth.extras name-to-handler map on the auth config (no decorator, no class); the…

agentfront/frontmcp · 184 tokens

sketch-design

算子草图设计语言规范和生成指导,包含 UnifiedSketch DSL 语法和算子草图设计方法论.

mindspore-ai/akg · 30 tokens