moon clean command will clean the current workspace by deleting stale cache. For the most
part, the action pipeline will clean automatically, but this command can be used to reset the
workspace entirely.
Options
--lifetime <duration>
The maximum lifetime of cached artifacts before being marked as stale. Defaults to 7 days.
The duration format supports:
- Seconds:
30s,60 seconds - Minutes:
15m,30 minutes - Hours:
2h,12 hours - Days:
7d,30 days - Weeks:
2w,4 weeks - Months:
1mo,3 months
--all
Clean all cached items and reset state, regardless of age. This is equivalent to --reset.
- All cached task outputs
- All hash manifests
- All temporary files
- State files (
.moon/cache/states)
What Gets Cleaned
The clean command removes:Cached Outputs
Task outputs stored in.moon/cache/outputs/ including:
- Build artifacts
- Test results
- Generated files
Hash Manifests
Hash manifests in.moon/cache/hashes/ that track input changes:
- Task input hashes
- Dependency hashes
State Files
Workspace state files in.moon/cache/states/ including:
- Action graph states
- Run history
- Hydration states
Cache Behavior
Moon’s cache is content-addressable and automatically invalidates when:- Source files change
- Dependencies are updated
- Configuration changes
- Environment variables change
clean command is useful for:
- Freeing disk space
- Debugging cache issues
- Starting fresh after major changes
- CI/CD cleanup tasks
Examples
Clean old cache
Clean cache older than custom duration
Reset all cache
Automation
You can automate cache cleaning in CI/CD:Performance
The clean command:- Runs quickly (typically < 1 second)
- Only scans cache directories
- Uses file timestamps for age determination
- Reports bytes saved after completion