Clean up workspace caches
Workspace runs can leave managed cache entries behind. Preview the selection, narrow it when needed, and remove it after checking the paths.
1. Preview the scope
Separate caches from run records
Cleanup removes managed workspace cache artifacts such as retained workspaces and cache state. Canonical records under .crewplane/execution-stages/ and .crewplane/execution-results/ remain.
Preview what goes. See what stays.
Try cleanup on these example entries. This preview does not access or remove your files.
crewplane cleanup workspaces --dry-runExample cache entries Current repository
- Completed run · 14 days oldVerified managed workspaceEligible after checks
- Completed run · 2 days oldVerified managed workspaceEligible after checks
- Running workspaceA run is still activeKeep
- Unverifiable workspaceSaved state cannot be confirmedKeep
.crewplane/execution-stages/.crewplane/execution-results/Preview the eligible completed workspaces, then confirm removal. Running or unverifiable entries stay.
Print the paths first
Run the dry run in the project whose caches you want to inspect. With no status flags, it selects workspaces from completed runs in the current Git repository, leaving running workspaces and workspaces whose state cannot be confirmed.
crewplane cleanup workspaces --dry-run Remove the reviewed selection
After checking the dry-run output, use --yes to remove matching cache entries. Cleanup is non-destructive without --yes; if both --dry-run and --yes are present, the dry run takes precedence.
crewplane cleanup workspaces --yes Expand the scope deliberately
--all-projects selects every repository bucket under the configured workspace cache root. Preview this scope first: Crewplane cannot tell whether another project’s cached workspace is still in use. Adding --all-projects --yes confirms acceptance of that risk.
crewplane cleanup workspaces --all-projects --dry-runcrewplane cleanup workspaces --all-projects --yes 2. Choose entries
Narrow the selection
Choose a config file, a full run key, an age, or status filters. --successful, --failed, and --cancelled select the corresponding run statuses; --orphans selects cache folders with no saved workspace record.
Replace YOUR_FULL_RUN_KEY with the full run key from the stage directory before running the command.
crewplane cleanup workspaces \ --config .crewplane/config.yml \ --dry-run \ --run 'YOUR_FULL_RUN_KEY' \ --older-than 7d \ --successful \ --failed \ --cancelled \ --orphans Select one run
Use the full run key from its stage directory. Review the first command’s output before using the second.
Replace YOUR_FULL_RUN_KEY with the full run key from the stage directory before running either command.
crewplane cleanup workspaces --run 'YOUR_FULL_RUN_KEY' --dry-runcrewplane cleanup workspaces --run 'YOUR_FULL_RUN_KEY' --yes Select by age
--older-than accepts integer seconds or durations with suffixes, such as 30s, 30m, 12h, and 7d. Preview before deleting.
crewplane cleanup workspaces --older-than 7d --dry-runcrewplane cleanup workspaces --older-than 7d --yes Understand orphan checks
A broken or conflicting record is not a missing record. Crewplane removes an orphan only if it can confirm the related run has ended and no provider process remains active. Otherwise it keeps the folder and explains why.
Understand workspace checks
A workspace can be reused and have multiple saved records. Before deletion, Crewplane checks that all records agree, the folder belongs to the expected repository, Git recognizes the worktree, and removal will not change a branch. If any check cannot be confirmed, it leaves the workspace in place.
3. Understand what remains
Keep the cache root separate
Cleanup rejects cache roots that are relative, symlinks, or overlap the project, .crewplane/, run artifact directories, or Git metadata paths.
Recognize managed entries
Cleanup scans the workspace-runs, workspaces, snapshots, and review-workspaces cache families. Destructive cleanup can also remove internal Git references created for the run.
Cache families and records
Cleanup targets managed caches and verified run-owned refs; canonical run artifacts remain.
Check Git reference ownership
Crewplane removes an internal reference only if it can confirm ownership and that it still points to the exact recorded commit. Changed or unverifiable references remain. Related workspace-result references are removed together to avoid a partial result.
Handle run records separately
Workspace cleanup leaves canonical workspace lineage, provider outputs, findings, run manifests, and result artifacts under .crewplane/. Crewplane has no run-record prune command; delete or archive the stage and result directories for a run according to your project policy.
.crewplane/execution-stages/<run-key>/.crewplane/execution-results/<run-key>/