# mt rm

`mt rm` retires tasks. In a git repository it records a `swh:1:rev` id for each task, rewrites every `links:` edge to that id, and deletes the file. It doesn’t commit. Outside git, [`[rm] strategy`](https://mlavrinenko.github.io/mindtape/config/index.md) decides what happens to those edges.

Refer to a task by stem, hash or path. Give a folder under a task root instead, and `mt rm` retires every task inside it too, as if you had listed each file. Try `mt rm tasks/sw1 --dry-run` to see the list first. `mt rm` refuses a folder outside every root.

A [`[[on.rm]]`](https://mlavrinenko.github.io/mindtape/hooks/index.md#removal-hooks) hook runs before the removal writes anything. A gate then refuses it while every file is still there. A dry run doesn’t run a hook.

Delete tasks, keeping links to them findable in git history

Links to a deleted task become a SWHID, an ID that still finds its file in git history.

`TARGET` takes any number of entries, each a task reference or a filter. `mt rm` retires every task any entry matches, in one pass, and asks you to confirm once.

Runs on one project and refuses a [set](https://mlavrinenko.github.io/mindtape/read-many-projects/index.md).

- `[TARGETS]…`: What to delete: tasks, folders, or a filter such as `done`
  Each is a task (stem, hash or path), a folder under a task root (every task inside it, however deep) or a filter such as `done`. Without any, `mt rm` deletes what `[rm] default-filter` picks, which is every closed task unless you change it.
  `repeatable`
- `-y, --yes`: Don't ask for confirmation
  Without a terminal on stdin `mt rm` can't ask, so it refuses unless you pass this.
- `--dry-run`: Show the deletions and rewrites without changing anything

```
$ mt rm terminal --dry-run                                      # the plan, nothing written
would delete 4 tasks:
  - tasks/add-request-ids-to-log-lines.typ
  - tasks/fix-the-404-page-typo.typ
  - tasks/pin-the-rust-toolchain-in-ci.typ
  - tasks/upgrade-the-axum-web-framework.typ
dry run: nothing written
$ mt rm fix-the-404-page-typo --yes                             # by reference
deleted 1 task:
  - tasks/fix-the-404-page-typo.typ
review the changes and commit when satisfied
$ mt rm upgrade-the-axum-web-framework pin-the-rust-toolchain-in-ci --yes   # two references, one pass
deleted 2 tasks:
  - tasks/pin-the-rust-toolchain-in-ci.typ
  - tasks/upgrade-the-axum-web-framework.typ
review the changes and commit when satisfied
$ mt rm 'status == "done"' --yes                                # by filter: every match
deleted 1 task:
  - tasks/add-request-ids-to-log-lines.typ
review the changes and commit when satisfied
```

Every command also takes the [global flags](https://mlavrinenko.github.io/mindtape/cli/index.md#global-flags).
