prune-learnings

prune-learnings is a command for Claude Code from closedloop-ai/claude-plugins. It costs 13 tokens per session (565 once invoked), scanned A, original, Apache-2.0.

A manual cleanup command for the files and logs created by the learnings system. It removes old sessions and archived files and rotates oversized logs according to retention settings.

In plain words
What is it for?
Use it to prune old session directories, rotate run and outcome logs, and delete archived pending files past their allowed age.
Why use it?
Learning records and logs can grow over time and use unnecessary disk space. This command keeps only the amount of history allowed by your retention policy.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is ./plugins/self-learning/scripts/prune-learnings.sh.

Part of the self-learning plugin — 2 skills, 6 commands shipped together

Good fit Use it to prune old session directories, rotate run and outcome logs, and delete archived pending files past their allowed age.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/closedloop-ai/claude-plugins
agentmods
npx agentmods add commands/closedloop-ai/claude-plugins/prune-learnings

Made for: Claude Code.

Or install self-learning, the plugin that ships this one along with the rest of its 2 skills, 6 commands.

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 prune-learnings

README.md
[![agentmods](https://agentmods.dev/badge/commands/closedloop-ai/claude-plugins/prune-learnings.svg)](https://agentmods.dev/commands/closedloop-ai/claude-plugins/prune-learnings)
Your own site
<a href="https://agentmods.dev/commands/closedloop-ai/claude-plugins/prune-learnings"><img src="https://agentmods.dev/badge/commands/closedloop-ai/claude-plugins/prune-learnings.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 565 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.
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.00013 $0.00565
Opus 5 $0.00006 $0.00282
Sonnet 5 $0.00003 $0.00113
Haiku 4.5 $0.00001 $0.00056

Measured yesterday against content hash 5efae5e7d187, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

prune-learnings 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 yesterday.

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/self-learning/commands/prune-learnings.md · 89 lines

How it starts

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

Prune Learnings Command

Manually invokes the pruning script to clean up old learnings and rotate log files.

Purpose

Over time, the learnings system accumulates:

  • Old session directories
  • Large log files
  • Archived pending files

This command runs the pruning script to clean up old data according to retention policy.

Retention Configuration

Edit .learnings/retention.yaml to customize:

# Maximum number of runs to keep in runs.log
max_runs: 100

# Maximum number of session directories to keep
max_sessions: 50

# Maximum lines per log file before rotation
max_log_lines: 10000

# Maximum age (days) for archived pending files
max_archive_age_days: 30

# Lock staleness threshold (hours) before force-pruning
lock_stale_hours: 4

# Protected run window (minutes) - recent runs won't be pruned
protected_window_minutes: 30

What Gets Pruned

  1. Session directories: Oldest sessions beyond max_sessions limit
  2. Log files: Rotated when exceeding max_log_lines
    • runs.logruns.log.1 → deleted
    • outcomes.logoutcomes.log.1 → deleted
    • acknowledgments.logacknowledgments.log.1 → deleted
  3. Archived pending files: Older than max_archive_age_days
  4. Stale lock files: Lock files older than lock_stale_hours

Safety Mechanisms

  • Protected runs: Current run and runs active within protected_window_minutes are never pruned
  • Lock checking: Won't prune if .learnings/.lock exists (unless stale)
  • Atomic operations: Uses atomic file replacement to prevent corruption

Usage

# Run pruning script directly
./plugins/self-learning/scripts/prune-learnings.sh

# Or via ClosedLoop orchestrator command
# This is automatically run after each completed run

Automatic Pruning

Pruning runs automatically:

  1. After each run completes (in background)
  2. Current run is always protected
  3. Failures are logged but don't block the run

Manual Pruning

Use manual pruning when:

  • Disk space is low
  • You want to clean up before sharing repository
  • You've changed retention settings and want immediate effect

Read the full file on GitHub · 89 lines

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. yesterday First seen · 89 lines · 13 tokens per session scan A 5efae5e7d187

Subscribe to this mod's changes

prune-learnings is a command published in the GitHub repository closedloop-ai/claude-plugins (103 stars, last pushed 2d ago), licensed Apache-2.0. It adds 13 tokens to every session and 565 once invoked, about $0.0001 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-07.