| name | archive-stale-chats |
| description | Archive Claude Code chat sessions that haven't been used in the last N days (default 2). Lists sessions, surfaces decisions (open PRs, directory scope), re-pulls fresh IDs, then archives in batches with confirmation. Use when asked to "archive old chats", "clean up unused chats/sessions", or "archive chats not used in X days". |
| allowed-tools | mcp__ccd_session_mgmt__list_sessions, mcp__ccd_session_mgmt__archive_session |
/archive-stale-chats — Archive inactive Claude Code chats
Archive Claude Code (CCD) chat sessions that have gone quiet, so the sidebar only
shows recent work. Archived chats are not deleted — they move to the
Archived list and can be reopened anytime.
When to use
- "Archive any chats not used in the last 2 days"
- "Clean up my old / unused chats"
- "Archive everything except "
Inputs
- Window — default 2 days. Honor any threshold the user gives ("a week", "3 days").
- Scope (optional) — only chats whose
cwd is under a given directory.
- Exceptions (optional) — chats to keep regardless, named by the user.
Tools
mcp__ccd_session_mgmt__list_sessions — list sessions. The current session is
always excluded from results, so it can never be archived by accident.
mcp__ccd_session_mgmt__archive_session — archive one session by sessionId.
Procedure
-
List. Call list_sessions with a high limit (e.g. 200) and
include_archived: false. Each row has sessionId, title, cwd,
isRunning, lastActivityAt, and sometimes prNumber / prState.
-
Compute the cutoff. cutoff = now − window. A session is stale if its
lastActivityAt is older than the cutoff. Treat the boundary day inclusively
unless the user is precise about hours.
-
Split keep vs archive. Keep:
- anything newer than the cutoff,
isRunning: true sessions,
- any explicit user exceptions.
If a scope was given, only consider sessions whose cwd is under that path,
and explicitly flag the ones you're skipping because they live elsewhere.
-
Surface decisions before archiving (one clear prompt, plain language):
- Sessions with an open PR (
prState: "OPEN"): archiving stops the session
and cleans up its git worktree. Default to keeping these unless told
otherwise.
- State the total count, and warn that each archive needs its own confirmation
click — there is no bulk archive, and
archive_session is unavailable in
unsupervised / auto-accept (bypass-permissions) mode (it will error with
"requires user approval"). If that happens, ask the user to switch to a
supervised mode and resume.
-
Re-list immediately before archiving. Pull a fresh list_sessions and copy
each sessionId directly from that output. Do not retype IDs from an older
message — sessionIds are long UUIDs and a single wrong character fails with
"Session not found." A fresh list also drops anything already archived.
-
Archive in batches of ~15–20 per message. For each, call archive_session
with the sessionId and a short reason (e.g. "Inactive 2+ days — <title>").
Never pass the current session's id (it won't be in the list anyway).
-
Verify. After the batches, call list_sessions once more and confirm only
the intended keepers remain. Report how many were archived and what was kept.
Notes
- Archiving is reversible — reopen from the Archived list. It stops the
session process and, by default, removes that session's git worktree.
- For recurring cleanup tied to PRs, point the user at the "Auto-archive on PR
close" preference in Settings instead of running this repeatedly.
- Sidebar groups are a separate, UI-only feature — this skill does not touch
them.