DVT CLEAN-BAK-FILES
Every DVT tool that rewrites one of your files leaves the original beside it as a timestamped .bak — that's your undo. dvt clean-bak-files is the other half of the bargain: once you trust the changes, one command removes every *.bak from the entire project tree, root included.
Check first, then sweep:
$ dvt clean-bak-files --dry-run would remove dvt_project.yml.20260803-091412.bak would remove models/marts/revenue_rollup.sql.20260802-174501.bak would remove models/staging/stg_orders.sql.20260802-174501.bak 3 .bak file(s), 9.8 KB — dry run, nothing removed $ dvt clean-bak-files removed dvt_project.yml.20260803-091412.bak removed models/marts/revenue_rollup.sql.20260802-174501.bak removed models/staging/stg_orders.sql.20260802-174501.bak 3 .bak file(s), 9.8 KB removed
And on a clean project there is nothing to do, and it says so:
$ dvt clean-bak-files 0 .bak file(s) found
WHERE THE .BAK FILES COME FROM
Several DVT commands edit files on your behalf, and every one of them writes a backup first, in one shared convention: <file>.YYYYmmdd-HHMMSS.bak, right beside the file it rewrote. You'll collect them from dvt config-fix (repairing model configs), dvt flip-target-to (rewriting models for a new target), dvt fix-warnings (clearing deprecation warnings), proposals you apply through Martin — and from the dvt_project.yml health guard, which restores a deleted key and leaves its backup at the project root, not in a model folder.
That last one is why the sweep covers the whole tree. The backups land wherever the edited file lives — model folders, yes, but also the root itself — so clean-bak-files walks everything from the project root down. Only .gitis skipped; it's not DVT's to touch.
IN PLAIN DBT
No tool edits your files, so no tool cleans up after itself either — your safety copies are whatever you made by hand, and clearing them means a hand-rolled find . -name "*.bak" -deletewith no preview and no report. DVT's fixers all write one backup convention, and one command — with a dry run — sweeps them all, telling you exactly what went and how much space came back.
DRY-RUN FIRST, DELETE SECOND
--dry-run prints exactly the list a real run would remove — same walk, same matches, same summary line — and deletes nothing. The habit worth forming is the two-step above: dry-run, read the list, then run it for real. One thing to know before you do: the sweep matches any file ending in .bak, not only DVT's timestamped ones — so if you keep backups of your own under that name, the dry run is where you'll spot them.
Inside dvt martin, the /clean-bak-files shortcut has the same caution built in: it always shows you the dry run first, and the actual removal only happens as a proposed command you approve.
REFERENCE — EVERY FLAG
| FLAG | DEFAULT | WHAT IT DOES |
|---|---|---|
| --dry-run | off | List what would be removed — same walk, same matches, same summary — without deleting anything. Run this first. |
| --project-dir | . | The project root the sweep starts from. The walk covers the entire tree below it, root included, skipping only .git. |