RefakTS is a TypeScript refactoring tool built by AI coding agents for AI coding agents. Its key principle is surgical refactoring operations that avoid error-prone text generation.
Key Approach: Clear Path and Small Context
1. Location-Based Workflow
Find then refactor: Use select command to locate code elements first
Precise targeting: Operations target specific locations like [src/example.ts 5:8-5:18]
Preview before action: Shows content preview before performing operations
2. Surgical Operations (Not Regeneration)
Extract variable: Convert expressions to variables without touching surrounding code
Inline variable: Replace variable usage with its value
Rename: Change variable names and all references across codebase
Find usages: Locate all symbol references
3. Context Management
Minimal scope: Operations affect only what needs to change
Preserve cognitive capacity: AI agents don’t need to regenerate entire functions
Token efficiency: Changes only specific elements rather than entire code blocks
4. Selection Modes for Context Control
Range mode: Select between start and end patterns
Structural mode: Select based on code structure (methods, fields)
Boundary mode: Limit selection to specific boundaries (functions, classes)