Telling Technology · Learning in public
All episodes
EP.134 — DELETE KEY
A Claude Code workflow · a read-only agent on my NAS

My AI listed 12 million files on my NAS. It deleted nothing, and found a 4.2 TB folder no listing shows.

The disk was nearly full and could not tell me why. I did not want any tool near the delete key, so the AI got three commands: ls, find and du. It came back with a table, a page that adds up what I tick, and one number that did not add up.

An overflowing NAS drawer in the dark with a teal magnifier hovering over the files and a small padlock sitting on a single keyboard key labelled DELETE
read-only · 12.2 M rows · 13 shares + 2 drives · 0 deletes
a full disk that could not say why
01 The rule

A nearly full NAS, and no tool allowed near the delete key

My Synology NAS has a 7 TB volume with about 600 GB free and two more volumes next to it, and I had no idea which folders were the weight. Every cleanup tool I looked at wants to help by deleting. So the rule came first: read-only by design. The listing runs on the NAS itself over SSH with key auth, using GNU find at disk speed instead of crawling the shares over the network. Only ls, find and du ever run there. Output goes into one flat SQLite table on my server. Deleting stays mine, by hand.

claude code — desktop
> list every file and folder on every share of knapp2 so I can see where the space went. Read-only: only ls, find and du may run on the NAS. Nothing in this project deletes anything. The deletes are mine, by hand
scripts/scan_nas.ps1 runs find -printf on the NAS and streams one TSV line per entry (type, size, mtime, path) to the PC. load_scan.py loads it into data/knapp2.sqlite, table entries, one row per file or folder. The Active Backup chunk store is pruned (chunks, not files you can act on); Synology system dirs are sized with du instead of walked.
A flow diagram: the NAS on the left with a padlock and three allowed commands ls, find and du, an SSH arrow carrying TSV lines to a server, and one SQLite table called entries on the right, with a crossed-out arrow pointing back to the NAS
3 commands · 0 writes
the listing runs on the NAS, the table lives on my server
02 The scan

One evening, 12,227,353 rows, and my server in the same table

The full pass ran on the evening of 19 October: 13 NAS shares, then the same listing for my home server’s own C: and D: drives, so the NAS and the machine that runs my agents sit in one table and answer the same queries. Total: 12,227,353 rows, just under 10 million of them files. Every Synology quirk gets a flag instead of a guess: #recycle bins, the hidden @eaDir thumbnail folders, snapshots.

claude code — desktop
> same listing for Hbot's C: and D: so the server and the NAS sit in one table. Then tell me how many rows we have and what is flagged
scan_local.py C: D: writes the same TSV format; the loader maps C:/ paths to hbot:C volumes. Totals: 12,227,353 rows, 9,966,562 files, 5 volumes. Flagged: 473 GB of @eaDir thumbnails (267 GB on the photo share alone) and 74 GB in recycle bins.
A dark stats strip with four big numbers: 12.2 million rows, 9.97 million files, 13 shares plus 2 local drives, and 0 writes to the NAS
12.2 M rows
the NAS and the server, one SQLite table
03 What went wrong

Three snags, and a scan that can lose its connection without starting over

The first runs died in boring ways. Quoting: a find command has to survive PowerShell 5.1, then cmd, then ssh, then sh, and it did not. The fix was to stop quoting: write the remote script to a file and pipe it on stdin with sh -s. Stderr: in PowerShell 5.1 a native 2>&1 turns every warning into an error record and killed the run. The log: I opened it with tail -f, the log write threw, and the scan died silently. Now a log write can never abort the run. Then the real fix: each share streams into a .part file that is renamed only when it is complete, so a dropped connection never restarts 12 million rows, it resumes at the next share.

claude code — desktop
> the scan died again halfway through. Make it crash-safe: a dropped connection must not start the whole listing over
Each share now writes <date>-<share>.tsv.part and is renamed to .tsv only when find exits. A rerun skips every share that already has a finished file today. Logging is wrapped so a locked log file prints a note instead of throwing.
A diagram of a row of share files: finished ones in teal ending in .tsv, one in amber ending in .tsv.part with a broken connection icon, and an arrow showing the rerun skipping the finished files and starting at the broken one
one .part per share
crash-safe: resume at the share, not at row one
⚠️

Read-only is my rule, not the NAS’s

Honest part: the SSH key logs in as my own account, which could write if a script told it to. What keeps the NAS untouched is that the scripts only ever send ls, find and du, and nothing in the project has a delete path. A stricter setup would use a dedicated read-only user. The key was added for this scan, and removing it from authorized_keys is on my todo list now that the listing is done.

04 The page

One HTML page: tick folders and watch the space you would free add up

From the table, one self-contained page: a tab per volume with used and free, the biggest buckets by file type, a folder map you can drill into, duplicates by name and size, and the part I actually wanted: tick a folder and a running total shows the space you would free, per volume. It frees nothing. It is a list I can take to the NAS. The page passed the seven-viewport gate before I trusted it. Folder and file names are scrubbed in these pictures. Tap any image to enlarge it and read the exact prompt that drew it.

0 FILES DELETED · LIST READY

The biggest thing on my NAS was not a file

Then volume1 did not add up. Every file the listing found came to 4.5 TB; the volume reported about 7.0 TB in use. 2.5 TB was in no listing at all. The answer was a hidden system folder, @synologydrive: Synology Drive’s version history, every old copy of every synced file, and du measures it at 4.2 TB. It is bigger than the gap because old versions share disk blocks with the live files, so deleting history frees less than 4.2 TB. Where to start is Synology Drive’s versioning setting, not a folder delete. The AI never deleted anything. It built the list and the sum. The delete key stays with me.

A single wide bar for volume1: a teal segment of 4.5 TB of listed files, an amber segment of 2.5 TB marked not in any listing, and above it a bracket labelled @synologydrive version history, 4.2 TB measured with du, overlapping both
scanned 2026-10-19 · 12,227,353 rows · only ls, find, du on the NAS · numbers from the page’s report data, decimal TB
06 Steal this

The read-only inventory pattern

For anyone with a full NAS and no wish to hand an agent the delete key: list on the box itself, load one table, sum what you tick, delete by hand. Everything in this episode is free and open — clone it, run it, make it yours.

skill read-only NAS listing (ls, find, du) cmd scan_nas.ps1 -Shares photo template space-to-free page (tick to total) assets SQLite entries schema
run it # repo soon. The shape: find on the NAS over ssh (script piped on stdin) → one TSV per share (.part until complete) → one SQLite table → a page that sums what you tick → you press delete, by hand

No GitHub? Comment READONLY on the post and the bot DMs you the link.

Next episode

3.3 TB of my NAS might be copies of itself

Same name and same size says 2,000 duplicate groups, led by one 204 GB disk image stored four times. Same name and size is a hint, not proof. Next: pass 2 hashes them, size match, then partial hash, then full hash, before anything gets called a copy.

Four identical dark disk-image icons in a row, three of them faded, with a hash fingerprint line under each and a question mark over the last one
drops soon · follow so you don’t miss it