For developers · Orchestrator
Automatic disk cleanup
On this page
Coding agents, their tools and their builds fill a disk quickly. Gitoodo frees what can be
created again by itself and only suggests what belongs to the user. The engine lives in
crates/core/src/autoclean/ (entry point run_automatic_cleanup), the dispatcher runs it
(crates/cli/src/dispatcher_autoclean.rs), the Storage page shows it. Satellites run the same
engine for their own disk (crates/cli/src/satellite_autoclean.rs, #1675): the same schedule and
low-disk pass, under the main host's settings, with their clones and worktrees as Gitoodo's own
(never a tier item) and without the user's repositories, which need a confirmation on the main
host.
It complements, and never duplicates, the existing cleanup of Gitoodo's own run worktrees
(docs/orchestrator/hygiene.md): Gitoodo's worktree root, its data and the agents' data of its
runs are left to that cleanup and never counted twice.
Tiers#
| Tier | What | When |
|---|---|---|
| A | Fully automatic, silent | On its interval |
| B | Automatic under conditions | On its interval when its conditions hold; in the low-disk pass |
| C | Only listed on the Storage page as suggestion | Never by itself; an action runs only after a confirmation |
Tier A#
| Code | Item | Interval |
|---|---|---|
| A1 | npm cache verify (the tool's own garbage collection) | 7 days |
| A2 | uv cache prune (UV_LOCK_TIMEOUT=60) | 7 days |
| A4 | Each local worker gets its own TMPDIR/TEMP/TMP; removed when its run ends | 6 hours |
A4: the folder is <Gitoodo temp root>/runs/<12 hex characters of the issue key's hash>
(owner-only on Unix, short so socket paths stay within the system's limit). It is created when
a local worker starts and removed when its lease is released. A folder whose run ended without
that (a crash) and that has been idle for an hour is removed by the orphan pass; folders of runs
with a lease are never touched. Workers on other machines keep their system temp folder.
Tier B#
| Code | Item | Condition |
|---|---|---|
| B4 | Xcode DerivedData folders | Untouched for 7 days (1 when low); Xcode not running |
| B5 | Unavailable simulators (xcrun simctl delete unavailable) | Xcode selected and set up; no simulator booted |
| B7 | pnpm store prune | 7 days |
| B8 | Docker build cache above 20 GB (docker buildx prune) | Docker answers info; 7 days. Space inside the Docker VM is not counted as freed on macOS and Windows |
| B9 | Gradle caches of old versions, old wrappers | 30 days (wrappers 90) |
| B10 | NuGet HTTP cache, temp, plugin cache (never global packages) | Paths from dotnet nuget locals all --list; untouched for 30 days |
| B11 | Homebrew downloads | Files older than 30 days |
| B12 | CocoaPods cache | Not used for 30 days |
| B13 | Dart analysis server byte store | Files older than 30 days |
| B14 | Go build cache (go clean -cache) | Only when low |
| B15 | Old versions of the coding agent CLI | Keeps the current, the newest and the previous one (the previous not when low); not within 24 h of an update (1 h when low) |
| B16 | Chromium/Electron app caches (Cache, GPUCache …) | App not running; 30 idle days, or when low |
| B17 | Leftover browser code-signing clones (macOS) | Older than a day, nothing open inside. They are clones: they free almost nothing and are never shown as large |
| B18 | Old temp leftovers of this user; build output in younger temp folders | Top-level entries untouched for 7 days, minus sockets and live sessions. Inside younger ones (4 levels, not the agent CLI's claude folder): Rust target folders and node_modules next to a package.json, untouched for a day (1 h when low), nothing open, no build tool in the project, cargo's locks free (#1917) |
| B19 | Old crash reports and app logs | 30 days; com.apple.* stays |
| B20 | Program caches of installed, idle programs (macOS) | The program is installed and not running; no state or model folders |
| B21 | Playwright browsers no package uses any more | Not wanted by any project registered in Playwright's .links; 7 idle days |
| B22 | Packages npx installed for single runs (<npm cache>/_npx/<hash>) | Cache root from npm config get cache; untouched for 14 days (1 when low) |
| B23 | Old releases of agent packages (~/.codex/packages/<package>/releases/<version>) | Rule of B15 per package, current read from its link; the package's configuration, sessions and logins stay on the never list |
Candidates that stay are reported with their reason (autoclean.skipped): too recent, in
use, not provably regenerable, or not readable. The Storage page sums them per part of "other
programs" (Item::part) next to what the cleanup freed there, so a large part says why it is
still large.
Under pressure (#1804). In a pass with a goal (a low disk, or builds that wait for room,
Reason::low) every "untouched for N days" rule above waits a day at the most
(Reason::rest_days, PRESSURE_REST_DAYS): B4, B7–B13 where they count days, B17's program
caches, B18's top-level temp entries, B22 and the Playwright browsers. Rules that are already
shorter keep their own (B15's hour, B18's build output, B16's "or when low"); B19's crash logs
keep their 30 days. Nothing in use goes, under pressure or not: the guards (open files, running
owners, build tools, cargo's locks) hold as always, and the item's own checks still apply.
Your repositories' build output (after a confirmation, or when space is short and you switched it on; #1418, #1804)#
The build output of the repositories Gitoodo manages, their linked worktrees and the agent
worktrees inside them is the user's: Gitoodo never removes it silently, neither on its interval
nor for a low disk (Item::users_repo; each pass logs autoclean.skipped with
users-repo-needs-confirmation), unless the user switched on "Remove your repositories' build
output automatically when space is short" (Settings → Storage, repo_build_when_short, off by
default). Then a pass for short space (a low disk, or builds that wait for room) that has not
reached its goal after Gitoodo's own build output and the caches runs once more with
Reason::ReposShort for what is still missing (autoclean.repos_short; while it is off,
autoclean.skipped with item = repos, repo-build-auto-off): only these items, with the
rules and stages of the confirmed removal below, and of them only build output that nothing
wrote to for three days (REPO_BUILD_REST_DAYS) in a working copy without uncommitted changes
(uncommitted-changes) that nobody worked in for as long (used-recently, built-recently;
unknown counts as recent). A build that runs keeps its output as always. Each survey and each pass for a low disk plans what
"Remove your repositories' build output" would take (Reason::Confirmed, plan mode, every
check) and keeps the list (autoclean.json repo_build, largest first). The Storage page offers
the action with its total, in the build section and in the warning "Disk almost full"; it asks
first and lists every folder. Once confirmed (request id repo_build), the dispatcher runs it
with the low-disk rules and stages below, so nothing a build uses right now goes:
| Code | Item | Rule |
|---|---|---|
| B1 | Rust target/ of managed repositories and their worktrees | Confirmed by cargo metadata --offline, CACHEDIR.TAG, ignored by git; never a linked target or one cargo does not build into. incremental/ not written in the last 10 minutes, profiles other than the newest not built for a day, the whole folder once nothing was built in it for an hour (never with criterion/package output). Skipped while a build runs in the tree (cargo's lock, a build tool working there) |
| B2 | node_modules of managed repositories | Manifest, lockfile and install marker, never Plug'n'Play; ignored by git; the worktree untouched for 7 days |
| B3 | Framework caches (.next/cache, .turbo, __pycache__ …) | Ignored by git and not tracked; 1 idle day |
| B6 | SwiftPM .build/<triple> | Ignored by git; 1 idle day |
It logs autoclean.repo_build_done (freed); the list is planned again right after.
Tier C (suggestions)#
The Storage page lists large folders (from 500 MB) that only the user decides on: build output of projects Gitoodo does not manage, extra worktrees, Xcode archives and device support, the Android SDK, package stores, AI models, the coding agents' history and large unknown caches. Each row shows the folder; "Remove" exists only for build output and Xcode device support and asks for a confirmation first. Everything else is only shown in the file manager.
Extra worktrees come as a decision (crates/core/src/autoclean/decide.rs). The row names
what goes and what stays, the facts behind it (branch merged into the base branch, on the
server or not pushed; uncommitted changes; unpushed commits; last change as the newest
modification time; in use by a process with its working folder or open files there, or named
in a running command line; the branch's pull request) and a recommendation.
The pull request comes from the forge (#1543): before each survey, and before a confirmed removal, the dispatcher lists the open and the recently merged pull requests of every configured repository once (Forgejo/Gitea, GitHub, GitLab; kept for five minutes). An open pull request with the worktree's branch as its head shows "PR open (#n)" with a link and never lets the working copy go as a whole (the autopilot may still work on it). A merged pull request that ended at the worktree's head counts as merged, also after a squash or rebase merge and with its branch deleted on the server. When the forge could not be asked, the row says "PR state unknown" and the working copy is never advised to go as a whole.
| Recommendation | When | Button |
|---|---|---|
| Safe to remove | merged, clean, nothing unpushed, unchanged for 3 days, registered with git, no open pull request, pull request state known | remove the working copy |
| Build output only | not merged, open pull request, pull request state unknown, uncommitted changes or changed recently, with build output | remove the build output (target/, node_modules/, …); code and commits stay |
| Keep | in use, unpushed commits, unclear branch, or nothing to rebuild | none |
A working copy goes with git worktree remove (never forced) and git worktree prune; its
branch stays. Right before, the facts are read again; if the advice changed, nothing happens.
"Take all safe ones" removes every safe worktree after one confirmation that lists them.
The opt-in setting remove_safe_worktrees lets each survey remove the safe ones by itself;
the page then lists them under the automatic cleanup.
Agent history (transcripts per project, Codex sessions grouped by working folder, handoff
folders) is grouped per project and age band (older than 90 days, 30–90, 7–30, newer than 7)
with count and size. Times are the newest modification inside a session; access times are
unreliable (APFS and noatime mounts). A session in use (open files, a running command line
naming it, a process working in it) counts as newest and is never offered.
| Recommendation | When |
|---|---|
| Probably not needed | 30 days and older, no agent working in the project (pre-selected) |
| Check | 7–30 days, or an agent is working in the project |
| Keep | newer than 7 days or in use; cannot be selected |
History is removed only after a confirmation and only for the bands picked; never automatically. Memory and settings folders next to the sessions are not part of it.
Suggestions of a worker machine (#1680)#
A satellite measures its own suggestions too (suggest::removable, every hour and, while its
disk stays low after its own pass, at most every 15 minutes), but only what goes as a whole after
one confirmation: build output of projects Gitoodo does not manage (target/ with its
CACHEDIR.TAG, node_modules/ next to a package.json) in the usual project folders and up to
two levels below the other folders right in the home folder (an ad-hoc checkout such as
~/w1162), and on macOS Xcode device support. Never offered: sources, the satellite's worktrees
and clones, its state folder, its update builds in ~/.cache/gitoodo-build, the scratch folders
below, hidden folders and the system and document folders of the home folder (Library,
AppData, Documents, …); and nothing that changed in the last hour or is in use (a process
naming it, and on macOS and Linux open files or a working folder there).
The list travels in the satellite's disk report (disk::Report::suggestions, size and newest
write per folder; both new fields are optional, so older satellites simply send none). The
low-disk warning for the machine names how much it offers, and the Storage page lists it under
"Suggestions for <machine>" with the same rows as this computer's. "Remove" asks first, then
sends suggestion_remove; the satellite checks the folder once more (still there, still build
output, outside Gitoodo's places, rested, not in use), answers at once and removes it in the
background with the guards of every confirmed removal (the user's exclusions and keep markers
win; on Windows a folder something holds open stays). Its next reports carry the outcome
(disk::Report::removals: running, done with the bytes freed, or failed with the reason) for
15 minutes.
Scratch folders for checks over ssh (#1680)#
A worker that checks its work on another computer over ssh (a test machine the repository
names) is told to put every checkout and build there into ~/.gitoodo-scratch/<run>
(%USERPROFILE%\.gitoodo-scratch\<run> on Windows; <run> is the short name of its run, the
same as its local temp folder) and to remove it when done (orchestration::brief::scratch_rule).
What is left goes by itself on every computer Gitoodo runs on (autoclean::scratch): a
satellite in its own pass, this computer in its hourly pass. A folder goes when no issue the
machine knows to run or be held has its name, it rested for an hour and nothing uses it; a
satellite removes none while the main host's word on held issues is unknown (an older main host).
The root is never followed when it is a link, and a checkout's .git inside goes with it.
Before that, what an ended run left running there ends (#1931, scratch::strays): a check whose
ssh connection broke keeps building on Windows, holds the memory the machine's workers need and
keeps its folder in use. A process goes when its command line names the scratch folder of a run
that is not active, it runs for ten minutes or more and started before the current list of active
runs (on a satellite: before the main host's last word); every process below it goes with it (a
child that is older than its parent is not one). A process that names an active run's folder stays.
Guards#
Every step passes all of them; an answer that cannot be had ("unknown") skips the step.
- G1 The tool is installed (searched like the agents are);
xcode-select -pbeforexcrun. - G2 A tool's root comes from the tool itself (10 s), is absolute, inside the home folder, on its volume and never the home folder itself.
- G3 Its owner program does not run (one process table per pass).
- G4 Nothing inside is open (one listing of open files per pass on macOS,
/procon Linux, a rename probe on Windows when acting). On Linux the user's own processes the kernel keeps closed (not dumpable, such assshd-sessionandssh-agent) are left out of the listing: every machine reached over ssh has one, and they never work in build output (#1680). - G5 Placeholders of cloud folders are never read; folders the system guards by permission prompt are never walked.
- G6 The target is bound again right before it goes (same file, same device); a changed target is skipped.
- G7 User exclusions (
autoclean-settings.json) and a.gitoodo-keepfile win;.git, the home folder and the system folders are never touched. The one exception is a clone a cargo build script made inside its output folder (<profile>/build/<package>/out/…/.git, the profile with cargo's.cargo-lockand the target folder withCACHEDIR.TAG, #1446): it is build output and goes with it. - G8 Every item has a time limit (10 or 20 minutes) and its own interval.
- G9 Only what really went counts (size before minus after). When a tool fails, nothing is removed in its place.
Sizes are clone-aware: on APFS the private size of a file counts, so a clone counts nothing, and each hard link counts once.
Never#
- Anything tracked by git, any
.git, anything outside the home folder (except the user's temp files), anything a program holds open or whose owner runs. - The user's own data: documents, projects Gitoodo does not manage, models, archives, the agents' sessions. These are tier C.
- A removal by hand where a tool exists for it; a removal after the tool failed.
Schedule#
The dispatcher looks once a minute (first five minutes after its start), one pass at a time on its own thread:
- A suggestion the user confirmed starts within a second.
- Scheduled: once an hour every item whose interval passed runs under its normal rules.
- Every six hours the survey measures the breakdown of "other programs" and the suggestions.
Low disk has no trigger of its own: the disk guard owns the low state, its rate limit and the
warning (hygiene.md, "Disk space" and "Build output"). Its pass for a low disk first removes
Gitoodo's own build output in its order (ended runs, waiting or paused workers, running workers'
incremental caches; hygiene.md, "Gitoodo's own build output by phase"), then runs this cleanup with
Reason::DiskLow (#1445). It starts below twice the guard's limit (20 GiB by default) and frees
until the volume has three times the limit free (30 GiB): every tier B item with its low-disk
rule, in stages, and within a stage the least recently built first, then the largest.
Builds that wait for room (#1804) start the same pass, also while the disk is far from low:
when ready issues wait because their repository's build does not fit (build_budget), the
dispatcher runs it with the goal low + the smallest waiting build + the guard's margin (its
need is what is missing to that goal), under the same rate limit and repeat gaps; the wait is
announced only after it (hygiene.md, "Build output"). The real path:
dispatcher.rs track_host_waits → note_build_waits (cleanup.build_held) → the next disk
reading → auto_build_output (low::build_due, low::build_goal) → build_output(Low) →
Gitoodo's own build output by phase → LowPass with Reason::DiskLow → with the switch on and
the goal not reached, Reason::ReposShort → cleanup.freed_bytes, build_done → the card.
The user's repositories are not part of the DiskLow run (above); their stages apply to the
confirmed removal and to ReposShort:
incremental/of every Rust profile not written in the last 10 minutes;- caches, temp files and the other items;
- Rust profiles other than the newest of their
target/, idle for a day; - whole
target/folders whose newest build is an hour old (only the profiles wherecriterion/packageoutput stays).
Each new stage logs autoclean.stage. Before each step the pass reads the free space again and
stops as soon as the goal is reached (autoclean.disk_recovered), so builds that end or files
removed by hand meanwhile spare the rest. Both halves count into one total
(cleanup.freed_bytes of the disk report); the app posts its one notification only after the
whole pass ("Gitoodo freed 4.2 GB automatically. …"), and not at all when it freed enough. The
cleanup part runs only when the home folder lies on the worktree volume. A scheduled pass that
runs at that moment is asked to stop; the pass for the low disk waits up to two minutes for it
(autoclean.low_waits), else it is skipped (autoclean.low_skipped) and the next reading tries
again after a minute. While the disk stays low the pass comes again, sooner when it did not
reach its goal (hygiene.md, "Build output").
Each action and each skip is logged with its item code and reason (autoclean.* events).
autoclean.json in the state folder keeps the last run per item, the total freed, the last run,
the breakdown and the suggestions, and recent: what went in the last 24 hours, per part, as
automatic or confirmed (the low-disk pass of Gitoodo's own build output notes there too, part
own_build). Settings → Storage shows only these 24-hour figures ("in the last 24 hours freed
automatically"), never the total since the first run, and per part says whether it went
automatically or after a confirmation; the build output of the user's repositories goes only
after one (#1418) or with its switch on (#1804); its older automatic figures are not shown as
automatic.
Settings#
autoclean-settings.json in the config folder: disabled (switches it off), exclude (folders
never touched), off (item names, e.g. "docker_build_cache"), remove_safe_worktrees
(finished worktrees go by themselves, off by default), repo_build_when_short (the user's
repositories' build output goes when space is short, #1804, off by default; a satellite has no
repositories of the user's and keeps it off). The main host sends disabled, exclude
and off to its satellites with each hygiene scope (HygieneScope.cleanup); a satellite without
them uses its own file.
Command line#
gitoodo autoclean [--plan] [--disk-low] runs one pass as the dispatcher would. --plan runs
every check and removes nothing; it lists per step what would go and why something is skipped.
Systems#
Every item either has its Windows and Linux equivalent or skips with not-on-this-system
(Xcode, simulators, code-signing clones and program caches are macOS only; crash reports on
Linux are left to the system).