# session-sweep

> Detect a Claude Code update and safely cycle stale cmux-hosted sessions (idle now; busy via interrupt-or-wait).

session-sweep is a paid AI agent skill on Agensi by chendrizzy (justin), in Workflow Automation. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $10 (one-time purchase)
- Creator: [chendrizzy (justin)](https://www.agensi.io/creators/chendrizzy)
- Category: [Workflow Automation](https://www.agensi.io/skills/workflow-automation)
- Version: 1.0
- Last updated: 2026-10-17
- Security: scan passed (2026-10-17); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/session-sweep
- Tags: ai-agents, automation, agents-orchestration, workflow-automation

## About this skill

### session-sweep

Check for a Claude Code update and safely cycle open **cmux-hosted** sessions
still on an older version. Idle sessions restart in place (same pane, same
conversation via cmux's tracked resume). Busy sessions get an interrupt-or-wait
choice.

**Canonical repo:** https://github.com/chendrizzy/session-sweep
Install: `npx skills add chendrizzy/session-sweep`

The engine is `sweep.sh` in that repo (with `sweep.bats`). This listing is the
operating procedure. It does not inline the script.

Companion: **self-cycle** (`https://github.com/chendrizzy/self-cycle`) for
refreshing *this* driver session last.

#### When to use

- User asks to update Claude Code sessions, refresh stale sessions, or mentions
  a new Claude Code version.
- Fleet of cmux panes; some still running an older `claude` binary.
- Preview: `sweep.sh --dry-run` before enabling any LaunchAgent.

#### When not to use

- **Not on cmux** — same hard dependency as self-cycle; no tmux/iTerm fallback.
- Background-agent surfaces (cmux cannot respawn/restore those).
- Looping `--force-cycle` across many surfaces (each call re-runs `claude update`
  and serializes on the lock) — cycle one, confirm, then next.
- Refreshing your own driver mid-sweep — that must be **last**, via self-cycle
  `/self-refresh`, and skipped if mid-task / `/goal` / pending monitors.
- Trusting a missing version banner alone — verify with process age (`etime`).

#### Permissions

| Need | Why |
|------|-----|
| `sweep.sh` + `bash` | Engine |
| `rtk proxy` (recommended) | Prevents output filters from hiding protocol lines |
| `cmux` with workspace-scoped respawn | Cycle panes in other workspaces |
| `claude update` | Version bump + lock |
| AskUserQuestion | Busy stale sessions |
| Writable state / logs | `state/last-sweep.log`, optional LaunchAgent log |

#### Expected output

Run interactive mode:

```bash
rtk proxy ~/.claude/skills/session-sweep/sweep.sh --mode=interactive
```

If stdout looks empty, read `state/last-sweep.log` (mirrored each run).

| Line | Agent action |
|------|----------------|
| `CYCLED <surface_id>` | Done for that pane |
| `CYCLE_FAILED <surface_id>` | Tell user to look manually — do not claim updated |
| `GRACE <surface_id>` | Waiting out idle grace; no action |
| `CYCLE <surface_id>` | Dry-run preview only |
| `INTERACTIVE_PROMPT <surface_id>` | AskUserQuestion Wait vs Interrupt; on Interrupt run `--force-cycle=<id>` and check exit status |

Order: handle all other surfaces first, report to the user, then optionally
self-refresh this driver via self-cycle.

#### Install / enable notes (honest)

Scheduled LaunchAgent must not exec through an external-volume symlink (launchd
`EX_CONFIG`). Prefer a plist that runs `/bin/bash <script>` and logs under
`~/Library/Logs/`. Leave enable/disable to the operator.

## Requires

- cmux
- Bash
- Node.js

## Known limitations

Requires cmux. Not compatible with tmux or iTerm. Cannot refresh background-agent surfaces. Each cycle call serializes on the claude update lock.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the session-sweep skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Why should I use Session Sweep instead of manually restarting my Claude Code sessions?

It cycles idle stale cmux panes in place and asks before interrupting a busy one. You still report the protocol lines. It does not replace looking at a pane that prints CYCLE_FAILED.

### Can I use this skill with standard terminal multiplexers like tmux?

No. It requires cmux, the same hard dependency as self-cycle. There is no tmux or iTerm path.

### What happens if I have a Claude Code session currently running a long task when I start the sweep?

Interactive mode prints INTERACTIVE_PROMPT for a busy stale pane and waits for Wait vs Interrupt. It does not interrupt on its own. A dry run only prints CYCLE lines and changes nothing.

### What exactly is included in the purchase of this skill?

This listing is the operating procedure. sweep.sh and sweep.bats install from https://github.com/chendrizzy/session-sweep (`npx skills add chendrizzy/session-sweep`). self-cycle is a separate companion and is not included.

### Is it possible to schedule these sweeps to run automatically at specific times?

The sweep is meant to be run interactively. A LaunchAgent is optional and left to the operator. launchd fails with EX_CONFIG if the job runs through an external-volume symlink; exec /bin/bash and log under ~/Library/Logs/.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
