Expert code refactoring

From GrishaAngelovGH/gemini-cli-agent-skills · View interactive version

Expert code refactoring is an AI agent skill from the GitHub repository GrishaAngelovGH/gemini-cli-agent-skills. Expert code refactoring for Java, JavaScript, and React projects. Focuses on SOLID principles, design patterns, and idiomatic improvements while ensuring test stability.

How to use this skill

Skill file

Refactoring Skill

This skill guides the agent in refactoring codebases by identifying technical debt and applying industry-standard patterns tailored to the specific technology stack.

General Refactoring Workflow

  1. Analyze Context: Read the file and its associated tests. Identify dependencies and usage patterns.
  2. Verify Tests: Before any changes, run existing tests to ensure a stable baseline.
  3. Identify Smells: Look for long methods, deep nesting, duplicate code, or tight coupling.
  4. Incremental Changes: Apply transformations in small, verifiable steps.
  5. Re-verify: Run tests after each significant change.

Architecture & Clean Code (Global)

Refactoring for Testability

Legacy Code Techniques (Safe Changes)

Common Code Smells & Solutions

| Smell | Description | Refactoring Pattern |

| :--- | :--- | :--- |

| Magic Literals | Hardcoded numbers/strings. | Extract Constant or Enum. |

| Long Method | Method does too many things. | Extract Method. |

| Large Class | Too many responsibilities. | Extract Class or Extract Interface. |

| Feature Envy | Method uses another object's data more. | Move Method. |

| Primitive Obsession | Using primitives for domain concepts. | Introduce Value Object. |

| Multi‑File Change Requirement | One change affects many files. | Move Field or Inline Class to centralize. |

Language Specifics

Java

JavaScript / TypeScript

React

Security & Reliability

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.