Help us improve
Share bugs, ideas, or general feedback.
npx claudepluginhub jasonkneen/codesurf-insightsHow this command is triggered — by the user, by Claude, or both
Slash command
/codesurf-insights:compact [project|all]This command is limited to the following tools:
The summary Claude sees in its command listing — used to decide when to auto-load this command
# Compact Conversation Logs
Remove detritus from conversation logs while archiving removed content for reference. Works with both **Claude Code** and **OpenCode** conversation histories.
## Arguments
- `project` (default): Compact current project's conversations only
- `all`: Compact all projects globally (both tools)
- `{project-name}`: Compact specific project by name
## Process
### 1. Detect Tool & Locate Conversations
**IMPORTANT**: First detect which conversation sources exist:
**Claude Code**:
- Project: `~/.claude/projects/{hash}/conversations/*.jsonl`
- Global: `~/.claude/pro.../smart-compactAnalyzes current conversation to generate optimized /compact command preserving high-value context (tasks, changes, errors), summarizing medium-value info, and discarding stale content.
/cleanup-contextRuns Claude Code context cleanup script, permanently deleting files older than 7-60 days from file-history, sessions, projects, todos, logs, and statsig. Shows before/after stats and deletion summary.
/restore-historyRestores past Claude Code and Codex session transcripts to Obsidian vault as structured documents. Supports scopes: recent N, date range, current/all projects, resume.
/historySearches Claude Code, Codex, and Hermes conversation history in parallel with optional date, source, and limit filters.
/cleanupCleans old log files from workflows, commands, audio, Figma, JIRA, and plugins older than specified days (default 30). Supports --dry-run preview.
/analyze-contextAnalyzes Claude Code chat history for context window usage, identifying top consumers and providing optimization recommendations in a markdown report.
Share bugs, ideas, or general feedback.
Remove detritus from conversation logs while archiving removed content for reference. Works with both Claude Code and OpenCode conversation histories.
project (default): Compact current project's conversations onlyall: Compact all projects globally (both tools){project-name}: Compact specific project by nameIMPORTANT: First detect which conversation sources exist:
Claude Code:
~/.claude/projects/{hash}/conversations/*.jsonl~/.claude/projects/*/conversations/*.jsonlOpenCode:
~/.local/share/opencode/storage/session/ses_*~/.local/share/opencode/storage/message/ses_*~/.local/share/opencode/storage/part/msg_*/prt_*.jsonLaunch the detritus-detector agent to identify noise:
Present summary before archiving:
Detritus Found
══════════════════════════════════
Source: Claude Code
├── Conversation abc123:
│ ├── [lines 45-67] Failed grep loop (5 attempts)
│ └── [lines 120-125] Greeting exchange
Source: OpenCode
├── Session ses_485d888e:
│ ├── [msg_19b370...] Failed tool loop (4 attempts)
│ └── [msg_19b371...] "Let me try again" x3
Total: 156 segments across 8 conversations/sessions
Archive location: ~/.claude/insights/archive/2026-01-01/
Move flagged content to archive:
~/.claude/insights/archive/YYYY-MM-DD/Claude Code: Remove detritus from JSONL files:
{"archived": true, "lines": 23, "reason": "failed tool loop"}OpenCode: Mark parts as archived (don't delete - OpenCode manages its own storage):
Compaction Complete
══════════════════════════════════
Sources processed:
- Claude Code: 8 conversations
- OpenCode: 12 sessions
Segments archived: 156
Space saved: ~45KB (Claude Code only - OpenCode archived separately)
Archive: ~/.claude/insights/archive/2026-01-01/
Original Claude Code logs updated with archive markers.
OpenCode archive references created.
Archived content preserves context and source:
# Archive: Claude Code - abc123
Date: 2026-01-01
Source: Claude Code
Reason: Failed tool loop
## Original Location: lines 45-67
[user]: Search for the config file
[assistant]: Let me search...
[tool_call]: grep "config" - FAILED
[assistant]: Let me try again...
...
---
# Archive: OpenCode - ses_485d888e
Date: 2026-01-01
Source: OpenCode
Reason: Failed tool loop
## Message IDs: msg_19b370..., msg_19b371...
[user]: Find the auth implementation
[assistant]: Searching...
[tool_call]: grep "auth" - FAILED
...
/analyze to clean flagged detritusall monthly to keep both tools' logs manageable