refactor

Convert JavaScript to TypeScript with AST-guided renames and React hooks.

24|6|Updated Dec 19, 2025
One-click install
npx skills add https://github.com/johnlindquist/claude --skill refactor-johnlindquist
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/johnlindquist/claude/tree/main/skills/refactor
Command: npx skills add https://github.com/johnlindquist/claude --skill refactor-johnlindquist

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires google-generativeai, jscodeshift, typescript, and includes scripts (resource) components.

What problem does it solve?

This Skill eliminates the risk and tedium of manual code refactoring.

Core Features & Use Cases

  • Code Modernization: Convert legacy code to current best practices with AI guidance.

Quick Start

Convert the attached legacy JavaScript file to modern TypeScript with proper types and error handling.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I convert legacy JavaScript to TypeScript with proper types?

This Skill automates JavaScript-to-TypeScript conversion by analyzing your code with AST tools and Gemini, adding explicit types, interfaces, and strict TypeScript rules while preserving behavior. It handles type inference, error handling, and validates changes through test-driven workflows.

Can I use AI to modernize React class components to hooks?

Yes. This Skill migrates class components to React hooks using AI-guided refactoring. Gemini analyzes component structure, jscodeshift applies AST-safe transformations, and TypeScript validates the output for correctness and type safety.

What's the safest way to refactor a large codebase with renames?

AST-guided refactoring eliminates manual rename errors across large codebases. This Skill uses jscodeshift to parse and transform code structurally, ensuring all references update consistently while TypeScript validates type correctness after changes.

How do I modernize code to ES2023+ patterns automatically?

This Skill applies modern ES2023+ patterns through AI analysis and AST transformation. Gemini identifies refactoring opportunities, jscodeshift executes safe rewrites, and tests verify behavior is preserved before deployment.

Do I need to write tests before refactoring with this Skill?

A test-driven workflow is built into this Skill's design. Tests verify that refactored code preserves behavior. Having tests in place before refactoring ensures safety and confidence in AST-guided transformations.

Can this Skill handle TypeScript files with strict type checking?

Yes. This Skill satisfies strict TypeScript requirements by enforcing explicit types, interfaces, and strict mode during refactoring. TypeScript validation ensures all transformations maintain type safety and pass strict compilation rules.