Dart and Flutter tests filling the disk: diagnose and choose a fix (agent prompt) A developer published an agent prompt that diagnoses disk-filling by `dart test` and `flutter test`, which compile each test file to 20–30 MiB kernel (.dill) files in the system temp folder. The writeup identifies two causes: package:test 1.32 and earlier retain every kernel file until a run ends (fixed in test 1.33.0), and both runners leave `dart_test.*` and `flutter_tools.*` folders behind after SIGHUP or SIGKILL. It offers six remediation options, from cleaning leftovers and upgrading package:test to relocating TMPDIR or scheduling cleanup, and changes nothing until the user chooses. Give this file to your coding agent. It explains the problem, checks your machine, and asks you how you want to handle it. It changes nothing until you choose. dart test and flutter test compile each test file to a kernel .dill file in the system temp folder. Two things make that folder grow: 1. Growth during a run dart test . In package:test 1.32 and earlier test core 0.6.20 and earlier , the runner keeps every kernel file until the whole run ends. Each one can be 20–30 MiB. A package with 200 test files can hold 7 GiB or more while it runs. Several agents or worktrees running tests at once multiply this. Fixed in test 1.33.0 test core 0.6.21 . See dart-lang/test 2710 https://github.com/dart-lang/test/issues/2710 . 2. Leftovers after a killed run dart test and flutter test . Both delete their temp folder when a run finishes, and on Ctrl-C or SIGTERM. Neither cleans up after SIGHUP the terminal or agent session closed or SIGKILL force kill, for example after a timeout . Later runs do not remove these folders. See dart-lang/test 2711 https://github.com/dart-lang/test/issues/2711 and flutter/flutter 84094 https://github.com/flutter/flutter/issues/84094 . | How the run stopped | dart test | flutter test | |---|---|---| | Finished, Ctrl-C or SIGTERM | Cleaned up | Cleaned up | | Session closed SIGHUP | dart test. left | flutter tools. left | | Force kill SIGKILL | dart test. left | flutter tools. left | Why you may not have the fix yet. In a pub workspace that includes a Flutter package, flutter test pins test api to an exact version, which caps package:test : | Flutter | Newest test | Has fix 1? | |---|---|---| | 3.50 and earlier | 1.32.x or older | No | | 3.51 and later | 1.33.0+ | Yes | Pure Dart packages outside a Flutter workspace can use test: ^1.33.0 now. Never override test api to get the fix early. Do not create, edit or delete anything in this step. Report: - OS and where the system temp folder is macOS: getconf DARWIN USER TEMP DIR ; Linux: $TMPDIR or /tmp ; Windows: %TEMP% , and how much free space that drive has. - Any dart test. and flutter tools. folders there: count, total size, newest change time, and whether a running process still uses them. - For the current project, the resolved test core version pubspec.lock and Flutter version, and whether it has fix 1. - Which shells and agents the person uses, and whether any agent runs in a sandbox that limits where it can write. - Other drives with more free space, if any. Show the diagnosis, then offer only the options that fit this machine. Say what each changes and what it does not cover. Wait for the person to choose. They may choose several or none. - A. Clean up now. Remove leftover folders that nothing is using and that have not changed recently. Show the list and get a yes first. - B. Upgrade package:test . Only if the Flutter pin allows test 1.33.0 or later. Fixes growth during a run, not leftovers. - C. Move the temp folder to a larger drive. Set TMPDIR in a file every shell reads. Keep a fallback for when the drive is not mounted, because flutter fails if TMPDIR points to a missing folder. Does not cover programs an app starts without a shell. Sandboxed agents may need the new folder added to their allowed write paths; find their real setting, do not guess. - D. Scheduled cleanup. A job launchd, cron, systemd timer or Task Scheduler that removes only dart test. and flutter tools. folders that are stale and not in use. Default to a dry run. Show the script and schedule before installing. - E. Limit parallel runs. Run fewer test suites at once across agents or worktrees, for example with --concurrency or one test run per machine. - F. Do nothing. Report only. Do only what the person chose. Back up any file before you edit it. After each change, run one short test and show that the temp files land where expected and are gone when the run finishes. Do not touch the analyzer cache, pub cache, build folders or source files unless the person asks.