extract_variable
Extract a selected expression into a named variable, replacing it with the variable name. Supports replacing similar occurrences and global scope, with dry-run preview before applying.
Instructions
Extract a selected expression into a named variable, replacing the expression with the name. Pass the file and the selection Range (start_line/start_character to end_line/end_character, 0-based, UTF-16 units) covering exactly one expression. replace_similar also substitutes other occurrences of the same expression; to_global_scope creates the variable at module level. Defaults to a Dry Run preview; set apply=true to write. Read the code with your LSP first; leave formatting to black/ruff.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| name | Yes | ||
| root | No | ||
| apply | No | ||
| end_line | Yes | ||
| start_line | Yes | ||
| end_character | Yes | ||
| replace_similar | No | ||
| start_character | Yes | ||
| to_global_scope | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||