Skip to main content

/session-export - Export Sessions to /cx-Compatible Format

Export Claude Code sessions to text files that are fully compatible with /cx processing. Supports interactive selection from recent sessions or exporting by session ID.

System Prompt

EXECUTION DIRECTIVE: When the user invokes /session-export, you MUST:

  1. IMMEDIATELY execute the export script
  2. If no session ID provided, show interactive session picker
  3. Generate /cx-compatible output with proper format:
    • ASCII banner (▐▛███▜▌)
    • Claude Code version string
    • User markers (> )
    • Assistant markers ()
  4. Use standard naming: YYYY-MM-DD-<random16>.txt
  5. Report results with file path and message counts

Usage

# Interactive mode - pick from recent sessions
/session-export

# Export specific session
/session-export e129edd4-4194-4bba-9420-9eb284cc7cd1

# Export current session
/session-export --current

# Export last N sessions
/session-export --last 3

# Dry run (preview without writing)
/session-export --dry-run

Options

OptionDescription
[session-id]Specific session UUID to export
--currentExport current active session
--last NExport the N most recent sessions
--dry-runPreview without writing files
--output DIROutput directory (default: current directory)
--no-archiveDon't automatically run /cx after export

Interactive Session Picker

When run without arguments, displays recent sessions:

┌─────────────────────────────────────────────────────────────┐
│ Select Session(s) to Export │
├─────────────────────────────────────────────────────────────┤
│ [1] 2026-01-11 01:23 │ 257K │ Current session │
│ [2] 2026-01-11 01:05 │ 17M │ F.9.4 Architecture Update │
│ [3] 2026-01-10 04:36 │ 73M │ PILOT Plan Analysis │
│ [4] 2026-01-10 02:54 │ 97K │ Context DB work │
│ [5] 2026-01-10 01:46 │ 31K │ Git workflow │
├─────────────────────────────────────────────────────────────┤
│ Enter selection (1-5, or 'all', or 'q' to quit): │
└─────────────────────────────────────────────────────────────┘

Output Format

Generated files are fully /cx-compatible:

 ▐▛███▜▌  Claude Code v2.1.4
Model: claude-opus-4-5-20251101

─────────────────────────────────────────────────────────────────

> User message here

────────────────────────────────────────────────────────────

⏺ Assistant response here

────────────────────────────────────────────────────────────

File Naming Convention

Files are named to match Claude Code's /export format:

YYYY-MM-DD-<random16chars>.txt

Examples:
2026-01-11-9budnowmyeor7u2b.txt
2026-01-11-x7k3mwp9qr2nf4hj.txt

Execution

python3 ~/.coditect/scripts/session-exporter.py $ARGS

Examples

Export Current Session

/session-export --current
# Output: 2026-01-11-a3b2c1d4e5f6g7h8.txt (347 messages)

Interactive Selection

/session-export
# Shows picker, user selects [2]
# Output: 2026-01-11-x7k3mwp9qr2nf4hj.txt (227 messages)

Batch Export Recent

/session-export --last 3
# Output:
# 2026-01-11-abc123def456gh78.txt (347 messages)
# 2026-01-11-xyz789uvw012st34.txt (227 messages)
# 2026-01-10-jkl456mno789pq12.txt (892 messages)

Use Cases

  1. Recover from /export crash - When built-in /export fails on emoji characters
  2. Batch export - Export multiple sessions at once
  3. Export old sessions - Access sessions that are no longer current
  4. Backup before cleanup - Preserve sessions before removing old JSONL files

Success Output

✅ Session exported successfully!

Session: e129edd4-4194-4bba-9420-9eb284cc7cd1
Output: 2026-01-11-9budnowmyeor7u2b.txt
Size: 269.2 KB
Messages: 347 (120 user, 227 assistant)

Format verification:
✓ Banner (▐▛███▜▌)
✓ Version string
✓ User markers (>)
✓ Assistant markers (⏺)

Ready for /cx processing.

Integration with /cx

Exported files are automatically detected and processed by /cx:

/session-export --current     # Create export
/cx # Process all exports (including new one)
/cxq "search term" # Query extracted messages

Completion Checklist

Before marking complete:

  • Session file(s) exported
  • Format verified (banner, markers)
  • File named correctly (YYYY-MM-DD-random.txt)
  • Message counts reported
  • Ready for /cx processing

Failure Indicators

This command has FAILED if:

  • ❌ Session file not found
  • ❌ Write permission denied
  • ❌ Zero messages extracted
  • ❌ Format verification failed

When NOT to Use

Do NOT use when:

  • Built-in /export works (use that instead for current session)
  • Session JSONL file is corrupted
  • Exporting to non-writable directory

Principles

This command embodies:

  • #1 Recycle, Extend, Re-Use - Works with existing /cx pipeline
  • #3 Complete Execution - Full export with verification
  • #6 Self-Provisioning - No manual format conversion needed

Full Standard: CODITECT-STANDARD-AUTOMATION.md


Script: scripts/session-exporter.py Version: 1.0.0 Created: 2026-01-11