It was early evening, and I had just finished dropping a new batch of wallpaper source images into a dated folder. I started typing my usual request to Cowork — "remove the ones with white bars on the edges, and the near-duplicates" — and then my hands stopped.
That morning I had read Claude Code issue #112961. Someone reported that Auto mode ran a script it hadn't read, a deletion fired against a path the script had assembled, and the project was gone. Different tool, I know. But it made me notice that my one-line request never said whether "remove" meant delete, move, or just list.
Here's the line I've ended up with, up front: Cowork picks; I delete, a few days later. The rest of this post is how I turned that sentence into a holding folder, a log, and a way back.
"Remove" could mean three different things
As an indie developer who handles a lot of image assets, I say "remove" almost every day. From the receiving end, though, it reads at least three ways.
| What I typed | What I actually wanted | What Cowork could reasonably do |
|---|---|---|
| Check these | A list of candidates with reasons | Stop at the list, or go ahead and move them |
| Remove these | Get them out of the working folder | Move them, or delete them |
| Clean this up | Leave it ready for the next step | Move, delete, or rename |
For a while I never put that difference into words, so "check these" would stop at a list on one day and roll on into the next step on another. These days, a "check" request always ends at the candidate list. That's the agreement.
Why the delete prompt alone wasn't enough
On my setup, Cowork asks for permission before it deletes files inside a connected folder. For a while I treated that as the safety net and left it there.
But that prompt only asks whether to delete. It doesn't give me what I'd need to judge which files were picked and why. Late in the day, with dozens of candidates on screen, I might well click Allow out of momentum.
Then there are scheduled tasks that run unattended. Nobody is there to click anything. So my rule is that unattended tasks never use a step that asks for delete permission at all. Either the run stalls, or something disappears while no one is watching — I'd rather have neither.
A holding folder, and a log of every move
So I made one folder, _holding/, inside the connected folder. What I ask Cowork for stops at writing the candidates down, with a reason for each, as relative/path<TAB>reason, one per line.
The actual moving is done by this script. The problem it solves: keeping three promises — don't delete, don't leave the folder, make it reversible — in code rather than in wording.
#!/usr/bin/env python3
"""Move cleanup candidates into _holding/<timestamp>/ instead of deleting them,
and log one line per file in manifest.tsv.
Usage: python3 hold_files.py <connected_folder> <candidates.tsv> [--apply]
Without --apply nothing moves; it only prints the plan.
candidates.tsv holds one "relative/path<TAB>reason" per line.
"""
import argparse
import csv
import datetime
import shutil
import sys
from pathlib import Path
def main() -> None:
p = argparse.ArgumentParser()
p.add_argument("root")
p.add_argument("candidates")
p.add_argument("--apply", action="store_true")
a = p.parse_args()
# Path("") behaves like ".", so an empty variable would make the
# current directory the root. Refuse it before resolving anything.
if not a.root.strip():
sys.exit("STOP root is empty")
root = Path(a.root).expanduser().resolve()
# Also refuse "/" and the home directory itself.
if root in (Path("/"), Path.home()) or not root.is_dir():
sys.exit(f"STOP invalid root: {root}")
stamp = datetime.datetime.now().strftime("%Y-%m-%d_%H%M")
hold = root / "_holding" / stamp
manifest = root / "_holding" / "manifest.tsv"
plan = []
for line in Path(a.candidates).read_text(encoding="utf-8").splitlines():
if not line.strip() or line.startswith("#"):
continue
rel, _, reason = line.partition("\t")
src = (root / rel.strip()).resolve()
# Never touch a path that escapes the connected folder.
if not src.is_relative_to(root) or "_holding" in src.relative_to(root).parts:
print(f"SKIP outside root: {rel}")
continue
if not src.is_file():
print(f"SKIP not found: {rel}")
continue
plan.append((src, hold / src.relative_to(root), reason.strip() or "-"))
for src, dst, reason in plan:
mark = "MOVE" if a.apply else "PLAN"
print(f"{mark} {src.relative_to(root)} -> {dst.relative_to(root)} ({reason})")
if not a.apply:
print(f"{len(plan)} file(s) planned. Review, then rerun with --apply.")
return
manifest.parent.mkdir(parents=True, exist_ok=True)
is_new = not manifest.exists()
moved = 0
with manifest.open("a", encoding="utf-8", newline="") as f:
w = csv.writer(f, delimiter="\t")
if is_new:
w.writerow(["moved_at", "from", "to", "reason"])
for src, dst, reason in plan:
if dst.exists():
print(f"SKIP already in holding: {dst.relative_to(root)}")
continue
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(src), str(dst))
w.writerow([stamp, src.relative_to(root), dst.relative_to(root), reason])
moved += 1
print(f"Moved {moved} file(s). Log: {manifest.relative_to(root)} / run: {stamp}")
if __name__ == "__main__":
main()By default it moves nothing and prints the plan. Only --apply moves files, because I want a step where my own eyes go over the list once. The holding area mirrors the original folder layout, so I never wonder where a file came from.
I ran it against a practice folder with 12 dummy images and 5 candidate lines. The line that escaped with ../ and the line pointing at a file that didn't exist were both skipped; the other 3 files moved.
One thing I only caught while building it: the first version didn't stop when I passed an empty variable. In Python, Path("") behaves like ., so the current directory quietly becomes the root. The same kind of hole as the issue I'd read that morning was sitting in my own tiny script. Now it rejects an empty string first, then refuses / and the home directory.
Restoring should just mean reading the log backwards
You'll want something back sooner or later — say, a "near-duplicate" that's worth keeping because its colors are different. When that happens, I don't want to rely on memory. I want to walk the log in reverse.
#!/usr/bin/env python3
"""Walk manifest.tsv backwards for one run (moved_at) and put files back.
Usage: python3 restore_held.py <connected_folder> <moved_at> [--apply]
"""
import argparse
import csv
import shutil
import sys
from pathlib import Path
def main() -> None:
p = argparse.ArgumentParser()
p.add_argument("root")
p.add_argument("moved_at")
p.add_argument("--apply", action="store_true")
a = p.parse_args()
if not a.root.strip():
sys.exit("STOP root is empty")
root = Path(a.root).expanduser().resolve()
manifest = root / "_holding" / "manifest.tsv"
if not manifest.is_file():
sys.exit(f"STOP no log found: {manifest}")
with manifest.open(encoding="utf-8", newline="") as f:
rows = [r for r in csv.DictReader(f, delimiter="\t") if r["moved_at"] == a.moved_at]
if not rows:
sys.exit(f"STOP no entries for run: {a.moved_at}")
back = 0
for r in rows:
held, orig = root / r["to"], root / r["from"]
if not held.is_file():
print(f"SKIP not in holding (deleted by hand?): {r['to']}")
continue
if orig.exists():
print(f"SKIP original path is taken: {r['from']}")
continue
print(f"{'BACK' if a.apply else 'PLAN'} {r['to']} -> {r['from']}")
if a.apply:
orig.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(held), str(orig))
back += 1
print(f"{back if a.apply else len(rows)} file(s) {'restored' if a.apply else 'in scope'}.")
if __name__ == "__main__":
main()It restores by run because, most of the time, what I want is to undo an entire day's judgment. When it's a single file, I look up that row in manifest.tsv and move it back by hand. If a file with the same name already sits at the original path, the script skips it instead of overwriting, so restoring never costs me something else.
Three lines in the prompt, and who does the deleting
I changed how I ask, too. Every cleanup request now ends with these three lines:
- Do not delete any files. Write the candidates to candidates.tsv as "relative/path<TAB>reason" and stop there.
- When you're done, report only the count and a breakdown of the reasons. I'll move them after I've looked.
- Don't list any path outside the connected folder.The script already blocks the third case, but I write it in the prompt anyway. If one layer misses, the other catches it.
So who actually deletes, and when? I've settled on this: anything that has sat in _holding/ for 7 days, I delete by hand after reading through manifest.tsv. There's no deep reason behind 7 days. It's simply long enough that I'll look at it at least once before the next batch of images arrives.
Services like Dropbox let you recover deleted files for a while. But how long depends on your plan, and if you notice too late, it won't help. I count on it as the last net, not as part of the plan.
One thing to try today
Make a _holding/ folder inside whatever folder you've connected to Cowork. The next time you're about to type "remove," rephrase it as "move these there and log them." Even without the scripts, the single line "don't delete — write the candidates down and stop" changes how the whole job feels.
If you're still deciding which folders to hand over in the first place, starting with a practice folder and the order I open up write access may help. And if you'd like to check, in one pass, whether any of your unattended task prompts slip in a permission-asking step, I walk through the full procedure — including where my own linter got it wrong — in the write-up on linting 36 unattended-run prompts.
A few days of slack between choosing and deleting. That's the order I keep, especially on the days I'm in a hurry.