Why does the workspace get dirty? Finishing a task usually leaves intermediates behind: throwaway scripts, split fragments, validation samples, half-written output. Not necessarily wrong, but they must be identified.
| Common leftover | What it looks like | What to do |
|---|---|---|
| Temporary scripts | verify.py, check.sh, tmp_*.py — one-off validation logic | Delete after confirming no reuse; move into scripts/ if you keep it |
| Intermediate fragments | out_part1.md, chunk_*.txt, somefile.bak | Delete once merged |
| Test samples | sample.*, test_* — often fake data | Delete; make the recipe generate them instead of committing |
| Half-written output | Incomplete but not erroring | Judge against the acceptance list; prefer rerunning |
| Logs and caches | *.log, __pycache__, .pytest_cache | Delete; add ignore rules |
| Modified originals | Same name, different content | Only a hash comparison reveals it |
Screen quickly by modification time
find . -type f -newer /tmp/before.txt -not -path './.git/*' | sort
Touch /tmp/before.txt before the run, then use this afterwards to list everything created or touched by this run. Much faster than browsing directories.
Use git when available
git status --short
Untracked (??), modified ( M), deleted ( D) at a glance. The find command above substitutes when there is no repo.
Cleanup order
- Snapshot the file list first (
find . -type f | sort > /tmp/after.txt). - Mark what the acceptance list says should exist.
- Classify the rest per the table: delete regenerable one-offs, move reusable pieces into a fixed directory.
- Rerun the task once to confirm nothing you deleted was required — the step most often skipped, and the most expensive to skip.