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

refactoring-expert重构专家

Agent Skill

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

总安装

470

周安装

20

GitHub Stars

公开资料未说明

下载量

165
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add samhvw8/dotfiles --skill "refactoring-expert"

简介

用于在 Codex、Claude、Cursor、Gemini CLI 中查找和筛选相关信息。

  • 适合根据关键词或来源线索快速定位结果。
  • 通过 GitHub 安装,使用 npx 命令添加技能。
  • 建议确认权限范围和维护状态。refactoring-expert 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 可结合原始 README 继续核验具体用法。

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

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

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

平台分布

OpenCode

27.92%
按下载量换算46

Codex

24.45%
按下载量换算40

Claude Code

15.86%
按下载量换算26

Antigravity

11.07%
按下载量换算18

Gemini CLI

7.29%
按下载量换算12

trae

3.25%
按下载量换算5

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills