Safe Space Cleaner
Use the two bundled PowerShell cleanup scripts as the only automatic deletion engines. Keep audit reports private because they contain local paths and software-usage information.
Required references
Read references/safety-policy.md before every cleanup. Read references/windows-cleanup-categories.md when classifying candidates, explaining impact, or invoking a system or package-manager cleanup command.
Workflow
- Confirm the target is Windows and normalize the requested drive; default to
C:.
- Check available free space. Run both
space-cleaner.ps1 and managed-cache-cleaner.ps1 in audit mode before any deletion. Add -DeepScan to the file audit only when installer, package repository, and large-file discovery is needed. Do not install dependencies or request elevation merely to increase the result.
- Present three distinct groups:
- verified default plans: age-qualified files under fixed temporary roots, all files under fixed pure-cache roots whose owning application is closed, and pip/uv/npm cache cleanup through their owning commands;
- review-required candidates: old installers, archives, large files, diagnostic artifacts, environment-coupled package caches, and pure caches whose owning application is still active;
- protected locations: never directly delete.
- If the user requested only an audit, stop after reporting. If the same request explicitly authorizes cleanup, execute both verified default plans using each plan's full SHA-256 token. General cleanup authorization covers these default plans but never review-required candidates.
- Require explicit IDs or exact paths before acting on review-required candidates. Prefer the owning application's official cleanup command over direct directory deletion. Re-check active processes and impact immediately before execution.
- Compare drive space before and after. Run
scripts/check-report.ps1 on every audit and cleanup JSON report, then inspect structured errors or warnings. Do not search arbitrary path text for words such as warning or nan; filenames can create false positives.
- Report what was deleted, what was skipped, measured space change, remaining review candidates, protected items, and private report paths.
Commands
Resolve the skill directory first, then run its script.
# Read-only audit with deep candidate discovery
& "$skillRoot\scripts\space-cleaner.ps1" `
-Mode Audit -Drive C -Profile Aggressive -MinAgeDays 7 -DeepScan `
-ReviewTimeoutSeconds 180 `
-ReportDirectory .\local-reports
# Execute only the exact automatic plan produced above
& "$skillRoot\scripts\space-cleaner.ps1" `
-Mode Clean -Drive C -PlanPath <plan.json> `
-ConfirmationToken <full-sha256-token> `
-ReportDirectory .\local-reports
# Audit pip, uv, and npm pure caches through their owning tools
& "$skillRoot\scripts\managed-cache-cleaner.ps1" `
-Mode Audit -Drive C -ReportDirectory .\local-reports
# Execute only the exact managed-cache plan produced above
& "$skillRoot\scripts\managed-cache-cleaner.ps1" `
-Mode Clean -Drive C -PlanPath <managed-plan.json> `
-ConfirmationToken <full-sha256-token> `
-ReportDirectory .\local-reports
# Human-operated audit and confirmation prompt
& "$skillRoot\scripts\space-cleaner.ps1" `
-Mode Interactive -Drive C -Profile Aggressive -DeepScan `
-ReportDirectory .\local-reports
# Validate an audit or cleanup JSON without filename-text false positives
& "$skillRoot\scripts\check-report.ps1" -Path <report.json>
Use Safe for a 30-day minimum retention period for temporary files. Use Aggressive for the requested retention period, normally 7 days. Both profiles clear allowlisted pure caches without an age threshold and keep review candidates out of the default plans.
Review-required actions
After item-level approval:
- Re-measure the candidate and confirm it is unchanged.
- Refuse to clear an application cache while its owning process is active. For package-manager caches, use only the verified owning command and its documented locking behavior.
- Run package-manager commands exactly as documented, including both npm content-cache and npx-cache cleanup; never hard-delete a cache root or package repository.
- Delete an old installer, archive, dump, or other user-visible file only by exact literal path, never by wildcard or recursive parent removal.
- Append the command, selected IDs, before/after sizes, exit code, output summary, and any skipped items to a new report beside the automatic cleanup report.
Non-negotiable safeguards
- Never delete a directory recursively during automatic cleanup. Delete only exact files from a token-verified plan.
- Clear pip, uv, npm content, and npx caches only through their owning commands from a token-verified managed plan; never hard-delete their cache roots.
- Never follow reparse points, junctions, symlinks, or offline placeholders.
- Skip a file if its path, root, size, timestamp, age, attributes, or drive changed after audit.
- Never directly delete Windows component, installer, update, paging, hibernation, restore, recycle-bin, cloud, virtual-disk, environment, library, project, document, download, or desktop data.
- Never stop processes, services, Windows Update, or security software to force a deletion.
- Never publish a real user's reports, paths, filenames, account names, or cache inventory.
Validation
Run the isolated regression test after modifying the script:
powershell -NoProfile -ExecutionPolicy Bypass -File .\tests\test-space-cleaner.ps1
The test must prove old-file deletion, recent-file retention, immediate pure-cache deletion, changed-file retention, both plan-token guards, junction non-traversal, and all three managed-cache commands. Then run quick_validate.py against the skill directory.
1---2name: safe-space-cleaner3description: Audit and safely reclaim disk space on Windows, defaulting to C:, with verified temporary-file and pure-cache cleanup, review-required installer and large-file candidates, protected-path exclusions, interactive confirmation, and complete JSON/CSV/Markdown reports. Use when a user asks to inspect, clean, free, or explain disk space on a Windows drive; remove temporary or cache files; find old installers or large files; or produce an auditable cleanup report. Do not use for partitioning, formatting, registry cleaners, non-Windows systems, or deleting user content without item-level approval.4---56# Safe Space Cleaner78Use the two bundled PowerShell cleanup scripts as the only automatic deletion engines. Keep audit reports private because they contain local paths and software-usage information.910## Required references1112Read [references/safety-policy.md](references/safety-policy.md) before every cleanup. Read [references/windows-cleanup-categories.md](references/windows-cleanup-categories.md) when classifying candidates, explaining impact, or invoking a system or package-manager cleanup command.1314## Workflow15161. Confirm the target is Windows and normalize the requested drive; default to `C:`.172. Check available free space. Run both `space-cleaner.ps1` and `managed-cache-cleaner.ps1` in audit mode before any deletion. Add `-DeepScan` to the file audit only when installer, package repository, and large-file discovery is needed. Do not install dependencies or request elevation merely to increase the result.183. Present three distinct groups:19 - verified default plans: age-qualified files under fixed temporary roots, all files under fixed pure-cache roots whose owning application is closed, and pip/uv/npm cache cleanup through their owning commands;20 - review-required candidates: old installers, archives, large files, diagnostic artifacts, environment-coupled package caches, and pure caches whose owning application is still active;21 - protected locations: never directly delete.224. If the user requested only an audit, stop after reporting. If the same request explicitly authorizes cleanup, execute both verified default plans using each plan's full SHA-256 token. General cleanup authorization covers these default plans but never review-required candidates.235. Require explicit IDs or exact paths before acting on review-required candidates. Prefer the owning application's official cleanup command over direct directory deletion. Re-check active processes and impact immediately before execution.246. Compare drive space before and after. Run `scripts/check-report.ps1` on every audit and cleanup JSON report, then inspect structured errors or warnings. Do not search arbitrary path text for words such as `warning` or `nan`; filenames can create false positives.257. Report what was deleted, what was skipped, measured space change, remaining review candidates, protected items, and private report paths.2627## Commands2829Resolve the skill directory first, then run its script.3031```powershell32# Read-only audit with deep candidate discovery33& "$skillRoot\scripts\space-cleaner.ps1" `34 -Mode Audit -Drive C -Profile Aggressive -MinAgeDays 7 -DeepScan `35 -ReviewTimeoutSeconds 180 `36 -ReportDirectory .\local-reports3738# Execute only the exact automatic plan produced above39& "$skillRoot\scripts\space-cleaner.ps1" `40 -Mode Clean -Drive C -PlanPath <plan.json> `41 -ConfirmationToken <full-sha256-token> `42 -ReportDirectory .\local-reports4344# Audit pip, uv, and npm pure caches through their owning tools45& "$skillRoot\scripts\managed-cache-cleaner.ps1" `46 -Mode Audit -Drive C -ReportDirectory .\local-reports4748# Execute only the exact managed-cache plan produced above49& "$skillRoot\scripts\managed-cache-cleaner.ps1" `50 -Mode Clean -Drive C -PlanPath <managed-plan.json> `51 -ConfirmationToken <full-sha256-token> `52 -ReportDirectory .\local-reports5354# Human-operated audit and confirmation prompt55& "$skillRoot\scripts\space-cleaner.ps1" `56 -Mode Interactive -Drive C -Profile Aggressive -DeepScan `57 -ReportDirectory .\local-reports5859# Validate an audit or cleanup JSON without filename-text false positives60& "$skillRoot\scripts\check-report.ps1" -Path <report.json>61```6263Use `Safe` for a 30-day minimum retention period for temporary files. Use `Aggressive` for the requested retention period, normally 7 days. Both profiles clear allowlisted pure caches without an age threshold and keep review candidates out of the default plans.6465## Review-required actions6667After item-level approval:6869- Re-measure the candidate and confirm it is unchanged.70- Refuse to clear an application cache while its owning process is active. For package-manager caches, use only the verified owning command and its documented locking behavior.71- Run package-manager commands exactly as documented, including both npm content-cache and npx-cache cleanup; never hard-delete a cache root or package repository.72- Delete an old installer, archive, dump, or other user-visible file only by exact literal path, never by wildcard or recursive parent removal.73- Append the command, selected IDs, before/after sizes, exit code, output summary, and any skipped items to a new report beside the automatic cleanup report.7475## Non-negotiable safeguards7677- Never delete a directory recursively during automatic cleanup. Delete only exact files from a token-verified plan.78- Clear pip, uv, npm content, and npx caches only through their owning commands from a token-verified managed plan; never hard-delete their cache roots.79- Never follow reparse points, junctions, symlinks, or offline placeholders.80- Skip a file if its path, root, size, timestamp, age, attributes, or drive changed after audit.81- Never directly delete Windows component, installer, update, paging, hibernation, restore, recycle-bin, cloud, virtual-disk, environment, library, project, document, download, or desktop data.82- Never stop processes, services, Windows Update, or security software to force a deletion.83- Never publish a real user's reports, paths, filenames, account names, or cache inventory.8485## Validation8687Run the isolated regression test after modifying the script:8889```powershell90powershell -NoProfile -ExecutionPolicy Bypass -File .\tests\test-space-cleaner.ps191```9293The test must prove old-file deletion, recent-file retention, immediate pure-cache deletion, changed-file retention, both plan-token guards, junction non-traversal, and all three managed-cache commands. Then run `quick_validate.py` against the skill directory.