refactoring-expert

Detects code smells and applies proven refactoring techniques without changing external behavior.

3|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/trudyan141/my-antigravity-agents-kit --skill refactoring-expert-trudyan141
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring-expert
Source: https://github.com/trudyan141/my-antigravity-agents-kit/tree/main/templates/.agent/skills/refactoring-expert
Command: npx skills add https://github.com/trudyan141/my-antigravity-agents-kit --skill refactoring-expert-trudyan141

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Codebases accumulate technical debt through duplicated code, long methods, complex conditionals, and poor structure, making them hard to maintain and extend. This Skill systematically identifies code smells and applies safe, incremental refactoring techniques while keeping tests green. ## Core Features & Use Cases - Code Smell Detection: Uses grep-based pattern matching to find long methods, magic numbers, message chains, deep nesting, and duplicated code across JavaScript and TypeScript files. - Six Refactoring Categories: Covers composing methods, moving features between objects, organizing data, simplifying conditionals, simplifying method calls, and generalization with concrete before/after examples. - Safe Incremental Process: Enforces a test-first workflow where each small refactoring is validated by running tests, linting, and type checks before proceeding. - Use Case: When reviewing a legacy module with 50-line functions and nested conditionals, invoke this Skill to get a prioritized refactoring plan with specific techniques like Extract Method and Guard Clauses, applied one step at a time. ## Quick Start Ask the agent to analyze a specific file or module for code smells and suggest safe refactorings, for example: review src/orders.js for code smells and refactor the longest methods while keeping all tests passing.

Frequently Asked Questions about refactoring-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor long methods in JavaScript safely?

Use the Extract Method technique to pull logical blocks into well-named functions, keeping each method under 10 lines. Ensure tests exist first, make one small change at a time, and run the test suite after every step to confirm behavior is unchanged.

How to detect code smells in a TypeScript codebase?

Run grep-based pattern matching to find long methods, magic numbers, deep nesting, message chains, and duplicate code blocks. The Skill provides ready-made detection commands for each smell category, such as finding conditionals with multiple && and || operators.

What is the safe refactoring process when tests are missing?

Create characterization tests before touching any code, since refactoring without a safety net risks silent behavior changes. Then follow the cycle of small change, run tests, commit if green, and repeat.

When should I replace conditionals with polymorphism?

Apply this when switch statements or if-else chains branch on a type code that keeps growing. Create a class hierarchy where each subclass overrides the behavior method, eliminating the conditional and making new variants easy to add.

When should I not use this refactoring skill?

Delegate to a specialist when the root problem is performance bottlenecks, type system design, database schema, or build configuration rather than code structure. The Skill explicitly routes those cases to domain experts like react-performance-expert or typescript-type-expert.