metago-refactor-suggest

metago-refactor-suggest is a skill for Claude Code, Codex from metago-ai/metagolifeform. It costs 74 tokens per session (1,321 once invoked), scanned A, original, MIT.

A code-refactoring guide that finds common code problems, measures technical debt, and suggests ordered changes while aiming to keep the program’s behaviour the same.

In plain words
What is it for?
Use it to review code smells, complexity, dependencies, and possible refactorings such as splitting long functions or removing duplicated code.
Why use it?
It helps turn vague maintenance work into specific, prioritised tasks and highlights where changes may affect other code.

Skill for Claude CodeCodex

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

Good fit Use it to review code smells, complexity, dependencies, and possible refactorings such as splitting long functions or removing duplicated code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/metago-ai/metagolifeform/metago-refactor-suggest
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 metago-ai/metagolifeform --skill metago-refactor-suggest
Clone the repo
git clone --depth 1 https://github.com/metago-ai/metagolifeform

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 metago-refactor-suggest

README.md
[![agentmods](https://agentmods.dev/badge/skills/metago-ai/metagolifeform/metago-refactor-suggest/github.svg)](https://agentmods.dev/skills/metago-ai/metagolifeform/metago-refactor-suggest)
Your own site
<a href="https://agentmods.dev/skills/metago-ai/metagolifeform/metago-refactor-suggest"><img src="https://agentmods.dev/badge/skills/metago-ai/metagolifeform/metago-refactor-suggest/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for metago-refactor-suggest

Your own site · 80×15
<a href="https://agentmods.dev/skills/metago-ai/metagolifeform/metago-refactor-suggest"><img src="https://agentmods.dev/badge/skills/metago-ai/metagolifeform/metago-refactor-suggest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,321 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.00074 $0.01321
Opus 5 $0.00037 $0.00660
Sonnet 5 $0.00015 $0.00264
Haiku 4.5 $0.00007 $0.00132

Measured 12d ago against content hash 4b12de70182c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

metago-refactor-suggest 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 12d 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.

packages/dev-kit/skills/metago-refactor-suggest/SKILL.md · 117 lines

How it starts

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

重构建议(metago-refactor-suggest)

描述

检测代码异味、量化技术债务、识别重构机会,生成含优先级和影响范围的重构方案。遵循行为保持变换(Behavior Preservation)原则,确保重构不改变外部行为。

触发条件

  • 用户请求重构、代码优化、技术债务评估时激活
  • 代码审查发现可维护性问题时联动触发
  • 定期技术债务盘点
  • metago-code-review-deep 协同:审查发现 Minor/Major 问题时触发

核心流程

1. 代码异味检测

  • 长函数(行数 > 阈值,默认 50 行)
  • 大类(字段/方法数 > 阈值)
  • 重复代码(相似度 > 80%)
  • 过长参数列表(参数数 > 5)
  • 发散式修改(一个类因多个原因修改)
  • 霰弹式修改(一个修改引发多处变更)
  • 特性依恋(方法调用大量其他类)
  • 数据泥团(多个变量总是一起出现)

2. 复杂度量分析

  • 圈复杂度(Cyclomatic Complexity)> 10 需重构
  • 认知复杂度(Cognitive Complexity)> 15 需重构
  • 继承深度(DIT)> 4 需关注
  • 耦合度(CBO)> 10 需优化

3. 依赖分析

  • 循环依赖检测
  • 不稳定依赖(依赖不稳定模块)
  • 上层依赖下层(违反依赖倒置)
  • 过度耦合(一个模块依赖过多模块)

4. 重构机会识别

异味类型 推荐重构手法 优先级 影响范围
长函数 Extract Method 函数级
重复代码 Extract Method / Pull Up Method 类级
大类 Extract Class 模块级
过长参数 Introduce Parameter Object 函数级
特性依恋 Move Method 类级
循环依赖 Extract Class / Move Method 模块级

5. 重构方案生成

  • 重构步骤分解(原子化操作)
  • 行为保持验证(测试覆盖要求)
  • 风险评估(回归概率)
  • 前后对比(复杂度、可读性、可维护性指标)

输出格式

【重构建议报告】

## 1. 技术债务概览
债务等级:🟢 低 / 🟡 中 / 🔴 高
债务量化:预估 N 人天
热点模块:path/to/module

## 2. 代码异味清单
| # | 异味 | 位置 | 严重度 | 推荐手法 |
|---|------|------|--------|----------|
| 1 | 长函数(85行) | file.ext:L10-L95 | 🟡 Major | Extract Method |
| 2 | 重复代码(92%相似) | file.ext:L20 / file2.ext:L15 | 🔴 Critical | Extract Method |
| ... | ... | ... | ... | ... |

## 3. 重构方案(按优先级排序)

### 方案1:[重构名称]
- 目标:...
- 步骤:
  1. ...
  2. ...
  3. ...
- 测试要求:覆盖率达 X%
- 风险评估:低 / 中 / 高
- 预期收益:复杂度 15→8,可读性 +40%

### 方案2:...

## 4. 重构前后对比
| 指标 | 重构前 | 重构后 | 改善 |
|------|--------|--------|------|
| 圈复杂度 | 18 | 6 | -67% |
| 重复率 | 35% | 5% | -86% |
| 可维护性 | 4.2/10 | 8.1/10 | +93% |

## 5. 建议执行顺序
1. 先补充测试(当前覆盖率 X%)
2. 执行方案1(低风险高收益)
3. 执行方案2(...)

与其他技能的协同

  • metago-code-review-deep 协同:审查发现可维护性问题时触发重构建议
  • metago-coupling-optimize 协同:耦生度量化指导重构优先级
  • metago-critique 协同:重构方案需通过批判性分析
  • metago-decision-lock 协同:重构执行前需通过决策锁校验
  • metago-fact-check 协同:验证重构前后行为一致性

Read the full file on GitHub · 117 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. 12d ago First seen · 117 lines · 74 tokens per session scan A 4b12de70182c

Subscribe to this mod's changes

metago-refactor-suggest is a skill published in the GitHub repository metago-ai/metagolifeform (4 stars, last pushed 10d ago), licensed MIT. It adds 74 tokens to every session and 1,321 once invoked, about $0.0004 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.