cleanup-context

A procedure for reducing unnecessary text in a project’s memory-bank documentation while preserving important information. It focuses on finding duplicates, obsolete files, temporary material, and overly verbose sections.

In plain words
What is it for?
It helps audit documentation sizes, remove or archive outdated material, consolidate repeated guidance, and make memory files more efficient.
Why use it?
Large or duplicated context files use more tokens and can make it harder for an agent to find the information that matters.

Command for Claude Code

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.

agentmods
npx agentmods add commands/centminmod/my-claude-code-setup/cleanup-context
Clone the repo
git clone --depth 1 https://github.com/centminmod/my-claude-code-setup

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,601 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.01601
Opus 5 $0.00000 $0.00800
Sonnet 5 $0.00000 $0.00320
Haiku 4.5 $0.00000 $0.00160

Measured 3d ago against content hash e4c41373c200, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cleanup-context 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 3d 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.

.claude/commands/cleanup/cleanup-context.md · 274 lines

How it starts

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

Memory Bank Context Optimization

You are a memory bank optimization specialist tasked with reducing token usage in the project's documentation system while maintaining all essential information and improving organization.

Task Overview

Analyze the project's memory bank files (CLAUDE-*.md, CLAUDE.md, README.md) to identify and eliminate token waste through:

  1. Duplicate content removal
  2. Obsolete file elimination
  3. Content consolidation
  4. Archive strategy implementation
  5. Essential content optimization

Analysis Phase

1. Initial Assessment

# Get comprehensive file size analysis
find . -name "CLAUDE-*.md" -exec wc -c {} \; | sort -nr
wc -c CLAUDE.md README.md

Examine for:

  • Files marked as "REMOVED" or "DEPRECATED"
  • Generated content that's no longer current (reviews, temporary files)
  • Multiple files covering the same topic area
  • Verbose documentation that could be streamlined

2. Identify Optimization Opportunities

High-Impact Targets (prioritize first):

  • Files >20KB that contain duplicate information
  • Files explicitly marked as obsolete/removed
  • Generated reviews or temporary documentation
  • Verbose setup/architecture descriptions in CLAUDE.md

Medium-Impact Targets:

  • Files 10-20KB with overlapping content
  • Historic documentation for resolved issues
  • Detailed implementation docs that could be consolidated

Low-Impact Targets:

  • Files <10KB with minor optimization potential
  • Content that could be streamlined but is unique

Optimization Strategy

Phase 1: Remove Obsolete Content (Highest Impact)

Target: Files marked as removed, deprecated, or clearly obsolete

Actions:

  1. Delete files marked as "REMOVED" or "DEPRECATED"
  2. Remove generated reviews/reports that are outdated
  3. Clean up empty or minimal temporary files
  4. Update CLAUDE.md references to removed files

Expected Savings: 30-50KB typically

Phase 2: Consolidate Overlapping Documentation (High Impact)

Read the full file on GitHub · 274 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. 3d ago First seen · 274 lines · 0 tokens per session scan A e4c41373c200

Subscribe to this mod's changes

cleanup-context is a command published in the GitHub repository centminmod/my-claude-code-setup (2,614 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,601 tokens. 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-08-30.