Token导航 LogoToken导航TokenDH.com
运维和基础设施只读github未标认证来源可访问clear审计通过

code-refactoring代码重构

Agent Skill

code-refactoring 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

412

周安装

17

GitHub Stars

10

下载量

135
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/dauquangthanh/hanoi-rainbow --skill code-refactoring

简介

code-refactoring 提供安全重构工作流,通过分析代码问题、制定增量计划与全面测试覆盖保障重构可靠性。

  • 适用于长方法、重复逻辑或复杂条件判断的重构场景,系统化识别问题并生成可执行修复步骤。
  • 采用渐进式变更策略,每步修改后验证功能一致性,输出详细日志与回滚建议以防意外。
  • 使用前应确认 Git 工作区干净且有完整测试用例,避免在冻结期或关键发布前执行高风险重构操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Code Refactoring

Overview

This skill guides systematic code refactoring to improve code quality, maintainability, and design while preserving functionality. Follow the safe refactoring workflow with comprehensive test coverage and incremental changes.

Refactoring Workflow

Step 1: Analyze Code and Identify Issues

Examine the codebase to identify code smells and quality issues:

  • Long methods (>20-30 lines) or large classes (>300-500 lines)
  • Duplicated code blocks or similar logic in multiple places
  • Unclear or misleading names for variables, methods, or classes
  • Complex conditional logic or deeply nested structures
  • Poor separation of concerns or tight coupling between components

For detailed code smell catalog: See code-smells.md

Step 2: Verify Test Coverage

Before refactoring ANY code:

  1. Check existing test coverage for the code to be refactored
  2. If tests are missing or inadequate, write tests FIRST
  3. Run all tests to establish baseline (all should pass)
  4. Never proceed without adequate test coverage

For test coverage strategies: See testing-strategies.md

Step 3: Choose Refactoring Technique

Select the appropriate refactoring pattern based on the issue:

  • Extract Method/Function: Break down long methods into smaller, focused ones
  • Extract Class: Split large classes with multiple responsibilities
  • Rename: Improve clarity with better names
  • Move Method/Field: Relocate functionality to more appropriate classes
  • Replace Conditional with Polymorphism: Simplify complex conditionals
  • Introduce Parameter Object: Group related parameters
  • Inline Method/Variable: Remove unnecessary indirection

For complete pattern catalog: See refactoring-patterns.md

Step 4: Apply Refactoring Incrementally

Make ONE small change at a time:

  1. Apply a single refactoring technique
  2. Run all tests immediately after the change
  3. If tests pass, commit the change
  4. If tests fail, revert and try a different approach
  5. Repeat for each refactoring needed

Critical Rules:

  • Never change behavior while refactoring
  • Never refactor and add features simultaneously
  • Use IDE automated refactoring tools when available
  • Keep each refactoring commit small and focused

For detailed process guidance: See refactoring-process.md

Step 5: Verify and Document

After completing refactorings:

  1. Run full test suite to ensure all tests pass
  2. Check that code quality metrics improved
  3. Review code to confirm readability enhanced
  4. Document significant architectural changes if needed
  5. Create clear commit messages describing refactorings

Common Refactoring Scenarios

Scenario-specific guidance is available for:

  • Legacy code modernization
  • Preparing code for new features
  • Performance optimization through refactoring
  • Reducing technical debt systematically
  • Extracting reusable components

See common-refactoring-scenarios.md for detailed examples and approaches.

Best Practices and Quality Guidelines

Follow established principles for high-quality refactoring:

  • Apply SOLID principles (Single Responsibility, Open/Closed, etc.)
  • Reduce coupling between components
  • Increase cohesion within components
  • Eliminate duplication (DRY principle)
  • Maintain consistent coding standards

For comprehensive best practices: See refactoring-best-practices.md

Tools and Automation

Modern IDEs and tools can automate many refactorings safely:

  • IDE refactoring features (IntelliJ, VS Code, Visual Studio)
  • Static analysis tools for code smell detection
  • Test coverage tools
  • Automated code formatting and linting

For tool recommendations and usage: See tools-and-automation.md

Output Format

When presenting refactoring recommendations:

  1. Identify the code smell or quality issue
  2. Explain why it's problematic
  3. Propose specific refactoring approach
  4. Show before/after code examples
  5. List tests to verify behavior preservation

For detailed output templates: See output-format.md

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

能力 5

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

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

平台分布

Antigravity

25.25%
按下载量换算34

Claude Code

24.54%
按下载量换算33

Codex

17.52%
按下载量换算24

Gemini CLI

12.7%
按下载量换算17

OpenCode

7%
按下载量换算9

windsurf

3.41%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

来源信息

继续浏览同类 Skills