Intelligent code refactoring with safety guardrails, impact analysis, and automated validation
This plugin is not yet in any themed marketplace. To install it, you'll need to add it from GitHub directly.
Choose your preferred installation method below
A marketplace is a collection of plugins. Every plugin gets an auto-generated marketplace JSON for individual installation, plus inclusion in category and themed collections. Add a marketplace once (step 1), then install any plugin from it (step 2).
One-time setup for access to all plugins
When to use: If you plan to install multiple plugins now or later
Step 1: Add the marketplace (one-time)
/plugin marketplace add https://claudepluginhub.com/marketplaces/all.json
Run this once to access all plugins
Step 2: Install this plugin
/plugin install refactogent@all
Use this plugin's auto-generated marketplace JSON for individual installation
When to use: If you only want to try this specific plugin
Step 1: Add this plugin's marketplace
/plugin marketplace add https://claudepluginhub.com/marketplaces/plugins/refactogent.json
Step 2: Install the plugin
/plugin install refactogent@refactogent
Intelligent code refactoring - with or without AI
Transform how you refactor code with intelligent analysis, safety checkpoints, and structured workflows. Use it standalone for deterministic refactoring, or with AI for intelligent, context-aware changes.
Refactogent is a dual-mode refactoring tool that works two ways:
Run automated refactoring directly without AI. Perfect for:
Enhance Claude or other AI assistants with refactoring superpowers via Model Context Protocol (MCP):
Key insight: The CLI handles deterministic operations (like type extraction) while the MCP server gives AI the tools to orchestrate complex, context-aware refactorings using those same primitives.
# Install CLI
npm install -g refactogent
# Run automated type extraction
refactogent refactor ./src
# With options
refactogent refactor ./src \
--ignore "**/*.test.ts" \
--types-path "src/types" \
--dry-run
# Verify changes
npm run build # Your tests should pass!
What it does: Automatically extracts interface/type definitions from implementation files, creates .types.ts
files, and updates imports. All changes are deterministic and safe.
See CLI documentation for all commands.
# Install MCP server
npm install -g @refactogent/mcp-server
# Configure with Claude Code
claude mcp add --transport stdio refactogent -- npx -y @refactogent/mcp-server
What it does: Gives Claude (or other AI) access to refactoring tools like refactor_context
, refactor_checkpoint
, refactor_validate
, etc. The AI orchestrates complex refactorings using its intelligence while the tools provide safety and validation.
No API Key Needed: All tools work without configuration when using with Claude. The refactor_suggest
tool (which calls AI) is redundant when Claude is already analyzing your code!
See MCP Server documentation for detailed setup.
This monorepo contains three packages:
Model Context Protocol server providing Claude with refactoring tools and safety guardrails.
Status: โ Production Ready
Command-line interface for standalone refactoring analysis.
Status: โ Production Ready
Core analysis engine with AST parsing, indexing, and type abstraction.
Status: โ Production Ready
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Claude Code โ
โ (AI-powered development environment) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ MCP Protocol
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ @refactogent/mcp-server โ
โ โ
โ Tools: Resources: โ
โ โข refactor_context โข project-health โ
โ โข refactor_checkpoint โ
โ โข refactor_validate โ
โ โข refactor_impact โ
โ โข refactor_suggest โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ Uses
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ @refactogent/core โ
โ โ
โ โข AST Analysis & Parsing โ
โ โข Project Indexing โ
โ โข Dependency Mapping โ
โ โข Type Abstraction โ
โ โข Complexity Analysis โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Install dependencies for all packages
npm install
# Build all packages
npm run build
# Test all packages
npm run test
# Lint all packages
npm run lint
# Format code
npm run format
# Clean build artifacts
npm run clean
# MCP Server
cd packages/mcp-server
npm run build
npm run test:inspector # Test with MCP Inspector
# CLI
cd packages/cli
npm run dev
# Core
cd packages/core
npm test
Direct refactoring without AI - just run and apply:
.types.ts
files--ignore
Use when: You want automated, consistent refactoring without AI decision-making.
Tools that enhance AI's refactoring capabilities:
Use when: You want AI to make intelligent, context-aware refactoring decisions with safety guardrails.
Note: Type abstraction is NOT exposed via MCP because AI can handle it better using refactor_execute_safe
with full context awareness.
# Before: Types mixed with implementation across 50 files
# After: Clean separation with .types.ts files
$ refactogent refactor ./src/components --ignore "**/*.test.ts"
๐ RefactoGent: Complete AI-Powered Refactoring Workflow
๐ Discovered 50 files
โ
Successfully indexed 50 files with 120 symbols
โ
Found 35 type abstraction opportunities
โ
Successfully applied 35 type abstractions
$ npm run build
โ Build passes - all imports resolved correctly!
Result: All interface and type definitions extracted to co-located .types.ts
files, imports updated, multi-line imports preserved.
User: "Extract types from src/components/UserProfile.tsx"
Claude (using MCP):
1. Uses refactor_context to analyze the file and its dependencies
2. Uses refactor_checkpoint to create a safety point
3. Extracts types to a separate file with context-aware naming
4. Updates imports in all dependent files
5. Uses refactor_validate to run tests
6. If tests fail, auto-rolls back to checkpoint
User: "What's the impact of changing the UserService class?"
Claude (using MCP):
1. Uses refactor_impact to analyze dependencies
2. Reports: "47 files depend on this. High risk (82/100)"
3. Uses refactor_dependency_trace to show the chain
4. Suggests breaking the refactor into smaller steps
User: "Improve code quality in src/services"
Claude (using MCP):
1. Uses refactor_suggest on each file
2. Prioritizes high-impact, low-risk suggestions
3. Uses refactor_execute_safe to apply changes incrementally
4. Validates after each change with automatic rollback
Use CLI Mode when:
Use MCP Mode when:
Contributions are welcome! Areas where we need help:
See CONTRIBUTING.md for detailed guidelines.
MIT - see LICENSE for details.
Built with โค๏ธ for the Claude Code community
0.7.3