Agent skill

Session Cleanup

by hoangsonww in hoangsonww/Claude-Code-Agent-Monitor

Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before…

MITAuto-check passed

Install Session Cleanup

skills CLI
$ npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-cleanup -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install hoangsonww/Claude-Code-Agent-Monitor session-cleanup --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/hoangsonww/Claude-Code-Agent-Monitor.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/ccam-sessions/skills/session-cleanup .claude/skills/session-cleanup && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
session-cleanup
GitHub stars
1.1k
Token cost
~834 tokens
SKILL.md length
386 words
Files
2
Skills in repo
78
Repo updated
First seen
Licence
MIT

At a glance

Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before…

  • Works in 5 steps: Baseline → Identify candidates → Preview table (ALWAYS shown) → …
  • Tidying the monitoring database
  • SKILL.md covers Input, Data Sources, Report Sections and Output, plus 1 more section
  • Calls npm

What it does

Session Cleanup is an agent skill from hoangsonww/Claude-Code-Agent-Monitor. Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before anything is deleted. Cleanup permanently deletes data, so this skill previews first and requires explicit user confirmation. Use when tidying the monitoring database.

Its SKILL.md is about 830 tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

The repository describes itself as: 🚀 A real-time monitoring dashboard for Claude Code & Codex, built with SQLite3, Node.js, Express, React, Vite, TailwindCSS, & WebSockets. It tracks sessions, agent activity… The licence is MIT.

When your agent uses it

  • Tidying the monitoring database

Example prompts

  • “/session-cleanup”

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Baseline
  2. Identify candidates
  3. Preview table (ALWAYS shown)
  4. Explain the endpoint
  5. Execute only on confirmation

What it can do on your machine

Read from SKILL.md and the folder at commit e0f4a1a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Session Cleanup loads about 834 tokens when it runs. Until then it costs about 94 tokens; SKILL.md has 386 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~94
When it runs · the whole SKILL.md, loaded when a task matches
~834

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from hoangsonww/Claude-Code-Agent-Monitor at commit e0f4a1a, republished under its MIT licence (© hoangsonww). 386 words, ~834 tokens.

Download SKILL.mdSave it as .claude/skills/session-cleanup/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
session-cleanup
description
Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before anything is deleted. Cleanup permanently deletes data, so this skill previews first and requires explicit user confirmation. Use when tidying the monitoring database.

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

EndpointReturns
GET /api/sessions?limit=Nsession list: id, status, model, cwd, started_at, ended_at, cost, metadata (turn_count, total_turn_duration_ms)
GET /api/statstotals: total_sessions, active_sessions, total_events, events_today, sessions_by_status, agents_by_status
POST /api/settings/cleanupruns 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 active — status 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.

Show full SKILL.md (164 more words)Show less
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.

Output

A preview Markdown table: id (short) | status | reason | cwd basename | started_at | cost, then a one-line count and the explicit "nothing deleted — re-run with confirm to proceed" notice. On a confirmed run, add a before → after summary using ▲/▼ on the counts. Currency as USD to 4 decimal places.

Safety

  • This is the ONLY skill in the plugin that mutates data, and only via the one documented endpoint.
  • NEVER call POST /api/settings/cleanup without an explicit confirm from the user in this turn — previewing is the default.
  • Never widen scope to POST /api/settings/clear-data or any other destructive endpoint; cleanup of stale/empty sessions only.
  • If the dashboard is unreachable, tell the user to start it with npm start from the repo root.

© hoangsonww, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in plugins/ccam-sessions/skills/session-cleanup of hoangsonww/Claude-Code-Agent-Monitor.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit e0f4a1a

Compare with similar skills

Session Cleanup next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Session Cleanup compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Session Cleanup this skillhoangsonww/Claude-Code-Agent-Monitor1.1k—~834Automated safety check: PassMIT
Agent Session Monitorhigress-group/higress9.5k—~3.3kAutomated safety check: PassApache-2.0
Session Handoffsickn33/agentic-awesome-skills47k—~1.8kAutomated safety check: NotesMIT
Cleanupsimstudioai/sim30k—~1.4kAutomated safety check: PassApache-2.0
Sessionanthropics/claude-for-legal9.6k3 repos~478Automated safety check: PassApache-2.0
Session History Searchslopus/happy24k—~3.1kAutomated safety check: PassMIT

Similar skills

  • Agent Session Monitor

    higress-group/higress

    Real-time agent conversation monitoring - monitors Higress access logs, aggregates conversations by session, tracks token usage.

    9.5k GitHub stars~3.3k tokensUpdated 4 days ago
    Data & AnalyticsAuto-check passed
  • Session Handoff

    sickn33/agentic-awesome-skills

    A skill your agent uses when context approaches capacity, before /clear or /compact, when switching tasks, or when ending a coding session: produces a structured handoff artifact for the next session.

    47k GitHub stars~1.8k tokensUpdated yesterday
    Agent WorkflowsAuto-check: notes
  • Cleanup

    simstudioai/sim

    Run all code quality skills — effects, memo, callbacks, state, React Query, emcn design review, url-state, comments, and test-audit — analyzing in parallel, then applying fixes sequentially

    30k GitHub stars~1.4k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Session

    anthropics/claude-for-legal

    Official

    Run a focused N-question study session on a subject — MBE, essay, or flashcards.

    9.6k GitHub starsUsed in 3 repos~478 tokens
    EducationAuto-check passed
  • Searches past Claude Code, Codex and Cursor sessions and summarizes what was worked on, tried or decided, using extraction scripts instead of reading raw logs.

    24k GitHub stars~3.1k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Qdrant Monitoring

    github/awesome-copilot

    Official

    Guides Qdrant monitoring and observability setup. An agent skill from github/awesome-copilot.

    40k GitHub starsUsed in 1 repo~276 tokens
    DevOps & CloudAuto-check passed

More from hoangsonww/Claude-Code-Agent-Monitor

All 78 skills in this repo
  • Budget Set

    hoangsonww/Claude-Code-Agent-Monitor

    Define a spend budget for Claude Code and, optionally, create a cost alert rule that fires when usage crosses the limit, via POST /api/alerts/rules on the Agent Monitor dashboard.

    1.1k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Version Release

    hoangsonww/Claude-Code-Agent-Monitor

    Choose and apply the correct semantic version bump for this repository.

    1.1k GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed
  • Cost Breakdown

    hoangsonww/Claude-Code-Agent-Monitor

    Break down Claude Code costs using the Agent Monitor pricing engine.

    1.1k GitHub starsUsed in 1 repo~845 tokens
    Auto-check passed
  • File Headers

    hoangsonww/Claude-Code-Agent-Monitor

    MANDATORY for every coding agent (Claude Code, Codex, or any other) on every change-set — every applicable source file the agent creates or updates MUST start with the project's copyright/authorship…

    1.1k GitHub starsUsed in 1 repo~1.1k tokens
    Auto-check passed
  • Hook Diagnostics

    hoangsonww/Claude-Code-Agent-Monitor

    Diagnose Claude Code hook installation, delivery, and ingestion issues.

    1.1k GitHub starsUsed in 1 repo~676 tokens
    Auto-check passed
  • Memory Review

    hoangsonww/Claude-Code-Agent-Monitor

    Review the file-based memory store via the Agent Monitor Config Explorer API: the user and project CLAUDE.md plus per-project auto-memory files under ~/.claude/projects/<slug/memory/.md.

    1.1k GitHub starsUsed in 1 repo~970 tokens
    Auto-check passed

Questions about Session Cleanup

What does Session Cleanup do?

Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before…. Session Cleanup is an agent skill from hoangsonww/Claude-Code-Agent-Monitor. Identify stale and empty Claude Code sessions in the Agent Monitor and explain the cleanup endpoint (POST /api/settings/cleanup), always showing the exact list of what WOULD be removed before anything is deleted.

When should I use Session Cleanup?

Session Cleanup fits situations like: tidying the monitoring database.

How do I install Session Cleanup in Claude Code?

Run `npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-cleanup -a claude-code`. Or copy the skill folder (plugins/ccam-sessions/skills/session-cleanup in hoangsonww/Claude-Code-Agent-Monitor) into .claude/skills/session-cleanup in your project. Claude Code loads it when a task matches its description.

How do I install Session Cleanup in Codex?

Run `npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-cleanup -a codex`. Or copy the skill folder (plugins/ccam-sessions/skills/session-cleanup in hoangsonww/Claude-Code-Agent-Monitor) into .agents/skills/session-cleanup in your project. Codex loads it when a task matches its description.

Can I use Session Cleanup in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill session-cleanup -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/session-cleanup, .gemini/skills/session-cleanup, .github/skills/session-cleanup and .opencode/skills/session-cleanup in your project.

What does Session Cleanup need to run?

Going by SKILL.md and its folder, Session Cleanup needs the command-line tools its instructions call (npm).

Does Session Cleanup access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Session Cleanup safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Session Cleanup use?

Session Cleanup is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Session Cleanup use?

About 834 tokens (SKILL.md is roughly 3.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Session Cleanup?

Skills that share tags, products or a category with Session Cleanup: Agent Session Monitor (higress-group/higress, 9.5k stars), Session Handoff (sickn33/agentic-awesome-skills, 47k stars), Cleanup (simstudioai/sim, 30k stars) and Session (anthropics/claude-for-legal, 9.6k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Session Cleanup?

hoangsonww (a GitHub user) maintains it in hoangsonww/Claude-Code-Agent-Monitor, which has 1,052 GitHub stars. The repository holds 78 skills in this directory. The repository was last updated on October 6, 2026.

Source: hoangsonww/Claude-Code-Agent-Monitor on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.