Archive Claude Code /insights reports for historical tracking. Supports archiving, listing, comparing, and opening reports.
Archive and manage Claude Code /insights reports to track how your usage patterns evolve over time.
/insights-archive archive # Save current report with timestamp
/insights-archive list # See all archived reports
/insights-archive open # Open current report in browser
/insights-archive open <date> # Open archived report by date
/insights-archive diff <d1> <d2> # Compare two archived reports
/insights-archive # Show help
INSIGHTS_DIR=~/.claude/usage-data
ARCHIVE_DIR=~/.claude/usage-data/archives
CURRENT_REPORT=~/.claude/usage-data/report.html
This skill is fully self-contained. Do NOT download or execute any external scripts. All logic is implemented directly below using the allowed tools.
Before processing any command, validate all user-provided arguments:
archive, list, open, diff, or empty (show help)open and diff) must match the pattern YYYY-MM-DD or YYYY-MM-DD-HHMM (digits and hyphens only). Reject any argument containing characters other than [0-9-] or the literal string current.If no arguments are provided or the subcommand is not recognized, display:
Usage: /insights-archive <command> [args]
Commands:
archive Archive current /insights report with timestamp
list List all archived reports
open [date] Open current report or archived report by date
diff <d1> <d2> Open two reports for comparison
Examples:
/insights-archive archive
/insights-archive list
/insights-archive open current
/insights-archive open 2026-02-04
/insights-archive diff 2026-02-01 2026-02-04
Ensure the archive directory exists:
mkdir -p ~/.claude/usage-data/archives
Check that the current report exists:
test -f ~/.claude/usage-data/report.html && echo "exists" || echo "missing"
If missing, tell the user: "No current report found. Run /insights first to generate a report."
Generate the archive filename with a timestamp:
date +%Y-%m-%d-%H%M
Check for duplicate and copy:
ARCHIVE_FILE=~/.claude/usage-data/archives/report-<TIMESTAMP>.html && test -f "$ARCHIVE_FILE" && echo "duplicate" || cp ~/.claude/usage-data/report.html "$ARCHIVE_FILE" && echo "Archived to: $ARCHIVE_FILE"
Report the result to the user.
List archived reports using Glob for ~/.claude/usage-data/archives/report-*.html
If no files found, tell the user: "No archived reports found. Run '/insights-archive archive' to create one."
Otherwise, display the list with dates extracted from filenames (strip report- prefix and .html suffix), and remind: "Use '/insights-archive open <date>' to view one."
Validate the date argument (must be current, empty, or match [0-9-]+).
If argument is empty or current:
test -f ~/.claude/usage-data/report.html && open ~/.claude/usage-data/report.html || echo "missing"
If missing, tell user to run /insights first.
If a date is provided, use Glob to find matching files: ~/.claude/usage-data/archives/report-<DATE>*.html
open <matched-file>
list.Require exactly two date arguments. If not provided, show usage: "Usage: /insights-archive diff <date1> <date2>"
Validate both date arguments (must match [0-9-]+).
Find matching archives for each date using Glob: ~/.claude/usage-data/archives/report-<DATE>*.html
If either date has no match, report which one is missing.
If both found, open them:
open <file1> && open <file2>
Tell the user: "Opening both reports for comparison."
Tracking how your Claude Code usage patterns evolve over time is valuable:
This aligns with the "knowledge compounds" thesis — your usage data is another form of knowledge that benefits from historical context.