Forked from crunch3r/ai-toolbox
Date: 04.07.2026
Project: ai_toolbox (LM Studio Plugin)
Base File: src/tools/refactorCodeTools.ts
The existing refactor_code tool covers only 3 basic operations:
A "Recode" toolset would expand this into a comprehensive, AST-driven refactoring engine that helps developers modernize, clean up, and harden their codebases safely.
| Feature | Why It Matters | Example |
|---|---|---|
| Unused import cleanup | Reduces bundle size, removes clutter | Removes import { unused } from '...' across files |
| Dead code detection | Flags unreachable/never-called functions | Warns about exported functions never imported by anything else |
| Module path normalization | Fixes broken relative imports after moves | Converts ../../utils ā absolute/clean paths |
| Type inference / annotation fixes | Catches any leaks and missing types | Replaces : any with inferred type or adds typed placeholders |
| Feature | Why It Matters | Example |
|---|---|---|
| Callback ā async/await conversion | Removes callback hell in legacy code | Converts (err, data) => {...} chains to async/await |
| Class ā functional component migration (React) | Modernizes React codebases | Class components with lifecycle methods ā hooks (useState, useEffect) |
| Security pattern hardening | Auto-fixes common vulnerabilities | Replaces string concat in SQL with parameterized queries, sanitizes user input before innerHTML |
| Duplicate code extraction | Reduces maintenance burden | Detects identical/mostly-identical function bodies and extracts a shared utility |
| Feature | Why It Matters | Example |
|---|---|---|
| Auto-test generation | Massive time-saver for coverage gaps | Reads function signatures, infers edge cases, generates Jest/Vitest tests |
| JSDoc auto-generation | Improves IDE autocomplete & docs | Generates typed documentation from function bodies and types |
| Architecture linting | Enforces team conventions across the codebase | Flags direct DB calls in controllers (should be in services), detects circular dependencies beyond existing tool |
For maximum immediate utility, propose building:
recodesign_importsrecodemodernize_async.then() chains, RxJS subscriptionsrecodesecurity_hardeneval(), innerHTML without sanitizationunused_import_cleanup using existing Babel setuptoolsProvider.tsTOOLS_REFERENCE.md.bak creation before any modification, with restore optionsrc/tools/
āāā refactorCodeTools.ts (existing ā keep as base)
āāā recodeTool.ts (new ā unified entry point)
āāā rules/
ā āāā unusedImports.ts
ā āāā asyncModernizer.ts
ā āāā securityHardener.ts
āāā recodeEngine.ts (AST transformation orchestrator)
āāā recodeTypes.ts (shared interfaces & schemas)