delete_file
Delete files and empty directories, singly or in batches up to 100, with validation before removal. Non-empty directories are rejected and dirty git files require confirmation.
Instructions
Delete files and empty directories. Pass file_path for one, or paths for several in a single call (max 100). Refuses to delete directories unless allow_dir: true is set — and even then only an EMPTY directory is accepted (non-empty directories are always rejected; there is no recursive delete). To remove a whole tree, list its files with find_files and pass them plus their directories in one paths batch with allow_dir: true — every path is validated before anything is removed, and directories go last, deepest first, so they are empty by the time their turn comes. The LSP server is notified with FileDeleted so symbol indexes and diagnostics update immediately. Per-path locking serialises against any concurrent write_file/edit_file targeting the same path. The response reports the line and byte count removed (bytes only for a binary or oversized file).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paths | No | Several files and/or empty directories to delete in one call (max 100). Same per-path rules as file_path — this batches round-trips, it does NOT delete recursively. Every path is validated before any is removed, and directories are removed after files, deepest first, so naming a tree's files and its directories together works in one call. | |
| dirty_ok | No | Allow deleting a file that has uncommitted changes in its git repository. Default false — deletion is refused if the file is dirty. Pass true to proceed anyway. | |
| allow_dir | No | Allow deleting an empty directory. Default false — deletion is refused for any directory. The directory must be empty; non-empty directories are rejected even with allow_dir: true. | |
| file_path | No | Absolute path, file:// URI, or workspace-relative path of the file or empty directory to delete. Use paths instead to delete several in one call. |