- How you use it
- You ask for it
- What it can do
- writes files · runs shell
- What's inside
The option
| Option | ASkill · v1.0.0Review a rename plan without moving files |
|---|---|
| How you use it | You ask for it |
| What it can do | writes files · runs shell |
| What's inside |
What this thread does
The problem
You ask an agent to rename a folder of files (move the date to the front, tidy names). It writes a loop with a regex. On some files the regex captures nothing, every target becomes the same string, and mv replaces one file after another. mv does not use the trash.
What the issues show (read on GitHub, 17 November 2026)
Three reports in the anthropics/claude-code repo, all closed (two by the duplicate bot, one as not planned). This is a pattern of individual incidents, not a high-signal thread, but three people hit the same failure independently and the repo's duplicate bot linked them to each other:
- #31034 (horsexiaoyang, 5 March 2026): Claude wrote a bash script using
BASH_REMATCHto move dates in filenames. It failed silently on filenames with Chinese characters, both capture groups were empty, and every.mdfile was renamed to.mdand every.xlsxto.xlsx. The reporter says 36+ documents were destroyed. Closed as a duplicate of #29420, an earlier data-loss report about rewriting a file before extracting its content. - #43771 (gkumar93, 5 April 2026): a batch
mvrun without testing on one file produced identical target names and overwrote 23 screen recordings. The issue text says about 57 GB in one place and about 47 GB in another. The reporter's list of what should have happened is the best checklist in any of the three: test on one file, usemv -normv -i, show the old-to-new mapping and ask for confirmation, check all targets are unique before running, back up first, stop on the first failure. - #53151 (brandbuilt-hub, 25 April 2026): a
forloop with[[ $f =~ regex ]]and${BASH_REMATCH[1]}produced the same target for every iteration and overwrote 21 of 22 downloaded JPGs. Recovery failed because the local APFS snapshots predated the downloads. The reporter's extra points: prefer Python orrename(1)with explicit collision checks to a hand-rolled bash regex, and if a script usesBASH_REMATCH, make sure it runs underbash, notsh, with a sanity check on the captured groups.
How to apply it
1. Ask for a script with a dry-run default that prints old -> new for every file and writes nothing; apply only with an explicit flag. 2. Make it fail loudly if any new name is empty, unchanged, or appears twice: count unique targets and compare with the number of files. 3. Work on a copy or after a backup (cp -a the folder), especially for large or irreplaceable files; recent snapshots may not contain files that arrived since. 4. Use no-clobber moves (mv -n) so an existing target is never replaced. In a rename loop, the reporter shows mv -n "$f" "$newname" for the move itself. 5. Test the rule on a few real filenames, including accented, CJK or space-containing names, before the full run. 6. Prefer a short Python script using pathlib with explicit exists checks over a clever shell regex. For the Python route, the image-loss report points to os.rename; it still calls for checking collisions.
Mistakes to check
- A regex that works on ASCII samples and silently matches nothing on other filenames.
- Moving into a folder where names can collide (flattening a tree).
- Treating
-ias safe in a non-interactive loop. - Running a bash-only construct under
sh.
Limits
I did not reproduce these incidents. Three reporters describe them; the guardrails are their suggestions, not tested fixes.
Started from a post by @gkumar93, packaged by the editor. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.