Skip to content

machine-health: no detection for the Claude Code temp root (2.96 GB unpruned in 10 days) #1637

Description

@kyle-sexton

Context

Claude Code's per-session scratchpad tree accumulates without any observed pruning. Measured on one machine over 10 days:

  • %LOCALAPPDATA%\Temp\claude — 34,968 files, 3.6 GB total; the scratchpad subtrees alone are 230 directories, 31,260 files, 2.96 GB.
  • 219 session directories under a single project key; 45 CWD-derived project keys in total.
  • Oldest directory 10 days old, newest same-day — nothing in between was reclaimed.

For contrast, the surface that DOES have a documented cleanup owner — ~/.claude/jobs/<id>/tmp/, "Removed when the session is deleted" — measures 1 MB across 6 directories on the same machine. Three orders of magnitude, and the difference is precisely whether a cleanup owner exists.

Neither shipped hygiene plugin covers this today:

  • plugins/disk-hygiene/skills/clean owns the concern by charter — "orphaned, temporary, stale-lock, failed-write, partial-download, and empty leftover artifacts", arbitrary target directory, confidence tiers, per-tier approval — but it is disable-model-invocation: true and manual-only, so it never notices growth; someone has to already suspect it and aim it.
  • plugins/machine-health/skills/audit is the proactive surface but does not track this path (grep for AppData / LOCALAPPDATA / /tmp/claude under plugins/repo-hygiene/ and plugins/disk-hygiene/ returns nothing relevant).

So the concern has an owner for removal and no owner for detection.

Cost of leaving it: multi-gigabyte silent growth on every developer machine, discovered only when a volume fills.

Proposed work

  • Add a disk-growth check for the Claude Code temp root to plugins/machine-health/skills/audit: %LOCALAPPDATA%\Temp\claude on Windows, /tmp/claude (or $TMPDIR-derived) on POSIX, honoring CLAUDE_CODE_TMPDIR when set since it relocates the root.
  • Report size, directory count, and oldest-entry age with trend-aware severity, per the audit skill's existing catalog shape.
  • Route remediation to disk-hygiene:clean rather than removing anything from machine-health — detection and removal stay separately owned.
  • Ensure any removal path cannot delete a LIVE session's scratchpad. A session's own directory is addressable via CLAUDE_CODE_SESSION_ID (documented at env-vars.md:305, and empirically equal to the scratchpad path's UUID segment), but a concurrently running OTHER session is the real hazard — age-based tiers must account for it.

Acceptance criteria

  • machine-health:audit reports size, entry count, and oldest-entry age for the Claude Code temp root on Windows and POSIX.
  • The check honors CLAUDE_CODE_TMPDIR when set.
  • Findings route to disk-hygiene:clean for removal; machine-health removes nothing itself.
  • disk-hygiene's safety model documents the live-session hazard and how its confidence tiers avoid deleting an in-use scratchpad.
  • The check degrades quietly when the path does not exist (per the prerequisite-classification rule: not applicable exits quietly).

References

  • plugins/disk-hygiene/skills/clean/SKILL.md — charter, disable-model-invocation: true, manual-only
  • plugins/disk-hygiene/skills/clean/reference/safety-model.md — where the live-session hazard belongs
  • plugins/machine-health/skills/audit — versioned check catalog with trend-aware severity
  • Claude Code docs env-vars.md:330 (CLAUDE_CODE_TMPDIR), env-vars.md:305 (CLAUDE_CODE_SESSION_ID), agent-view "Where state is stored" (~/.claude/jobs/<id>/tmp/ — the documented-cleanup contrast)
  • docs/PLUGIN-PHILOSOPHY.md — prerequisites and failure behavior (not-applicable exits quietly)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumReal value, no hard deadline; normal backlog flow.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions