npx claudepluginhub andrewm4894/claude-log-cleanerAutomatically delete Claude Code session logs after a configurable retention period to prevent sensitive data exposure
A Claude Code plugin that automatically deletes session log files after a configurable retention period to prevent sensitive data exposure.
The Problem: I watched this YouTube video and freaked out a bit - Claude Code stores a ton of log files locally in
~/.claude/- files that can contain API keys, tokens, and other secrets from your sessions. That's another attack surface sitting on your laptop. This plugin helps reduce that risk by automatically cleaning up old logs and giving you easy commands to scan for exposed secrets.
Claude Code stores session logs in ~/.claude/ that can contain sensitive information from your chat sessions, including:
This plugin helps you maintain security hygiene by automatically cleaning up old logs.
trufflehog or detect-secrets for enhanced secret scanningInstall one or both for improved secret detection. All available scanners run together for maximum coverage.
TruffleHog (recommended) - 700+ secret detectors:
brew install trufflehog
detect-secrets - 20+ secret types:
pip install detect-secrets
Without these, the plugin uses built-in regex patterns for common secrets (OpenAI, Anthropic, GitHub, AWS, Slack, PostHog).
/plugin marketplace add andrewm4894/claude-log-cleaner
/plugin install log-cleaner@log-cleaner-marketplace
/plugin update log-cleaner@log-cleaner-marketplace
# Uninstall the plugin
/plugin uninstall log-cleaner
# Remove the marketplace (optional)
/plugin marketplace remove log-cleaner-marketplace
If updates aren't working, try a full reinstall:
# Remove everything
/plugin uninstall log-cleaner
/plugin marketplace remove log-cleaner-marketplace
# Reinstall
/plugin marketplace add andrewm4894/claude-log-cleaner
/plugin install log-cleaner@log-cleaner-marketplace
# Clone the repository
git clone https://github.com/andrewm4894/claude-log-cleaner.git
# In Claude Code, load the plugin for testing:
claude --plugin-dir /path/to/claude-log-cleaner/plugins/log-cleaner
| Command | Description |
|---|---|
/log-cleaner:clean | Manually run cleanup |
/log-cleaner:status | Show directory sizes and config |
/log-cleaner:set-retention <hours> | Set retention period |
/log-cleaner:scan | Scan logs for exposed secrets |
# Check current status
/log-cleaner:status
# Preview what would be deleted (dry run)
/log-cleaner:clean --dry-run
# Set retention to 48 hours
/log-cleaner:set-retention 48
# Delete files older than 1 hour
/log-cleaner:clean --hours 1
# Scan for secrets in your logs
/log-cleaner:scan
The plugin creates a config file at ~/.claude/log-cleaner-config.json:
{
"retention_hours": 24,
"clean_on_session_end": true,
"dry_run": false
}
| Option | Default | Description |
|---|---|---|
retention_hours | 24 | Hours to retain files before deletion |
clean_on_session_end | true | Auto-clean when Claude Code session ends |
dry_run | false | Preview mode (no actual deletion) |
Note: Config values are used as defaults. The --dry-run CLI flag overrides the config value for that run.
The plugin cleans all Claude Code data directories:
~/.claude/debug/ - Session debug logs~/.claude/file-history/ - File edit history~/.claude/projects/ - Project-specific data~/.claude/todos/ - Todo lists~/.claude/plans/ - Planning data~/.claude/shell-snapshots/ - Shell state snapshotsThe plugin hooks into Claude Code's SessionEnd event to automatically clean old logs when you finish a session. This ensures cleanup happens regularly without manual intervention.
To disable automatic cleanup, edit the config:
{
"clean_on_session_end": false
}
MIT
Issues and PRs welcome at https://github.com/andrewm4894/claude-log-cleaner
7-day visitors to each marketplace page
RuFlo Marketplace: Claude Code native agents, swarms, workers, and MCP tools for continuous software engineering
Claude Code marketplace entries for the plugin-safe Agentic Awesome Skills library and its compatible editorial bundles.
Directory of popular Claude Code extensions including development tools, productivity plugins, and MCP integrations