---
title: "session-reaper"
url: "https://claudemods.dev/zh-cn/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-cn"
content_locale: "zh-cn"
---

# 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.
