Code RoomFixing shell script robustness iteratively
MediumPrep Room Coding #4046

Fixing shell script robustness iteratively

Vibe & agenticAlgorithms & data structuresMid–Senior~14 min

You ask an AI for a Bash script to 'rename all the log files to add a date prefix.' It writes a loop with `for f in $(ls *.log)` and `mv $f 2024-...-$f`. It runs fine on your test dir, so you point it at production logs and it mangles a dozen filenames containing spaces and a couple starting with `-`. You tell it 'handle spaces' and it wraps a few vars in quotes but the dash-prefixed files still break. How do you re-steer to get this robust?

Implement
plan_log_renames(filenames: list[str], date_prefix: str) → list[str]
Examples
in[["app.log","my server.log","-rf.log","notes.txt"],"2024-06-01"]out["mv -- 'app.log' '2024-06-01-app.log'","mv -- 'my server.log' '2024-06-01-my server.log'","mv -- '-rf.log' '2024-06-01--rf.log'","skip:not_a_log"]
in[["it's.log","*.log"],"2024-06-01"]out["mv -- 'it'\\''s.log' '2024-06-01-it'\\''s.log'","mv -- '*.log' '2024-06-01-*.log'"]
in[["a.log","2024-06-01-a.log"],"2024-06-01"]out["error:collision","skip:already_prefixed"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 14 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.