---
title: "session-reaper"
url: "https://claudemods.dev/zh-tw/builds/session-reaper-e0f4b0"
source: "https://github.com/IT-BAER/claude-forge/tree/main/mods/session-reaper"
source_type: "github"
repo: "https://github.com/IT-BAER/claude-forge/tree/main/mods/session-reaper"
author: "IT-BAER"
author_handle: "IT-BAER"
stars: 1
category: "記憶與上下文"
categories: ["memory"]
tags: ["hooks", "idle-archive", "process-cleanup", "resource-usage", "session-management", "windows"]
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add IT-BAER/claude-forge\nclaude plugin install session-reaper@claude-forge"
added: "2026-10-11T20:09:28.484Z"
updated: "2026-10-11T18:44:33Z"
locale: "zh-tw"
content_locale: "zh-tw"
---

# session-reaper

一個 Claude Code 桌面模組，用於封存超過逾時時間的閒置 Code 工作階段，並停止已結束工作階段遺留的閒置處理程序樹，在 Windows 上回收記憶體與認可費用。

## Description

session-reaper 是適用於 Windows 上 Claude 桌面應用程式的 Claude Code 模組。每隔幾分鐘它會（1）封存閒置時間超過可設定限制（預設 60 分鐘）的 Code 工作階段，跳過執行中/釘選/背景忙碌的工作階段（可從已封存清單還原），並（2）在工作階段的 claude.exe 消失後，停止該工作階段遺留的處理程序樹，僅當每個處理程序都足夠舊且 CPU 閒置時，並帶有瀏覽器、編輯器、檔案總管和終端機的安全清單。

動機：每個桌面 Code 工作階段會保留自己約 0.8 GB 的 claude.exe 以及每個 MCP 伺服器的副本；一天的工作留下了 38 個 claude.exe（15 GB）和 88 個 node.exe（8 GB），使認可費用達到 47.1/47.6 GB 並導致 Chrome 當機。封存閒置工作階段並停止遺留處理程序後，將其降至 30 GB。

需求：Windows 在 C:\Windows 中（使用固定路徑的 PowerShell 和 Win32_Process）；桌面應用程式的 Code 索引標籤用於透過 ccd_session_mgmt 伺服器執行封存步驟（自動模式需要在 permissions.allow 中包含 "mcp__ccd_session_mgmt__archive_session"）；其他主機僅執行處理程序步驟。

安裝：/plugin install session-reaper --marketplace IT-BAER/claude-forge

選項：idleMinutes (60)、orphanMinutes (60)、cpuIdleMs (1000)、intervalMinutes (5)。僅追蹤模組執行期間在正在執行的 claude.exe 下觀察到的處理程序。

## Install

```
claude plugin marketplace add IT-BAER/claude-forge
claude plugin install session-reaper@claude-forge
```

## Original README

# session-reaper

A Claude Code mod for the Claude desktop app on Windows. Every few minutes it:

1. Archives Code sessions that had no activity for longer than a limit (default 60 minutes). Running and pinned sessions are skipped; the app itself also refuses sessions that are open on screen or still have background work. Archived sessions can be restored from the Archived list.
2. Stops process trees that a session left behind. It records every process a `claude.exe` started (MCP servers, dev servers, shells). Once that `claude.exe` is gone, a tree is stopped only when every process in it is at least 60 minutes old and used almost no CPU since the previous check. `chrome.exe`, `msedge.exe`, `Code.exe`, `claude.exe`, `explorer.exe` and `WindowsTerminal.exe` are never stopped.

Every open session loads the mod, but only one of them does the work (a heartbeat in the plugin store picks it).

## Why it exists

Each desktop Code session keeps its own `claude.exe` (about 0.8 GB) plus its own copy of every MCP server, and none of it goes away while the session sits in the sidebar. On a 32 GB machine, a day of work left 38 `claude.exe` (15 GB) and 88 `node.exe` (8 GB) processes running, the commit charge reached 47.1 of 47.6 GB, and Chrome crashed with an out-of-memory error. Archiving the idle sessions and stopping their leftover processes brought the commit charge down to 30 GB.

## Requirements

- Windows installed in `C:\Windows` (the process step runs `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe` by its fixed path and reads `Win32_Process`).
- The Claude desktop app's Code tab. The archive step calls the app's `ccd_session_mgmt` server, which other hosts (CLI, VS Code) do not have; there only the process step runs.
- In auto permission mode the archive call from a mod is refused unless it is allowed. Add this rule to `permissions.allow` in `~/.claude/settings.json`:

  ```json
  "mcp__ccd_session_mgmt__archive_session"
  ```

  The rule also lets Claude archive sessions in any chat without asking.

## Install

```
/plugin install session-reaper --marketplace IT-BAER/claude-forge
```

## Options

| Option | Default | Meaning |
| --- | --- | --- |
| `idleMinutes` | 60 | Archive a session idle for this many minutes |
| `orphanMinutes` | 60 | Minimum age of every process in a left-behind tree |
| `cpuIdleMs` | 1000 | Most CPU time (ms) a process may use between two checks and still count as idle |
| `intervalMinutes` | 5 | How often the active session checks |

Only processes seen under a running `claude.exe` while the mod runs are tracked; trees left behind before the mod loaded are not touched.
