| name | move |
| description | Use when relocating an existing complete code block within the worktree: moving functions/classes between files, reordering blocks in one file, or creating a new destination file from existing code. Prefer this over copy-then-delete. Do not use for semantic refactors, partial-line edits, import rewriting, or new code generation. |
Move Tool
Use move when code already exists in one place and must be relocated to another place. The tool performs a text move: remove complete source lines and insert them at the destination.
It does not update imports, exports, references, formatting, or surrounding code semantics. Do those with normal editing tools after the move.
Required workflow
- Read the source file and destination file first.
- Identify the block with
start_line and optional end_line.
- Run the first call as a dry run.
dry_run defaults to true; keep it explicit for clarity.
- Review
preview.removed_text and preview.inserted_text.
- Re-run with
dry_run=false only when the preview is correct.
- Update imports/exports/references manually.
- Run diagnostics/tests for touched files.
Argument patterns
Move lines to another file
move({
source_file: "src/utils.ts",
destination_file: "src/validation.ts",
start_line: 42,
end_line: 68,
insert_mode: "append",
dry_run: true,
})
Insert before or after a destination line
move({
source_file: "src/utils.ts",
destination_file: "src/validation.ts",
start_line: 42,
end_line: 68,
insert_mode: "before_line",
insert_line: 12,
dry_run: true,
})
insert_line is valid only with insert_mode="before_line" or insert_mode="after_line".
Reorder within the same file
move({
source_file: "src/app.ts",
destination_file: "src/app.ts",
start_line: 120,
end_line: 150,
insert_mode: "after_line",
insert_line: 45,
dry_run: true,
})
Same-file insert_line uses the original file's line numbers. Inserting inside or adjacent to the moved range is rejected because it is ambiguous or a no-op.
Defaults and constraints
dry_run defaults to true.
insert_mode defaults to append.
adjust_indentation defaults to false.
- Paths must stay inside the current worktree. Absolute paths are allowed only inside the worktree.
- Destination files may be created, but destination parents must resolve inside the worktree.
- Cross-file writes use best-effort rollback, not a true filesystem transaction.
When not to use
- Do not use for partial-line edits.
- Do not use to update imports or references.
- Do not use when generating brand-new code.
- Do not skip reading the files first; the tool needs precise block boundaries.
- Do not apply (
dry_run=false) until the dry-run preview is correct.