large-repo-refactor

large-repo-refactor is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 33 tokens per session (2,876 once invoked), scanned A, original, MIT.

A set of rules for safely restructuring large or older codebases without changing what they do.

In plain words
What is it for?
Use it when renaming, moving, splitting, or reorganizing code across many files, or when gradually moving to a new architecture.
Why use it?
It reduces the risk of hidden behavior changes by requiring tests, small steps, and easy-to-reverse commits.

Skill for Claude CodeCodex

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

Good fit Use it when renaming, moving, splitting, or reorganizing code across many files, or when gradually moving to a new architecture.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor
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 Wade-DevCode/awesome-coding-skills-cn --skill large-repo-refactor
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

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 large-repo-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor/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 large-repo-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/large-repo-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,876 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.00033 $0.02876
Opus 5.5 $0.00013 $0.01150
Sonnet 5.5 $0.00007 $0.00575
Haiku 4.5 $0.00003 $0.00288

Measured 3mo ago against content hash 262bc9426123, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

large-repo-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 3mo 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/large-repo-refactor/SKILL.md · 161 lines

How it starts

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

大仓库重构

何时用

  • 需要对大型或老代码库做结构性调整:抽函数、移动模块、重命名、拆分大文件。
  • 已有功能运行正常,但代码组织混乱、可读性差,需要在不改变外部行为的前提下清理内部结构。
  • 接到"把这个模块重构一下"或"把这些文件整理整理"的任务,改动会波及多个文件或多处调用方。
  • 团队准备迁移到新架构,需要分阶段、可回退地把现有代码逐步搬过去。

核心规则

1. 先立测试护栏

规则: 确认关键路径有测试覆盖再动手重构;若测试不存在或覆盖不足,先补特征测试(characterization test)锁住当前行为,再开始结构调整。

为什么: AI 做重构时最常见的事故不是"改错了逻辑",而是"改完觉得没问题,其实已经悄悄改变了行为"。没有测试护栏,重构后的代码和重构前的代码在输入输出上是否完全一致,只能靠肉眼比对,这在大仓库里几乎不可能做到。特征测试的目的不是验证"代码应该做什么",而是记录"代码现在实际做什么"——包括那些可能是 bug 的行为,先把它们冻结下来,重构完再讨论要不要修。

怎么做:

  • 重构前先跑现有测试套件,确认全部通过,建立基准绿灯。
  • 找出重构目标的关键输入输出(函数签名、HTTP 响应、数据库写入格式),用现有输出写断言,不是写"预期应该怎样"而是写"现在实际是怎样"。
  • 特征测试不需要优雅,只需要覆盖:把现有行为的真实输出直接复制进断言,宁可多写几个边界用例。
  • 补完测试,跑一遍确认全绿,再切到重构任务。

2. 行为不变原则

规则: 重构只允许改代码结构,不允许同时改外部可见行为;每完成一个重构步骤立刻跑测试,确认行为与改前完全一致。

为什么: AI 在重构时极容易把"顺手改进逻辑"和"结构调整"混在一起——改参数顺序"因为这样更合理",修掉一个"顺眼的边界条件",调整返回值结构"更符合最佳实践"。每一处单独看都是好意,但混在重构里有两个危险:一,下游调用方可能依赖这个"不合理"的行为;二,一旦测试挂掉,无法判断是结构改动破坏的还是逻辑改动破坏的。重构和行为修改必须是两次独立的提交。

怎么做:

  • 每个重构步骤结束后立刻跑测试,不要攒几步再跑。
  • 若发现现有代码有 bug 或值得改进的逻辑,记录下来,不在当前重构 PR 里动,单独开任务处理。
  • 提交信息中明确写"refactor: 只改结构,行为不变",让 reviewer 知道这一步不含逻辑变更,可以用更轻量的方式审查。
  • 若测试挂掉,先还原到上一步绿灯状态,找出哪一处结构改动影响了行为,再修正,不要在挂掉状态下继续推进。

3. 单一变换,每步可独立回退

规则: 每次提交只做一种重构操作——改名就只改名,抽函数就只抽函数,移动文件就只移动文件;绝不在同一个提交里混合多种变换。

为什么: AI 被要求"重构这个模块"时,会倾向于一口气生成"改完的最终状态":函数名换了、目录结构调了、逻辑抽象层加了、import 路径更新了——全在一个 diff 里。这类大爆炸式提交在代码 review 时几乎无法有效审查,出问题时更无从用 git bisect 定位。出了问题只能整体回滚,等于白做。单一变换的核心价值是:每一步都可以被精确撤销,问题定位可以缩到一次提交粒度。

怎么做:

  • 把重构计划拆成操作列表,每条对应一个提交:
    步骤 1: 把 processOrder 里的金额计算逻辑抽成 calculateAmount 函数
    步骤 2: 把 calculateAmount 移到 src/domain/pricing.ts
    步骤 3: 将所有调用方的 import 路径更新为新路径
    步骤 4: 把 processOrder 重命名为 handleOrderSubmission
    
  • 每步提交前跑测试确认绿灯,再提交,再进行下一步。
  • 若某步执行中发现需要同时改另一件事,先把当前步骤提交或暂存,再另起一个步骤。

4. 自动化优先,不手动批量改

规则: 能用 IDE 重构工具、代码迁移脚本(codemod)、语言服务器安全执行的重构,不要用手写替换或正则批量改;手改正则是大仓库重构引入 bug 的重灾区。

为什么: AI 遇到"把全仓库 500 处 getUserById 改名成 findUserById"时,最容易的做法是写个正则替换脚本或直接生成修改后的文件列表。问题是:正则不理解语法,会改到字符串字面量、注释、不同作用域下同名但含义不同的函数;手工批量替换会跳过动态调用(obj[methodName]())、装饰器、反射场景。IDE 的语言感知重命名会处理这些边界情况,而 AI 生成的正则脚本几乎不会。

Read the full file on GitHub · 161 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. 3mo ago First seen · 161 lines · 33 tokens per session scan A 262bc9426123

Subscribe to this mod's changes

large-repo-refactor is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 5mo ago), licensed MIT. It adds 33 tokens to every session and 2,876 once invoked, about $0.0001 per session on Opus 5.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

large-repo-refactor compared with skills from other repositories

large-repo-refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
large-repo-refactorWade-DevCode/awesome-coding-skills-cnSkill75mo agoMITA33Claude Code, Codex
executing-plansjnMetaCode/superpowers-zhSkill8.6k15d agoMITA46Claude Code
chinese-git-workflowjnMetaCode/superpowers-zhSkill8.6k15d agoMITA69Claude Code
chinese-code-reviewjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code
chinese-commit-conventionsjnMetaCode/superpowers-zhSkill8.6k15d agoMITA65Claude Code
chinese-documentationjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code
systematic-debuggingjnMetaCode/superpowers-zhSkill8.6k15d agoMITA24Claude Code