cyberneticlibrary

Resume session with pruned context

prune-resumecommandsetup L1241
joewinke/jat
What it does

Prune conversation history and auto-resume Claude Code session

Best for

Extending long-running Claude Code sessions by pruning token-heavy conversation history while preserving session context and resuming automatically.

Inputs
  • · Session ID (from environment or .claude/session-id.txt)
  • · Current working directory (captured for background process)
Outputs
  • · Pruned conversation (35 messages retained)
  • · Resumed session with history intact
Requires
  • · npx claude-prune (session pruning)
  • · claude CLI (session resume)
  • · nohup / disown (background process survival)
  • · kill command (process monitoring)
Preconditions
  • · Claude Code environment has .claude/ directory
  • · Session tracking enabled
  • · claude and npx available in PATH
Failure modes
  • · Session ID not found → background process cannot prune
  • · cd to original directory fails → worker exits with error
  • · Prune or resume command fails → logs to /tmp/prune-resume.log
Trust signals
  • · Captures CWD before exit (critical for .claude/ folder discovery)
  • · Uses nohup + disown for background survival
  • · Error logging to /tmp/prune-resume.log for debugging
  • · Automatic resume via claude -r SESSION_ID (user-transparent)