Add cleanup/GC for stale session artifacts (todos, team inboxes, sub-agent state)
Resolved 💬 3 comments Opened Apr 7, 2026 by kofort9 Closed Apr 11, 2026
Problem
Claude Code accumulates stale artifacts on disk with no built-in cleanup mechanism:
~/.claude/todos/— task files from sub-agents pile up indefinitely. After moderate usage, 80+ orphaned JSON files accumulate.~/.claude/teams/*/inboxes/— team agent inboxes persist after the team session ends.~/.claude/sessions/— session files remain even after the owning process dies (e.g., a 14-day-old zombie session with a dead PID).- Sub-agent autocomplete ghosts — agents spawned in other active sessions (e.g.,
@scrutinize2-632,@economist-r1,@agent-638) appear in the@autocomplete across all sessions, with no way to dismiss or clean them up.
There is no claude gc, claude sessions --prune, or equivalent. The only recourse is manually rm-ing files.
Expected behavior
- Session files should be cleaned up when the owning PID is no longer running (on startup or periodically)
- Todo files should be removed when their owning session exits
- Team inboxes should be pruned when no active process references them
- Sub-agent names should be scoped to their parent session and not leak into other sessions' autocomplete
- Ideally: a
claude gcorclaude cleanCLI command for on-demand pruning
Current workaround
rm ~/.claude/todos/*.json
rm ~/.claude/teams/default/inboxes/*.json
# Manually kill stale PIDs from ~/.claude/sessions/
Environment
- macOS (Darwin 25.3.0)
- Claude Code CLI (latest as of 2026-04-07)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗