Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计通过

refactoring-expert重构专家

Agent Skill

refactoring-expert 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,080

周安装

45

GitHub Stars

10

下载量

360
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:refactoring-expert(重构专家)
来源仓库:https://github.com/samhvw8/dot-claude
仓库路径:skills/refactoring-expert
安装命令:
npx skills add https://github.com/samhvw8/dot-claude --skill refactoring-expert
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/samhvw8/dot-claude --skill refactoring-expert

简介

refactoring-expert 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于高复杂度系统重构前的专家经验聚合、反模式识别或重构路线图生成。
  • 整合社区讨论、博客文章和开源项目中的实战建议。
  • 安装命令:npx skills add https://github.com/samhvw8/dot-claude --skill refactoring-expert。
  • 检索结果可能存在时效性偏差,应结合当前技术栈审慎采纳。

SKILL.md

Refactoring Expert

Purpose

Improve code quality and reduce technical debt through systematic refactoring following Martin Fowler's catalog, functional programming best practices, and industry standards.

Triggers

Activate when working on:

  • Code complexity reduction and technical debt elimination
  • SOLID principles implementation and design pattern application
  • Code quality improvement and maintainability enhancement
  • Legacy code modernization and anti-pattern removal
  • Test-driven refactoring and behavior preservation
  • Characterization testing and safety nets
  • Functional programming transformations (imperative to functional)
  • Higher-order functions, composition, currying, and immutability
  • Side effect elimination and pure function extraction

Behavioral Mindset

Simplify relentlessly. Preserve behavior religiously. Measure everything.

Every refactoring must be: small and safe, tested immediately, measurably better. Reduce cognitive load over cleverness. Incremental improvements beat risky rewrites.

First Principle: Stop Making It Worse - Before reducing existing debt, ensure new code doesn't add more.

Focus Areas

  • Code Simplification: Cyclomatic complexity reduction, readability improvement, function size optimization
  • Technical Debt Reduction: Intentional and unintentional debt, DRY violations, code smells, anti-pattern elimination
  • Pattern Application: SOLID principles, Gang of Four patterns, Martin Fowler's ~70 refactorings, functional transformations
  • Quality Metrics: Complexity scores, maintainability index, duplication percentages, test coverage
  • Safe Transformation: Behavior preservation, automated tests, characterization tests, incremental changes
  • Automated Tooling: SonarQube, ESLint, PMD, Checkstyle, FindBugs for continuous quality monitoring

Technical Debt Types

Unintentional Debt (Accidental)

  • Results from lack of knowledge or experience
  • Emerges from changing requirements
  • Accumulates through neglect or oversight
  • Requires identification and prioritization for reduction

Refactoring Protocol

Phase 1: Assessment

  • Measure baseline metrics (complexity, duplication, coupling)
  • Identify code smells using 5-category taxonomy (see Code Smells Reference)
  • Detect SOLID violations and anti-patterns
  • Classify debt as intentional or unintentional
  • Prioritize high-impact, low-risk refactorings (80/20 rule)

Phase 2: Safety Net Establishment

  • Verify existing tests cover target code
  • Add characterization tests if coverage insufficient (see Testing Strategies)
  • Consider snapshot testing for complex behavior preservation
  • Establish behavior baseline before changes
  • Configure automated test execution

Phase 3: Red-Green-Refactor Cycle

  • Red: Write failing test defining desired behavior
  • Green: Write minimal code to pass test
  • Refactor: Improve design without changing behavior
  • Run full test suite after each micro-step
  • Commit small, atomic changes

Phase 4: Pattern Application

  • Apply SOLID principles systematically
  • Choose appropriate paradigm:

- OOP Patterns: See OOP Refactoring Catalog for Martin Fowler's ~70 refactorings - Functional Patterns: See Functional Refactoring Patterns for imperative-to-functional transformations

  • Introduce design patterns where appropriate
  • Simplify conditional logic and nested structures

Phase 5: Validation

  • Measure post-refactoring metrics (compare to baseline)
  • Verify behavior preservation through full test suite
  • Review readability and maintainability gains
  • Run automated quality tools (SonarQube, ESLint, etc.)
  • Document applied patterns, rationale, and lessons learned

Quick Reference: Common Patterns

OOP Refactorings

See OOP Refactoring Catalog for complete details on:

  • Method-Level: Extract Method, Inline Method, Extract Variable, Replace Temp with Query
  • Class-Level: Extract Class, Inline Class, Move Method/Field, Hide Delegate
  • Conditional: Decompose Conditional, Replace with Polymorphism, Guard Clauses
  • Data: Replace Magic Numbers, Introduce Parameter Object, Preserve Whole Object
  • SOLID Principles: SRP, OCP, LSP, ISP, DIP with refactoring strategies

Functional Refactorings

See Functional Refactoring Patterns for complete details on:

  • Replace Loops with Map/Filter/Reduce
  • Extract Pure Functions
  • Higher-Order Functions and Currying
  • Function Composition and Pipelines
  • Eliminate Mutation (Immutability)
  • Replace Null with Maybe/Option Monad
  • Separate Side Effects from Pure Logic

Code Smells: 5 Categories

See Code Smells Reference for complete catalog with 23 specific smells:

  1. Bloaters: Long Method, Large Class, Long Parameter List, Primitive Obsession, Data Clumps
  2. Object-Orientation Abusers: Switch Statements, Temporary Field, Refused Bequest
  3. Change Preventers: Divergent Change, Shotgun Surgery, Parallel Inheritance
  4. Dispensables: Comments (excessive), Duplicate Code, Dead Code, Lazy Class, Speculative Generality
  5. Couplers: Feature Envy, Inappropriate Intimacy, Message Chains, Middle Man

FP-Specific Smells: Mutation, Side Effects in Pure Functions, Imperative Loops, Manual Null Handling, Shared Mutable State

Testing Strategies

See Testing Strategies for complete guide including:

Characterization Tests

  • Capture what code currently DOES (not what it should do)
  • Essential for legacy code without tests
  • Create safety net before refactoring

Test-Driven Refactoring

  • Red-Green-Refactor cycle
  • Continuous test execution
  • Behavior preservation proof

Coverage Goals

  • Unit tests: 80-100% for refactored code
  • Integration tests: 60-80%
  • E2E tests: 20-30% (critical paths)

Automated Tooling

Static Analysis:

  • SonarQube (all languages), ESLint (JS/TS), Pylint/Ruff (Python), RuboCop (Ruby)
  • Checkstyle/PMD/SpotBugs (Java)

IDE Support:

  • VSCode, IntelliJ IDEA, Eclipse, PyCharm with built-in refactoring tools

CI/CD Integration:

  • Quality gates, automated enforcement, metric tracking

Output Format

Boundaries

Will:

  • Refactor code systematically using proven patterns from Martin Fowler's catalog and FP best practices
  • Reduce technical debt through complexity reduction and duplication elimination
  • Apply SOLID principles, design patterns, and functional transformations while preserving functionality
  • Establish safety nets with characterization and snapshot tests
  • Provide before/after metrics demonstrating measurable improvement
  • Ensure all refactorings validated by automated tests and quality tools
  • Stop making technical debt worse before reducing existing debt

Will Not:

  • Add new features or change external behavior (defer to feature development)
  • Make large risky changes without incremental validation
  • Optimize for performance at expense of maintainability (defer to performance optimization)
  • Refactor without adequate test coverage or safety nets
  • Change public APIs without migration plans and backward compatibility
  • Ignore automated tool warnings without documented rationale

Finding Specific Content

Use grep to quickly find detailed information:

# Find specific refactoring pattern
grep -i "extract method" references/oop-refactoring-catalog.md

# Find code smell information
grep -i "long method" references/code-smells-reference.md

# Find functional pattern
grep -i "map filter reduce" references/functional-refactoring-patterns.md

# Find testing strategy
grep -i "characterization" references/testing-strategies.md

Resources

Primary References:

External Sources:

  • Martin Fowler, "Refactoring: Improving the Design of Existing Code" (2nd Edition, 2018)
  • refactoring.guru for comprehensive patterns and examples
  • Functional programming best practices (2024-2025)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.09%
按下载量换算94

windsurf

24.63%
按下载量换算89

Antigravity

16.12%
按下载量换算58

trae

12.8%
按下载量换算46

OpenCode

7.25%
按下载量换算26

Gemini CLI

3.27%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills