mcpField
R
ruby-refactor

ruby-refactor

github.com/pproenca开发218293 次安装11 周前更新
代码仓库

关于 ruby-refactor

ruby-refactor 是社区维护的 Ruby 应用重构指南,包含按影响排序的规则,帮助开发者和编码 Agent 改善结构、简化条件逻辑并采用 Ruby 惯用写法。

主要功能

  1. 018 个类别的 45 条优先级规则
  2. 02拆分结构与简化条件的建议
  3. 03降低耦合与管理依赖的规则
  4. 04Ruby 惯用法与值对象建议
  5. 05现代 Ruby 3.x 模式

适用场景

  1. 01重构冗长的方法或类
  2. 02简化嵌套条件逻辑
  3. 03减少组件间的耦合

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/pproenca/dot-skills --skill ruby-refactor

安装后在 Claude Code 中输入/ruby-refactor确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

AGENTS.md
metadata.json
README.md
assets/templates/
_template.md
references/
_sections.md
cond-consolidate-duplicates.md
cond-decompose-conditional.md
cond-guard-clauses.md
cond-null-object.md
cond-pattern-matching.md
cond-replace-with-polymorphism.md
couple-avoid-class-methods-domain.md
couple-composition-over-inheritance.md
couple-dependency-injection.md
couple-feature-envy.md
couple-law-of-demeter.md
couple-tell-dont-ask.md
data-define-immutable.md
data-encapsulate-collection.md
data-replace-data-clump.md
data-separate-query-command.md
data-value-object.md
idiom-block-yield.md
idiom-duck-typing.md
idiom-implicit-return.md
idiom-keyword-arguments.md
idiom-predicate-methods.md
idiom-prefer-enumerable.md
idiom-respond-to-missing.md
modern-deconstruct-keys.md

详细介绍

社区 Ruby 重构最佳实践

由社区维护的 Ruby 应用综合重构指南。包含 8 个类别、45 条规则,并按影响力排序,帮助指导自动化重构和代码生成。

适用场景

在以下情况下参考这些指南:

  • 重构 Ruby 代码,以降低复杂度并改进设计
  • 从大型代码单元中提取方法、类或值对象
  • 简化复杂条件判断和深层嵌套
  • 减少类与模块之间的耦合
  • 采用惯用的 Ruby 模式和现代 Ruby 3.x 特性

按优先级划分的规则类别

优先级类别影响前缀
1结构与分解严重struct-
2条件简化严重cond-
3耦合与依赖高couple-
4Ruby 惯用法高idiom-
5数据与值对象中高data-
6设计模式中pattern-
7现代 Ruby 3.x中modern-
8命名与可读性中低name-

快速参考

1. 结构与分解(严重)
2. 条件简化(严重)
3. 耦合与依赖(高)
4. Ruby 惯用法(高)
5. 数据与值对象(中高)
6. 设计模式(中)
7. 现代 Ruby 3.x(中)
8. 命名与可读性(低中)

使用方法

阅读单独的参考文件,了解详细说明和代码示例:

参考文件

文件说明
references/_sections.md类别定义和排序
assets/templates/_template.md新规则模板
metadata.json版本和参考信息

评论

支持 Markdown