simplify
Removes over-engineering and complexity creep from code with an AST codemod (recast, not regex).
Reference
Parameters
- Name
code- Type
- string · required
- Description
The source to simplify (TSX/JSX)
- Name
rules- Type
- array · optional
- Description
Restrict to specific rule ids (default: all)
Returns
{
changed
fixed
diff unified
applied[]
skipped[]
warnings[]
}
Description
Removes over-engineering and complexity creep from code with an AST codemod (recast, not regex).
The complexity counterpart to apply_fix. Auto-applies the provably-safe, behavior-preserving cases and proposes the judgment calls:
- no-unneeded-boolean-ternary (auto): "c ? true : false" becomes "!!c", "c ? false : true" becomes "!c"
- no-useless-fragment (auto): a Fragment wrapping a single element is unwrapped to that element
- usememo-empty-deps / usecallback-empty-deps (proposed in skipped, not rewritten): memoization with an empty dependency array, where the safe fix depends on intent
Parameters:
- code (required): the source to simplify (TSX/JSX)
- rules (optional): restrict to specific rule ids (default: all)
Source
Defined in packages/mcp/src/tools.ts.
The request handler lives alongside its registration in packages/mcp/src/tools/.
Last reviewed by @jschuyler