session-cleanup

session-cleanup is a skill for Claude Code, Codex from hoangsonww/Claude-Code-Agent-Monitor. It costs 67 tokens per session (805 once invoked), scanned A, original, MIT.

A cleanup guide for finding empty or stale Claude Code sessions in Agent Monitor, with a preview of the records marked for removal.

In plain words
What is it for?
Use it to review session statistics, identify sessions with no useful activity or those older than a chosen age, and run the cleanup endpoint after approval.
Why use it?
It helps prevent accidental permanent deletion by showing the exact candidates first and requiring confirmation before cleanup.

Skill for Claude CodeCodex

Written for Claude Code and Codex: $ARGUMENTS substitution, but also agents/openai.yaml present. Also seen: mentions Claude Code.

Part of the ccam-sessions plugin — 5 skills, 3 commands, 1 agent shipped together

Good fit Use it to review session statistics, identify sessions with no useful activity or those older than a chosen age, and run the cleanup endpoint after approval.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hoangsonww/claude-code-agent-monitor/session-cleanup
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-cleanup
Clone the repo
git clone --depth 1 https://github.com/hoangsonww/Claude-Code-Agent-Monitor

Made for: Claude Code, Codex.

Or install ccam-sessions, the plugin that ships this one along with the rest of its 5 skills, 3 commands, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for session-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/hoangsonww/claude-code-agent-monitor/session-cleanup/github.svg)](https://agentmods.dev/skills/hoangsonww/claude-code-agent-monitor/session-cleanup)
Your own site
<a href="https://agentmods.dev/skills/hoangsonww/claude-code-agent-monitor/session-cleanup"><img src="https://agentmods.dev/badge/skills/hoangsonww/claude-code-agent-monitor/session-cleanup/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for session-cleanup

Your own site · 80×15
<a href="https://agentmods.dev/skills/hoangsonww/claude-code-agent-monitor/session-cleanup"><img src="https://agentmods.dev/badge/skills/hoangsonww/claude-code-agent-monitor/session-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 805 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00067 $0.00805
Opus 5 $0.00034 $0.00402
Sonnet 5 $0.00013 $0.00161
Haiku 4.5 $0.00007 $0.00081

Measured 8d ago against content hash 061eb2f9277d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

session-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/ccam-sessions/skills/session-cleanup/SKILL.md · 78 lines

How it starts

The opening of the file, as written. The whole thing — 78 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Session Cleanup

Find prune-worthy sessions and explain cleanup — preview first, delete only on explicit confirmation.

Input

The user provides: $ARGUMENTS

  • Empty / preview → only show what would be removed (the safe default).
  • confirm → the user has reviewed the preview and explicitly authorizes deletion.
  • An optional staleness threshold (e.g. older than 7d) for what counts as stale.

Data Sources

Endpoint Returns
GET /api/sessions?limit=N session list: id, status, model, cwd, started_at, ended_at, cost, metadata (turn_count, total_turn_duration_ms)
GET /api/stats totals: total_sessions, active_sessions, total_events, events_today, sessions_by_status, agents_by_status
POST /api/settings/cleanup runs the cleanup routine and returns what was removed — DESTRUCTIVE, only after confirmation

Report Sections

1. Baseline

GET /api/stats — record total_sessions, sessions_by_status, total_events. This is the before-state to compare against.

2. Identify candidates

GET /api/sessions?limit=1000. Flag sessions that are:

  • Empty — zero events and turn_count 0 / null and cost 0 (started but never did anything).
  • Stale activestatus active/working but last activity older than the threshold (default 24h), i.e. never cleanly stopped.
  • Truncated — no ended_at and no recent events.

3. Preview table (ALWAYS shown)

List every candidate with the reason it qualifies. State the total count and confirm that nothing has been deleted yet.

4. Explain the endpoint

Describe POST /api/settings/cleanup: it prunes empty / orphaned sessions and their dangling events server-side and returns a summary of removed rows. Make clear this is permanent and not reversible from the dashboard.

5. Execute only on confirmation

If — and only if — $ARGUMENTS is confirm (or the user has explicitly approved this run), call POST /api/settings/cleanup, then re-read /api/stats and report the before → after delta. Otherwise stop after the preview and tell the user to re-run with confirm.

Read the full file on GitHub · 78 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 78 lines · 67 tokens per session scan A 061eb2f9277d

Subscribe to this mod's changes

session-cleanup is a skill published in the GitHub repository hoangsonww/Claude-Code-Agent-Monitor (989 stars, last pushed 3d ago), licensed MIT. It adds 67 tokens to every session and 805 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.