SuperAPI AI Directory

claude-cleanup

Office & productivity

View repository

Updated 11-15 16:05

About this skill

Claude local cleanup and context slimming

First determine which task the user wants:

  • Local cleanup(macOS only): clear caches and logs, rotate local IDs, reset login state, remove the app, change the time zone. Use the bundled scripts in the "Run order" below.
  • Context slimming(works on both macOS and Windows): the startup context is too large, and you want to turn off unused tools, MCPs, skills, and plugins to save tokens; this also covers questions about where Claude Code's global configuration is and how to write it. Read references/context-slim.md and follow it.

Division of labor: high-risk, irreversible operations run scripts only in the terminal, with the user entering CONFIRM themselves; reversible settings changes are explained by the agent in the conversation and made directly after the user agrees.

Local cleanup

Use the bundled scripts; do not improvise rm. The scripts use a narrow allowlist, full backups, a single final informed confirmation, and stop on failure.

Run order

  1. If the current executor is Claude Code itself, run only the read-only audit and remind the user to switch to Codex or a normal terminal. Do not let Claude Code, which is currently using ~/.claude , clean that directory itself.
python3 scripts/claude_cleanup.py --audit
  1. If executed by Codex or a normal terminal, run the audit first and explain to the user:

    • The first write operation is a full copy and verification of ~/.claude, along with a backup of ~/.claude.json;
    • Regenerable caches and logs are automatically included in the final list without asking item by item;
    • Identity, Keychain, desktop login state and data, the app, and the time zone are risky operations and remain the user's choice;
    • All removals go only into a timestamped trash directory; nothing is permanently deleted and the Trash is not emptied;
    • Protected paths and telemetry settings remain unchanged.
  2. After the user explicitly asks to continue, run in a real terminal:

    python3 scripts/claude_cleanup.py
    

    Do not answer via a pipe, and do not add a parameter that skips confirmation. If there is only automatic safe cleanup and Claude is running, the script skips safe targets directly without requiring exit; if the user chooses risky operations, have the user exit normally and re-check. The script cannot end processes automatically.

  3. The script shows the expanded full list. Writing to disk begins only after the user enters CONFIRM once. If the time zone needs to be changed, the login password can only be entered by the user in the hidden prompt of the native macOS sudo ; do not ask the user to send the password to the executor, and do not read or save it.

  4. When finished, report the backup path, the trash batch, the actual selections, the telemetry inheritance result, and the time zone. Any stop mid-way must be reported as partially completed; do not claim broadly that cleanup succeeded.

Automatic safe cleanup

After both Claude Code and Claude Desktop have exited, automatically include the following existing targets in the final list without asking item by item:

~/.claude/cache
~/.claude/stats-cache.json
~/.claude/telemetry
~/.claude/usage.jsonl
~/.claude/usage.with-fix.jsonl
~/Library/Caches/claude-cli-nodejs
~/Library/Caches/com.anthropic.claudefordesktop*
~/Library/Logs/Claude
~/Library/Logs/DiagnosticReports/Claude*
~/Library/Application Support/CrashReporter/Claude*

These targets must still pass the script allowlist check and are only moved to the Trash.~/.claude/usage-data stores the reports generated by /insights ; it does not count as cache and is not cleaned automatically.

Absolute protection scope

Never delete or move:

~/.claude/projects、sessions、history.jsonl、file-history、debug
~/.claude/skills、plugins、hooks、commands、scripts、agents、mcp-servers、scheduled-tasks
~/.claude/backups、CLAUDE.md、settings.json、settings.local.json
任何项目目录、Git 仓库、Codex 会话,以及未明确列入白名单的路径

settings.json Only allow structured modification of keys explicitly selected by the user. Preserve other env, hooks, plugins, permissions, models, MCP, status bar, and secrets. Stop immediately when the target overlaps with a protected path.

Risky operations

  • Local identity rotation: rotate the ~/.claude.json of userID、machineID, clear known account cache fields, and sync the same set of new values to ~/.claude/backups/.claude.json.backup.*. Use only for privacy and troubleshooting; do not claim it can change platform association judgments.
  • Keychain: deleting Claude Code-credentials will log out of the CLI; select separately.
  • Claude Desktop: you may choose to clear login state and all desktop app data, or also move /Applications/Claude.app to the Trash. The desktop app data directory ~/Library/Application Support/Claude contains not only login state, but also the session list of the Code tab, files written in No folder sessions (scratch-workspaces), Cowork sessions, and virtual machine images. Before choosing, clearly explain to the user that these will also go to the Trash. The application process must not be terminated automatically.
  • Taipei time zone: ask only when macOS is currently not Asia/Taipei . Use sudo systemsetup to modify and verify.

Telemetry inheritance

Save the following keys value by value:

DISABLE_TELEMETRY
DO_NOT_TRACK
DISABLE_ERROR_REPORTING
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC

If currently off, keep it off; if currently not off, do not proactively turn it off. Changing telemetry state is not within the cleanup scope of this skill.

This skill is not for evading bans, payment checks, device or IP reputation, browser fingerprints, or any platform risk control.