Clean up old Claude Code hook log files based on retention policy. Use when disk space is low or to maintain log hygiene.
Deletes old hook log files to free up disk space based on retention policy.
/plugin marketplace add melodic-software/claude-code-plugins/plugin install claude-code-observability@melodic-software[days] [--dry-run]Delete old hook log files to free up disk space.
Related Skill: Invoke the user-config-management skill for comprehensive user configuration guidance.
# Delete logs older than 30 days (default)
/user-config:cleanup-hook-logs
# Delete logs older than 7 days
/user-config:cleanup-hook-logs 7
# Preview what would be deleted (dry run)
/user-config:cleanup-hook-logs --dry-run
# Delete logs older than 14 days with preview first
/user-config:cleanup-hook-logs 14 --dry-run
CLAUDE_HOOK_LOG_RETENTION_MAX_AGE_DAYS)--dry-run or -n: Preview what would be deleted without actually deletingFind and run the cleanup_logs.py script from the claude-code-observability plugin to delete old log files.
Script location: Look for cleanup_logs.py in the installed plugin at:
plugins/claude-code-observability/hooks/cleanup_logs.py**/claude-code-observability/**/cleanup_logs.pyArguments:
--dry-run or -n was specified, pass that flag--verbose to show progressExample command (adjust path based on where script is found):
python /path/to/cleanup_logs.py --days 30 --verbose
The script uses CLAUDE_PROJECT_DIR environment variable (already available in session) to locate the log directory at .claude/logs/hooks/. No CLAUDE_PLUGIN_ROOT is needed.
.jsonl files in .claude/logs/hooks/ older than the specified daysevents-2025-12-05.jsonl) and rotated files (events-2025-12-05-001.jsonl)The default retention period can be configured via environment variable:
# In .claude/settings.json "env" section:
"CLAUDE_HOOK_LOG_RETENTION_MAX_AGE_DAYS": "30"
--dry-run first to preview what will be deleted