Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

refactoring-analysis重构分析

Agent Skill

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

总安装

1,717

周安装

73

GitHub Stars

323

下载量

602
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/pedronauck/skills --skill refactoring-analysis

简介

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

  • 适用于重构前的技术债评估、复杂度指标计算或耦合度分析报告生成。
  • 支持从代码库中提取度量数据并与历史版本进行趋势对比。
  • 安装命令:npx skills add https://github.com/pedronauck/skills --skill refactoring-analysis。
  • 需明确分析范围和时间窗口,防止扫描过大影响性能或遗漏关键模块。

SKILL.md

Refactoring Analysis

Perform a systematic analysis of a codebase to identify refactoring opportunities based on Martin Fowler's "Refactoring: Improving the Design of Existing Code" (2nd Edition). Produce a prioritized report with actionable findings.

Procedures

Step 1: Scope the Analysis

  1. Determine the analysis target — a specific directory, module, feature area, or the entire project. If the user did not specify, ask which area to focus on.
  2. Identify the project's language and paradigm (OOP, functional, mixed) to calibrate which smells and techniques are applicable.
  3. If the project follows domain-driven design (DDD) or hexagonal architecture, read references/solid-ddd-context.md for additional SOLID-specific analysis criteria.

Step 2: Explore the Codebase

  1. Map the directory structure and identify key modules, entry points, and shared utilities.
  2. Read the most critical files (entry points, core business logic, shared modules).
  3. Identify the project's conventions: naming, file organization, test patterns, dependency injection approach.

Step 3: Detect Code Smells

Read references/code-smells-catalog.md for the full catalog of detectable smells.

Systematically scan for the following smell categories, in priority order:

  1. Bloaters — Long Functions (>15 lines of logic), Large Classes/Modules (>300 lines), Long Parameter Lists (>3 params), Data Clumps, Primitive Obsession.
  2. Change Preventers — Divergent Change (one module changed for multiple unrelated reasons), Shotgun Surgery (one change touches 5+ files).
  3. Dispensables — Duplicated Code, Dead Code, Speculative Generality, Lazy Elements, Comments as Deodorant.
  4. Couplers — Feature Envy, Insider Trading (excessive data sharing between modules), Message Chains (>2 levels deep), Middle Man (>50% delegation).
  5. Conditional Complexity — Nested Conditionals (>2 levels), Repeated Switches, Missing Guard Clauses, Complex Boolean Expressions.
  6. DRY Violations — Near-identical code blocks, copy-pasted logic with minor variations, repeated parameter groups, duplicated constants or magic numbers.

For each detected smell:

  • Record the exact file path and line range
  • Classify the smell type (from the catalog)
  • Assess severity: critical | high | medium | low
  • Note the impact on maintainability, readability, or change cost

Step 4: Map Refactoring Opportunities

Read references/refactoring-techniques.md for the full technique catalog.

For each detected smell, identify the recommended refactoring technique(s):

SmellPrimary Technique
Long FunctionExtract Function, Decompose Conditional
Duplicated CodeExtract Function, Pull Up Method
Long Parameter ListIntroduce Parameter Object, Preserve Whole Object
Feature EnvyMove Function
Data ClumpsExtract Class, Introduce Parameter Object
Primitive ObsessionReplace Primitive with Object
Large Class/ModuleExtract Class, Extract Module
Repeated SwitchesReplace Conditional with Polymorphism
Message ChainsHide Delegate, Extract Function
Nested ConditionalsReplace with Guard Clauses
Dead CodeRemove Dead Code
Magic Numbers/StringsExtract Constant
Mutable Shared StateEncapsulate Variable, Split Variable
Imperative LoopsReplace Loop with Pipeline (map/filter/reduce)

For each opportunity, draft a concrete before/after code sketch showing the transformation.

Step 5: Assess Coupling and Cohesion

  1. Identify modules with high afferent coupling (many dependents — risky to change).
  2. Identify modules with high efferent coupling (many dependencies — fragile).
  3. Flag circular dependencies between modules.
  4. Assess cohesion — modules that mix unrelated responsibilities are candidates for Extract Class or Split Phase.

Step 6: Evaluate DRY Opportunities

  1. Search for near-duplicate code blocks (>5 lines of similar structure).
  2. Identify repeated constant values (magic numbers, repeated string literals).
  3. Find repeated parameter patterns across function signatures.
  4. Look for copy-pasted logic with minor variations that could be parameterized.
  5. Propose extraction strategies: shared functions, constants files, parameter objects.

Step 7: SOLID Analysis (Domain Projects Only)

Read references/solid-ddd-context.md for detailed guidance.

Evaluate against SOLID principles with domain-project focus:

  • SRP: Classes/modules with multiple reasons to change
  • OCP: Areas requiring modification (not extension) for new variants
  • LSP: Subclasses that override to throw or no-op (Refused Bequest smell)
  • ISP: Interfaces forcing implementers to stub unused methods
  • DIP: High-level modules importing low-level implementations directly

Step 8: Prioritize and Generate Report

  1. Read assets/refactoring-report-template.md for the output template.
  2. Rank all findings by a priority score combining:

- Impact: How much does this hurt readability, maintainability, or change cost? - Frequency: How often is this pattern encountered in the codebase? - Effort: How much work to refactor? (low effort + high impact = do first)

  1. Group findings into priority tiers:

- P0 — Critical: Blocking future development, causing bugs, or high coupling - P1 — High: Significant maintenance burden, frequent pain point - P2 — Medium: Noticeable but manageable, worth addressing opportunistically - P3 — Low: Minor improvements, cosmetic, litter-pickup candidates

  1. Generate the report following the template and save to: docs/_refacs/<YYYYMMDD>-<slug>.md where <slug> is a lowercase-hyphenated summary (e.g., auth-module-cleanup).
  2. Create the docs/_refacs/ directory if it does not exist.

Step 9: Present Summary

  1. Present a brief executive summary to the user with:

- Total findings count by severity - Top 3-5 highest-impact opportunities - Suggested refactoring order (quick wins first, then high-impact) - Estimated complexity tier for each (trivial / moderate / significant)

  1. Ask the user if they want to proceed with any specific refactoring.

Error Handling

  • If the analysis target is too broad (>50 files), ask the user to narrow scope or confirm they want a high-level scan with sampling.
  • If the project has no tests, warn that refactoring without test coverage is risky and recommend adding tests for critical paths before refactoring.
  • If the project uses an unfamiliar framework or pattern, note this limitation in the report rather than guessing.
  • If a smell is ambiguous (could be intentional design), flag it as "potential" and note the context that might justify the current structure.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

33.29%
按下载量换算200

Claude

29.17%
按下载量换算176

Cursor

19.76%
按下载量换算119

Gemini CLI

9.68%
按下载量换算58

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

来源信息

继续浏览同类 Skills