refactor

Guide safe codebase refactoring with characterization tests and stepwise commits.

2|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/jscott3201/ai-agent-skills --skill refactor-jscott3201
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/jscott3201/ai-agent-skills/tree/main/skills/refactor
Command: npx skills add https://github.com/jscott3201/ai-agent-skills --skill refactor-jscott3201

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reduce the risk of regressions and large, unsafe changes by guiding developers through a structured refactoring workflow that identifies code smells, locks current behavior with characterization tests, and enforces small, verifiable steps.

Core Features & Use Cases

  • Smell identification and triage: Detects common smells like long functions, god modules, duplicate logic, and primitive obsession and recommends targeted fixes.
  • Test-first, stepwise execution: Requires characterization tests, compilation checks, and per-step commits so each change is independently verifiable.
  • Cross-language patterns and persistence: Provides Rust, Python, and JavaScript/TypeScript refactoring patterns and can optionally record decisions and outcomes to SeleneDB for future recall.

Quick Start

Run the refactor skill on the target module with a brief description of the smell to produce a stepwise plan, write characterization tests, and execute each step with tests and compilation checks.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I safely refactor long functions and god modules without introducing regressions?

To safely refactor long functions and god modules, identify code smells, lock current behavior with characterization tests, and execute incremental changes with compilation checks and per-step commits. This structured workflow prevents behavioral regressions in Rust, Python, and JavaScript codebases.

What is characterization testing and when do I need it for code refactoring?

Characterization testing is a technique to lock in the current behavior of existing code before making changes. You need it during code refactoring to verify that incremental transformations preserve the original logic and prevent regressions across Rust, Python, and JavaScript projects.

How do I plan incremental refactoring steps for duplicate logic and primitive obsession?

Plan incremental refactoring by detecting specific code smells like duplicate logic, then producing a stepwise transformation plan. Execute each step independently with characterization tests, compilation checks, and per-step commits to ensure no behavioral regressions occur during the reorganization.

Can I use this incremental refactoring workflow with Rust, Python, and JavaScript projects?

Yes, this refactoring workflow supports Rust, Python, and JavaScript or TypeScript projects. It provides cross-language refactoring patterns to handle long functions, god modules, duplicate logic, and API-preserving reorganizations safely.

How do I track refactoring decisions and outcomes for future recall?

Track refactoring decisions and outcomes by optionally recording them to SeleneDB for future recall. This persistence layer captures the stepwise transformations and characterization test results, enabling better decision tracking across incremental codebase changes.

What are the limitations of incremental refactoring for large codebases?

Incremental refactoring focuses on file- and module-level transformations, requiring compilation checks and tests at each step. It may not scale efficiently for massive architectural changes without first breaking them down into smaller, independently verifiable API-preserving reorganizations.