ashlr

ashlr__edit_structural

AST-aware rename across files. Handles Unicode identifiers, cross-file rename with shadowing guard, extract-function with return-value detection. TypeScript/TSX/JS/JSX only.

ashlr__edit_structural performs AST-aware symbol renames and function extractions. Unlike ashlr__edit (text search/replace), it understands scope and shadowing — a rename of foo only touches occurrences that resolve to the same binding.

Use cases

  • Rename a function, variable, or type across all files in a project
  • Rename Unicode identifiers (café, π, CJK characters) correctly
  • Extract a code block into a new function, auto-detecting return values
  • Dry-run a rename to preview all affected sites before applying

Parameters

ParameterTypeRequiredDescription
filestringyesSource file to anchor the rename.
oldNamestringyesCurrent symbol name.
newNamestringyesNew symbol name.
anchorFilestringnoDisambiguate when oldName appears in multiple files.
maxFilesnumbernoLimit cross-file rename to N files (default: unlimited).
dryRunbooleannoPreview affected sites without writing (default: false).

For function extraction, use extract mode (see tool schema for full args).

Supported languages

.ts, .tsx, .js, .jsx. Other languages fall back to ashlr__search_replace_regex.

Example

{
  "tool": "ashlr__edit_structural",
  "arguments": {
    "file": "src/auth/handler.ts",
    "oldName": "handleRequest",
    "newName": "handleAuthRequest",
    "dryRun": true
  }
}

Returns a preview of all affected sites. Remove dryRun to apply.

On this page