Archive detritus and clean conversation logs
Remove noise from conversation logs while archiving deleted content. Use after /analyze to clean failed tool loops, greetings, and abandoned threads from Claude Code and OpenCode histories.
/plugin marketplace add jasonkneen/codesurf-insights/plugin install jasonkneen-codesurf-insights@jasonkneen/codesurf-insights[project|all]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