add temp verb for WSL scratch sizing and selective wipe#26
Merged
Conversation
New `claudearium temp [size | clean -Scope <s>] [-IncludeTodos]
[-IncludePlans] [-Force]`. Three scopes:
tmp — /tmp (tmpfs, fully safe to wipe)
cache — /home/claude/.cache (npm/pip/cargo caches)
claude — /home/claude/.claude (Claude Code state). Default wipe:
projects/ (transcripts) + shell-snapshots/. Preserved:
todos/, plans/, host-tools/. -IncludeTodos / -IncludePlans
widen the wipe; host-tools/ is never wiped.
The central dashboard''s status block grows a `Scratch:` row that
surfaces total + per-scope sizes. The in-distro `du -sb` is capped
with `timeout 3` so a power user''s ~/.claude (months of transcripts =
hundreds of thousands of small files) can''t block the menu render.
- modules/Temp.psm1 (new): Get-ScratchSizes (batched du -sb with
timeout), Clear-Scratch by scope. The claude scope''s preserve set
(todos/plans/host-tools) lives in a module-local constant so the
pure tests can pin the contract.
- claudearium.ps1: Invoke-Temp / Invoke-TempSize / Invoke-TempClean
verbs, central-dashboard Scratch row, -IncludeTodos / -IncludePlans
script params.
- Tests: pure (du-output parsing, claude-scope wipe-set logic with
and without -IncludeTodos / -IncludePlans, tmp/cache use mindepth 1
— 7 cases) + distro (seed every scratch dir with a sentinel, run
temp clean -Scope all -Force, assert wiped vs preserved set; also
the -IncludeTodos -IncludePlans extension). Pure: 373/373 locally.
- Docs: usage.md, cookbook.md, architecture.md, testing.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new temp verb to claudearium.ps1 that surfaces and selectively wipes WSL-side scratch space (/tmp, ~/.cache, ~/.claude), plus a Scratch: row on the central dashboard. The claude scope is selectively destructive — wipes transcripts (projects/) and shell-snapshots/ by default while preserving todos/, plans/, and host-tools/ (the last is never wipeable). Get-ScratchSizes uses a single in-distro batched du -sb capped with timeout 3 to bound dashboard render time.
Changes:
- New
modules/Temp.psm1exposesGet-ScratchSizesandClear-Scratch(with-IncludeTodos/-IncludePlansto widen theclaude-scope wipe). claudearium.ps1wires thetempverb (subverbssize/clean) with confirmation, before/after sizing, and aScratch:row on the central dashboard.- Pure + distro Pester coverage with corresponding registry entries and doc updates (usage/cookbook/architecture/testing).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/Temp.psm1 | New module providing scratch sizing + scope-aware wipe primitives. |
| claudearium.ps1 | Adds Invoke-Temp / Invoke-TempSize / Invoke-TempClean, dispatch entry, help text, and Scratch dashboard row. |
| tests/pure/Temp.Tests.ps1 | Mocks the in-distro probe to pin parse + claude/tmp/cache wipe-set logic. |
| tests/distro/Temp.Tests.ps1 | End-to-end seeds scratch dirs, runs temp clean, and asserts wipe/preserve contract. |
| tests/lib/TestRegistry.psm1 | Registers new pure/Temp and distro/Temp entries. |
| docs/usage.md, docs/cookbook.md, docs/architecture.md, docs/testing.md | Documents the new verb, examples, module placement, and updated test counts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1372
to
+1397
| if ($scope -in @('claude','all')) { | ||
| $wipe = @('projects','shell-snapshots') | ||
| if ($IncludeTodos) { $wipe += 'todos' } | ||
| if ($IncludePlans) { $wipe += 'plans' } | ||
| $preserved = @('todos','plans','host-tools') | Where-Object { $wipe -notcontains $_ } | ||
| Write-Host '' | ||
| Write-Host ' claude scope:' | ||
| Write-Host (" wipe: " + (($wipe | ForEach-Object { "~/.claude/$_/" }) -join ', ')) | ||
| if ($preserved) { | ||
| Write-Host (" preserved: " + (($preserved | ForEach-Object { "~/.claude/$_/" }) -join ', ')) | ||
| } | ||
| } | ||
|
|
||
| if (-not $Force) { | ||
| $ok = Read-YesNo -Prompt "Wipe the above?" -Default $false -NonInteractive:$NonInteractive | ||
| if (-not $ok) { Write-Host 'Aborted.' -ForegroundColor Yellow; return } | ||
| } | ||
|
|
||
| foreach ($t in $targets) { | ||
| $extra = @{} | ||
| if ($t -eq 'claude') { | ||
| if ($IncludeTodos) { $extra.IncludeTodos = $true } | ||
| if ($IncludePlans) { $extra.IncludePlans = $true } | ||
| } | ||
| $r = Clear-Scratch -DistroName $DistroName -Scope $t @extra | ||
| Write-Host (" [$t] removed $($r.Removed) — $($r.PreservedNote)") -ForegroundColor Green |
Comment on lines
+3717
to
+3726
| # Scratch sizes are one short `du -sb` in-distro — fast on a | ||
| # running distro, skipped when it's stopped to avoid waking it. | ||
| $scratchLine = '-' | ||
| if ($state -eq 'Running') { | ||
| try { | ||
| $sz = Get-ScratchSizes -DistroName $distro | ||
| $scratchLine = ("{0} (tmp {1}, cache {2}, claude {3})" -f ` | ||
| (Format-Bytes -Bytes $sz.total), (Format-Bytes -Bytes $sz.tmp), | ||
| (Format-Bytes -Bytes $sz.cache), (Format-Bytes -Bytes $sz.claude)) | ||
| } catch { $scratchLine = '?' } |
| BeforeEach { | ||
| $script:capturedScript = $null | ||
| Mock -ModuleName Temp Invoke-InDistroScript { | ||
| param($Name, $User, $Script, $AllowFail) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New verb
claudearium temp [size | clean -Scope <s>]plus aScratch:row on the central dashboard. Three scopes:tmp(/tmp) — fully safe.cache(/home/claude/.cache) — safe, first-build penalty.claude(/home/claude/.claude) — selectively destructive. Wipesprojects/(transcripts) andshell-snapshots/by default; preservestodos/,plans/,host-tools/.-IncludeTodos/-IncludePlanswiden the wipe.host-tools/is never wiped (tool-managed).The dashboard''s
du -sbis capped withtimeout 3so a heavy~/.claudedoesn''t block the menu render.Test plan
.\test-claudearium.ps1 -ParseCheck(74 files clean).\test-claudearium.ps1 -Auto -Only pure -CI(373/373, +7 new)tests/distro/Temp.Tests.ps1seeds each scratch dir + asserts the wipe / preserve settempagainst a busy distro,temp clean -Scope cache -Forcereclaims real bytes🤖 Generated with Claude Code