backend-skill: Skill for Claude Code

.claude/skills/proj-refactor/SKILL.md

proj-refactor is a skill for Claude Code from zhangloveyan/backend-skill. It costs 31 tokens per session (1,217 once invoked), scanned A, original, MIT.

A guide to improving existing code through common refactoring patterns. Refactoring changes the structure of code without changing what it is meant to do.

In plain words
What is it for?
Use it when cleaning up difficult code, removing repeated or poorly structured parts, or improving code quality.
Why use it?
It helps remove code problems and make the structure easier to understand and maintain.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is zhangloveyan/backend-skill's own configuration. It tells Claude Code how to work on backend-skill itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything backend-skill configures →

Reuse

Borrowing it

Nothing to install: this file belongs to zhangloveyan/backend-skill. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/zhangloveyan/backend-skill/main/.claude/skills/proj-refactor/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/zhangloveyan/backend-skill

Made for: Claude Code.

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 proj-refactor

README.md
[![agentmods](https://agentmods.dev/badge/skills/zhangloveyan/backend-skill/proj-refactor/github.svg)](https://agentmods.dev/skills/zhangloveyan/backend-skill/proj-refactor)
Your own site
<a href="https://agentmods.dev/skills/zhangloveyan/backend-skill/proj-refactor"><img src="https://agentmods.dev/badge/skills/zhangloveyan/backend-skill/proj-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 proj-refactor

Your own site · 80×15
<a href="https://agentmods.dev/skills/zhangloveyan/backend-skill/proj-refactor"><img src="https://agentmods.dev/badge/skills/zhangloveyan/backend-skill/proj-refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,217 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.00031 $0.01217
Opus 5.5 $0.00012 $0.00487
Sonnet 5.5 $0.00006 $0.00243
Haiku 4.5 $0.00003 $0.00122

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

Security

Grade A, and why

proj-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 2mo 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.

.claude/skills/proj-refactor/SKILL.md · 211 lines

How it starts

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

代码重构

适用场景

  • 代码质量改善
  • 消除代码坏味道
  • 优化代码结构
  • 提高可维护性

重构流程

Step 0: 校验任务文档 → Step 1: 识别问题 → Step 2: 确定范围 → Step 3: 编写测试 → Step 4: 小步重构 → Step 5: 验证

Step 0: 校验任务文档

  • 确认全流程任务文档存在
  • 若缺失,先创建任务文档骨架并补齐流程状态与上下文快照
  • 在上下文快照记录“重构中”与一句话范围说明

重构原则

  1. 小步前进 - 每次只做一个小改动
  2. 保持功能 - 重构不改变外部行为
  3. 测试保障 - 有测试覆盖再重构
  4. 及时提交 - 每个小步骤后提交

同步任务文档:

  • 产物清单记录相关测试/报告路径(如有)
  • 更新下一步指令为“验证/继续开发”

常见代码坏味道

1. 过长方法

问题: 方法超过 50 行

重构方法: 提取方法

// ✗ 重构前
public void processOrder(Order order) {
    // 50+ 行代码...
}

// ✓ 重构后
public void processOrder(Order order) {
    validateOrder(order);
    calculatePrice(order);
    saveOrder(order);
    sendNotification(order);
}

2. 过大类

问题: 类超过 500 行,职责过多

重构方法: 提取类

// ✗ 重构前
public class UserService {
    // 用户管理 + 订单管理 + 支付管理...
}

// ✓ 重构后
public class UserService { /* 用户管理 */ }
public class OrderService { /* 订单管理 */ }
public class PaymentService { /* 支付管理 */ }

3. 重复代码

问题: 相同代码出现多处

重构方法: 提取公共方法

// ✗ 重构前
public void methodA() {
    // 重复代码块
}
public void methodB() {
    // 重复代码块
}

// ✓ 重构后
private void commonMethod() {
    // 公共代码块
}
public void methodA() {
    commonMethod();
}
public void methodB() {
    commonMethod();
}

4. 过长参数列表

问题: 方法参数超过 4 个

重构方法: 引入参数对象

// ✗ 重构前
public void createUser(String name, String phone, String email,
                       String address, Integer age, Integer status) {}

// ✓ 重构后
public void createUser(UserCreateRequest request) {}

5. 魔法值

问题: 硬编码的数字或字符串

重构方法: 提取常量或枚举

// ✗ 重构前
if (status == 1) { }
if (type.equals("VIP")) { }

// ✓ 重构后
if (status == StatusEnum.ENABLE.getCode()) { }
if (type.equals(UserType.VIP)) { }

6. 过深嵌套

问题: if/for 嵌套超过 3 层

重构方法: 提前返回、提取方法

// ✗ 重构前
public void process(User user) {
    if (user != null) {
        if (user.isEnabled()) {
            if (user.hasPermission()) {
                // 业务逻辑
            }
        }
    }
}

// ✓ 重构后
public void process(User user) {
    if (user == null) return;
    if (!user.isEnabled()) return;
    if (!user.hasPermission()) return;
    // 业务逻辑
}

Read the full file on GitHub · 211 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. 2mo ago First seen · 211 lines · 31 tokens per session scan A 49bdf700ce94

Subscribe to this mod's changes

proj-refactor is a skill published in the GitHub repository zhangloveyan/backend-skill (103 stars, last pushed 23d ago), licensed MIT. It adds 31 tokens to every session and 1,217 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-30.

Related

proj-refactor compared with skills from other repositories

proj-refactor next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
proj-refactorzhangloveyan/backend-skillSkill10323d agoMITA31Claude Code
systematic-debuggingopen-metadata/OpenMetadataSkill16kyesterdayApache-2.0A37Claude Code
log-error-digestzebbern/claude-code-guideSkill4.7k3d agoMITA71Claude Code, Codex
cwv-optimizeradobe/skillsSkill319yesterdayApache-2.0A112Claude Code
ci-fixersipyourdrink-ltd/bernsteinSkill1.2kyesterdayApache-2.0A15Claude Code, Codex
incident-response-incident-responsermyndharis/antigravity-skillsSkill1.9k23d agoMITA36Claude Code
triaging-web-analytics-supportPostHog/posthogSkill41kyesterdaynoneA151Claude Code, Codex