Tech Debt Analyzer
ailabs-393/ai-labs-claude-skills
This skill should be used when analyzing technical debt in a codebase, documenting code quality issues, creating technical debt registers, or assessing code maintainability.
Walks through code refactoring in phases you confirm, following Martin Fowler's method: research, test check, smell detection, planning and small safe steps.
SKILL.md written in Chinese; this summary is our English description.
$ npx skills add luongnv89/claude-howto --skill refactor -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install luongnv89/claude-howto refactor --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .claude/skills && cp -r skills-src/zh/03-skills/refactor .claude/skills/refactor && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .claude/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactorType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add luongnv89/claude-howto --skill refactor -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install luongnv89/claude-howto refactor --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .agents/skills && cp -r skills-src/zh/03-skills/refactor .agents/skills/refactor && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .agents/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add luongnv89/claude-howto --skill refactor -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install luongnv89/claude-howto refactor --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/zh/03-skills/refactor .cursor/skills/refactor && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .cursor/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/luongnv89/claude-howto.git --path zh/03-skills/refactor--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add luongnv89/claude-howto --skill refactor -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install luongnv89/claude-howto refactor --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/zh/03-skills/refactor .gemini/skills/refactor && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .gemini/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install luongnv89/claude-howto refactorInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add luongnv89/claude-howto --skill refactor -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .github/skills && cp -r skills-src/zh/03-skills/refactor .github/skills/refactor && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .github/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add luongnv89/claude-howto --skill refactor -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install luongnv89/claude-howto refactor --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/luongnv89/claude-howto.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/zh/03-skills/refactor .opencode/skills/refactor && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "refactor" agent skill from https://github.com/luongnv89/claude-howto/tree/main/zh/03-skills/refactor into .opencode/skills/refactor/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "refactor", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
refactorWalks through code refactoring in phases you confirm, following Martin Fowler's method: research, test check, smell detection, planning and small safe steps.
The skill follows Martin Fowler's approach to refactoring: keep external behavior unchanged, make small testable changes, use tests as the safety net, treat refactoring as ongoing work and get your confirmation at each phase. Phase one asks about scope, goals, constraints, time pressure and test status, reads the code, notes dependencies and TODO or FIXME debt markers, and asks for approval before continuing.
Phase two looks for existing tests, runs them and checks coverage. If tests are missing, the agent offers to write them first, to add them along the way or to continue at your risk, and it stops when tests fail. Phase three scans for code smells such as long functions, duplicated code, large classes, long parameter lists and dead code, ranks them by severity and asks you to confirm priorities. Phase four picks refactorings from a catalog and builds a plan. Reference files hold the smell and refactoring catalogs and a template holds the plan; the excerpt ends in phase four.
5 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 556af8d. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmpytestpythonmvnFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Systematic Code Refactoring loads about 1.5k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 32 tokens; SKILL.md has 441 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from luongnv89/claude-howto at commit 556af8d, republished under its MIT licence (© luongnv89). 441 words, ~1,505 tokens.
.claude/skills/refactor/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.这是一个基于 Martin Fowler《Refactoring: Improving the Design of Existing Code》(第 2 版)的系统化代码重构方法。这个 skill 强调安全、渐进的修改,并由测试提供保障。
“重构是在不改变软件外部行为的前提下,改进其内部结构的过程。” — Martin Fowler
阶段 1:研究与分析
↓
阶段 2:测试覆盖评估
↓
阶段 3:识别代码异味
↓
阶段 4:创建重构计划
↓
阶段 5:增量实施
↓
阶段 6:评审与迭代开始前先确认:
向用户汇报:
“没有测试的重构,就像没有安全带就开车。” — Martin Fowler
测试是安全重构的关键前提。没有测试,很容易引入 bug。
检查现有测试
# 查找测试文件
find . -name "*test*" -o -name "*spec*" | head -20运行现有测试
# JavaScript / TypeScript
npm test
# Python
pytest -v
# Java
mvn test检查覆盖率(如果可用)
# JavaScript
npm run test:coverage
# Python
pytest --cov=.如果测试存在且通过:
如果测试缺失或不完整: 给出选项:
如果测试失败:
对每个要重构的函数,测试应覆盖:
使用“红-绿-重构”循环:
代码深层问题的表面症状。它们不一定是 bug,但说明代码设计可能有问题。
完整目录见 references/code-smells.md。
| 异味 | 迹象 | 影响 |
|---|---|---|
| 长函数 | 函数超过 30-50 行 | 难以理解、测试和维护 |
| 重复代码 | 多处出现相同逻辑 | 修复需要改多处 |
| 大类 | 类承担了太多职责 | 违反单一职责原则 |
| Feature Envy | 一个方法更多依赖别的类的数据 | 封装性差 |
| 基础类型沉迷 | 过度使用基础类型而不是对象 | 缺少领域概念 |
| 长参数列表 | 方法参数超过 4 个 | 调用困难 |
| 数据泥团 | 一组数据总是一起出现 | 缺少抽象 |
| switch 语句 | 复杂的 switch / if-else 链 | 难以扩展 |
| 臆想泛化 | “以防未来需要”提前设计 | 不必要的复杂度 |
| 死代码 | 未使用的代码 | 造成困惑和维护负担 |
自动分析(如果有脚本)
python scripts/detect-smells.py <file>人工审查
优先级排序 优先关注会:
向用户呈现:
针对每个异味,从目录中选择合适的重构手法。
完整列表见 references/refactoring-catalog.md。
| 代码异味 | 推荐重构 |
|---|---|
| 长函数 | Extract Method、Replace Temp with Query |
| 重复代码 | Extract Method、Pull Up Method、Form Template Method |
| 大类 | Extract Class、Extract Subclass |
| Feature Envy | Move Method、Move Field |
| 基础类型沉迷 | Replace Primitive with Object、Replace Type Code with Class |
| 长参数列表 | Introduce Parameter Object、Preserve Whole Object |
| 数据泥团 | Extract Class、Introduce Parameter Object |
| switch 语句 | Replace Conditional with Polymorphism |
| 臆想泛化 | Collapse Hierarchy、Inline Class、Remove Dead Code |
| 死代码 | Remove Dead Code |
使用 templates/refactoring-plan.md 里的模板。
每项重构都要写明:
关键:重构必须分阶段推进。
阶段 A:快速收益(低风险,高价值)
阶段 B:结构改进(中风险)
阶段 C:架构改动(高风险)
在开始实施前:
“修改 → 测试 → 通过?→ 提交 → 下一步”
对每一步重构:
预检查
只做一个小改动
验证
如果测试通过(绿色)
如果测试失败(红色)
每次提交都应当:
示例提交信息:
refactor: 从 processOrder() 中提取 calculateTotal()
refactor: 将 'x' 重命名为 'customerCount' 以提升清晰度
refactor: 删除未使用的 validateOldFormat() 方法每个子阶段完成后,向用户汇报:
重构前后运行复杂度分析:
python scripts/analyze-complexity.py <file>展示改进:
向用户展示最终结果:
和用户讨论:
遇到以下情况时,务必暂停并和用户确认:
重构前:
function processOrder(order) {
// 150 行代码,包含:
// - 重复验证逻辑
// - 内联计算
// - 多种职责混杂
}重构步骤:
processOrder()validateOrder()calculateOrderTotal()notifyCustomer()processOrder() 现在只负责串联 3 个清晰函数重构后:
function processOrder(order) {
validateOrder(order);
const total = calculateOrderTotal(order);
notifyCustomer(order, total);
return { order, total };
}scripts/analyze-complexity.py - 分析代码复杂度指标scripts/detect-smells.py - 自动检测 code smell© luongnv89, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 3 other files (references) in zh/03-skills/refactor of luongnv89/claude-howto.
Open the folder on GitHubat commit 556af8d
Systematic Code Refactoring next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Systematic Code Refactoring this skillluongnv89/claude-howto | 42k | — | ~1.5k | Automated safety check: Pass | MIT | |
| Tech Debt Analyzerailabs-393/ai-labs-claude-skills | 454 | 2 repos | ~3.9k | Automated safety check: Pass | MIT | |
| FIXME Resolvertailcallhq/forgecode | 7.6k | — | ~1.1k | Automated safety check: Pass | Apache-2.0 | |
| DesloppifyGit-on-my-level/codex-autorunner | 875 | — | ~3.4k | Automated safety check: Pass | MIT | |
| Code Quality Gatefengshao1227/ccg-workflow | 5.9k | — | ~593 | Automated safety check: Notes | MIT | |
| Smell CheckZhen-Bo/smell-check | 239 | — | ~1.5k | Automated safety check: Pass | MIT |
ailabs-393/ai-labs-claude-skills
This skill should be used when analyzing technical debt in a codebase, documenting code quality issues, creating technical debt registers, or assessing code maintainability.
tailcallhq/forgecode
Finds every FIXME comment in a codebase, groups related ones across files into one task, implements the work they describe and removes the comments once it is done.
Git-on-my-level/codex-autorunner
Codebase health scanner and technical debt tracker. An agent skill from Git-on-my-level/codex-autorunner.
fengshao1227/ccg-workflow
Scans code for complexity, long functions, duplicated blocks, naming problems and code smells with a Node script, then reports and suggests refactors.
Zhen-Bo/smell-check
Runs a smell-first audit on a user-chosen path set: measures structure metrics, applies a named size profile, and reports code smells and test smells with evidence strength.
kucherenko/jscpd
A three-part cleanup guided by jscpd: measure health, then fix duplicated code, remove dead code and simplify the most complex files, finishing by re-measuring the score.
luongnv89/claude-howto
Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.
luongnv89/claude-howto
Guides systematic, test-backed refactoring in the style of Martin Fowler, moving through research, planning and small incremental changes with your approval at each phase.
luongnv89/claude-howto
Guides drafting a blog post from an idea and optional source material: research, brainstorming, outlining and version-tracked drafts, with user approval at each step.
luongnv89/claude-howto
Ensure all communication matches brand voice and tone guidelines. Use when creating marketing copy, customer communications, public-facing content, or when…
luongnv89/claude-howto
Reviews code for security, performance, quality and maintainability, using a checklist, a finding template and two metrics scripts.
luongnv89/claude-howto
Runs a quick or deep quiz on Claude Code skills, scores ten feature areas and generates a personalized learning path with prioritized next steps.
Categories
Walks through code refactoring in phases you confirm, following Martin Fowler's method: research, test check, smell detection, planning and small safe steps. The skill follows Martin Fowler's approach to refactoring: keep external behavior unchanged, make small testable changes, use tests as the safety net, treat refactoring as ongoing work and get your confirmation at each phase. Phase one asks about scope, goals, constraints, time pressure and test status, reads the code, notes dependencies and TODO or FIXME debt markers, and asks for approval before continuing.
Systematic Code Refactoring fits situations like: refactoring a module that has grown hard to maintain; cleaning up code smells before adding a new feature; reducing technical debt in steps you approve at each phase.
Run `npx skills add luongnv89/claude-howto --skill refactor -a claude-code`. Or copy the skill folder (zh/03-skills/refactor in luongnv89/claude-howto) into .claude/skills/refactor in your project. Claude Code loads it when a task matches its description.
Run `npx skills add luongnv89/claude-howto --skill refactor -a codex`. Or copy the skill folder (zh/03-skills/refactor in luongnv89/claude-howto) into .agents/skills/refactor in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add luongnv89/claude-howto --skill refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/refactor, .gemini/skills/refactor, .github/skills/refactor and .opencode/skills/refactor in your project.
Going by SKILL.md and its folder, Systematic Code Refactoring needs the command-line tools its instructions call (npm, pytest, python and mvn).
SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Systematic Code Refactoring is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 9.1k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Systematic Code Refactoring: Tech Debt Analyzer (ailabs-393/ai-labs-claude-skills, 454 stars), FIXME Resolver (tailcallhq/forgecode, 7.6k stars), Desloppify (Git-on-my-level/codex-autorunner, 875 stars) and Code Quality Gate (fengshao1227/ccg-workflow, 5.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
luongnv89 (a GitHub user) maintains it in luongnv89/claude-howto, which has 41,769 GitHub stars. The repository holds 25 skills in this directory. The repository was last updated on September 30, 2026.
Source: luongnv89/claude-howto on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.