expert-code-refactoring

expert-code-refactoring is a skill for Claude Code, Codex from GrishaAngelovGH/gemini-cli-agent-skills. It costs 38 tokens per session (1,105 once invoked), scanned A, original, MIT.

A code-refactoring guide for Java, JavaScript, and React projects. Refactoring reorganizes existing code to make it clearer or easier to maintain while keeping its behavior stable.

In plain words
What is it for?
Use it to review related code and tests, find design and readability problems, and make small incremental improvements. It emphasizes descriptive names, small functions, limited nesting, and avoiding unnecessary abstractions.
Why use it?
It helps identify issues such as duplicated code, long methods, deep nesting, and tightly connected parts. Running tests before and after each change helps detect accidental behavior changes.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to review related code and tests, find design and readability problems, and make small incremental improvements. It emphasizes descriptive names, small functions, limited nesting, and avoiding unnecessary abstractions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/grishaangelovgh/gemini-cli-agent-skills/expert-code-refactoring
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add GrishaAngelovGH/gemini-cli-agent-skills --skill expert-code-refactoring
Clone the repo
git clone --depth 1 https://github.com/GrishaAngelovGH/gemini-cli-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for expert-code-refactoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/grishaangelovgh/gemini-cli-agent-skills/expert-code-refactoring.svg)](https://agentmods.dev/skills/grishaangelovgh/gemini-cli-agent-skills/expert-code-refactoring)
Your own site
<a href="https://agentmods.dev/skills/grishaangelovgh/gemini-cli-agent-skills/expert-code-refactoring"><img src="https://agentmods.dev/badge/skills/grishaangelovgh/gemini-cli-agent-skills/expert-code-refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,105 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.01105
Opus 5 $0.00019 $0.00553
Sonnet 5 $0.00008 $0.00221
Haiku 4.5 $0.00004 $0.00111

Measured 8d ago against content hash b393889052a7, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

expert-code-refactoring scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

expert-code-refactoring/SKILL.md · 79 lines

How it starts

The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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)

  • Naming: Rename variables, functions, and classes to be descriptive and reveal intent. Avoid abbreviations.
  • AHA Programming: Avoid Hasty Abstractions. Only abstract code when the duplication is clear and the abstraction doesn't make the code harder to follow.
  • Functions: Keep functions small. Aim for a low number of parameters (prefer objects/records for many parameters).
  • Cognitive Load: Reduce nesting levels (aim for max 2-3 deep). Use early returns to keep the "happy path" aligned to the left.

Refactoring for Testability

  • Dependency Injection (DI): Replace hardcoded instances or static calls with injected dependencies (via constructor or parameters).
  • Interface Segregation: If a class depends on a large interface but only uses one method, extract a smaller interface.
  • Pure Functions: Extract business logic into pure functions that don't depend on external state or side effects, making them trivial to unit test.
  • Mocking Boundaries: Identify "seams" where you can inject mocks (e.g., Database, Network, System Clock).

Legacy Code Techniques (Safe Changes)

  • Characterization Tests: If tests are missing, write "Golden Master" tests that record the current behavior before changing it.
  • Sprout Method: When adding a feature to a messy method, write the new logic in a new, clean method and call it from the old one.
  • Wrap Method: Add new behavior by creating a new method with the same signature that calls the old method and then adds the new logic.
  • Break Dependencies: Use the "Extract and Override" pattern to isolate untestable static calls or constructors in a protected method that can be overridden in a test subclass.

Read the full file on GitHub · 79 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 79 lines · 38 tokens per session scan A b393889052a7

Subscribe to this mod's changes

expert-code-refactoring is a skill published in the GitHub repository GrishaAngelovGH/gemini-cli-agent-skills (16 stars, last pushed 6mo ago), licensed MIT. It adds 38 tokens to every session and 1,105 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.