[FEATURE] --export-on-exit CLI flag with optional path

Resolved 💬 3 comments Opened Feb 5, 2026 by aharbuz Closed Feb 9, 2026

Summary

Add a CLI flag to automatically export conversations when a session ends, with an optional path argument.

Proposed Syntax

# Export to default location (~/.claude/exports/)
claude --export-on-exit

# Export to specific relative path (resolved from cwd)
claude --export-on-exit ./AGENTS/convos/

# Export to absolute path
claude --export-on-exit /path/to/exports/

Use Case

Many users have workflows that benefit from systematic conversation archival:

  • Context management: When context gets high, users start fresh sessions but want to preserve the previous conversation
  • Progress tracking: Teams document work in AGENTS/convos/ or similar directories
  • Auditability: Keeping records of AI-assisted development sessions

Currently this requires:

  1. Remembering to run /export manually before ending
  2. Or setting up a SessionEnd hook (which works but requires more setup)

A CLI flag would make this a one-liner for users who always want exports.

Suggested Behavior

  • Accepts relative paths (resolved from cwd at session start)
  • Accepts absolute paths
  • Falls back to ~/.claude/exports/ if no path given
  • Filename format: YYYY-MM-DD-HHMM-{short-session-id}.jsonl
  • Only exports on normal session end (not on /logout or crashes)

Related Issues

  • #19086 - PostCommand hook for /export (complementary)
  • #18803 - Conversation Sharing / Export (broader scope)
  • #19233 - Per-Conversation Export

Workaround

Currently using a SessionEnd hook that reads transcript_path and copies to the desired location. Works but requires users to set up the hook manually.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗