Skip to main content

/sx - Session Export (Multi-LLM Interactive)

Export LLM session data to CODITECT Universal Session Format (CUSF) with interactive multi-select capability. Supports Claude, Codex, Gemini, and Kimi. Pairs with /cx for the complete export → extract workflow.

Usage

# Interactive mode (default) - checkbox multi-select
/sx

# Export specific LLMs (non-interactive)
/sx --llm claude
/sx --llm codex,gemini
/sx --llm all

# Show status only (no export)
/sx --status

# Dry run (show what would be exported)
/sx --dry-run

# Export and immediately process with /cx
/sx --process
/sx -p

# List available sessions
/sx --list
/sx --list --llm codex

# Export past sessions
/sx --session <session-id>
/sx --source ~/.claude/projects/abc/def.jsonl

# Output options
/sx --output /path/to/export.jsonl
/sx --format jsonl|json|sqlite

# Reconstruction mode (includes ALL metadata)
/sx --reconstruct

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes /sx with ANY arguments (or no arguments), you MUST:

  1. IMMEDIATELY execute the command - no questions, no explanations first
  2. ALWAYS show full output from the script execution
  3. ALWAYS provide summary after execution completes

DO NOT:

  • Say "I don't need to take action" - you ALWAYS execute when invoked
  • Ask for confirmation - the user invoking the command IS the confirmation
  • Skip execution even if it seems redundant - run it anyway

Workflow: /sx (export) → /cx (extract & index)

ADR-159 Project Scoping: When --project is provided (or auto-detected from $CODITECT_PROJECT or CWD), pass it to the extractor via --project flag so exported sessions are attributed to the correct project. This ensures /cx processes them into the right project scope.

# With project scope:
python3 ~/.coditect/scripts/unified-message-extractor.py --project PILOT [files...]

Output Directories (ADR-122 naming convention):

  • Claude: ~/PROJECTS/.coditect-data/sessions-export-pending-anthropic/
  • Codex: ~/PROJECTS/.coditect-data/sessions-export-pending-codex/
  • Gemini: ~/PROJECTS/.coditect-data/sessions-export-pending-gemini/
  • Kimi: ~/PROJECTS/.coditect-data/sessions-export-pending-kimi/

Interactive Mode (Default - No Arguments)

When invoked without --llm, use the AskUserQuestion tool to present an interactive multi-select:

{
"questions": [{
"question": "Which LLM sessions do you want to export?",
"header": "Export LLMs",
"multiSelect": true,
"options": [
{"label": "Claude (anthropic)", "description": "Export current Claude session - XX% context"},
{"label": "Codex", "description": "Export current Codex session - XX% context"},
{"label": "Gemini", "description": "Export current Gemini session - XX% context"},
{"label": "Kimi", "description": "Export current Kimi session - XX% context"}
]
}]
}

Before presenting options:

  1. Check which LLMs are running: pgrep -l "claude|codex|gemini|kimi"
  2. Get context usage for each running LLM
  3. Include status in option descriptions (e.g., "89% context ⚠️" or "Not running")

After selection: Execute the export for each selected LLM using the existing extractors:

# For each selected LLM, run its extractor:
PENDING_BASE=~/PROJECTS/.coditect-data

# Claude
python3 ~/.coditect/scripts/extractors/claude_extractor.py ~/.claude/projects/ \
--output "$PENDING_BASE/sessions-export-pending-anthropic/"

# Codex
python3 ~/.coditect/scripts/extractors/codex_extractor.py ~/.codex/sessions/ \
--output "$PENDING_BASE/sessions-export-pending-codex/"

# Gemini
python3 ~/.coditect/scripts/extractors/gemini_extractor.py ~/.gemini/tmp/ \
--output "$PENDING_BASE/sessions-export-pending-gemini/"

# Kimi
python3 ~/.coditect/scripts/extractors/kimi_extractor.py ~/.kimi/sessions/ \
--output "$PENDING_BASE/sessions-export-pending-kimi/"

Non-Interactive Mode (--llm specified)

Execute directly without prompting using existing extractors:

# Single LLM
python3 ~/.coditect/scripts/extractors/claude_extractor.py ~/.claude/projects/ \
--output ~/PROJECTS/.coditect-data/sessions-export-pending-anthropic/

# Multiple LLMs (comma-separated)
for llm in claude codex; do
python3 ~/.coditect/scripts/extractors/${llm}_extractor.py ...
done

Options

OptionShortDescription
--llm LLMLLM(s) to export: claude, codex, gemini, kimi, all, or comma-separated
--status-sShow LLM status only (running, context %, session info)
--process-pRun /cx after export to process pending files
--list-lList available sessions
--source PATHSpecific session file to export
--session-id IDSpecific session ID to extract
--output PATH-oOutput file path (default: pending directory)
--format FMT-fOutput format: jsonl, json, sqlite
--pendingWrite to pending directory (default for interactive)
--compressGzip compress output
--reconstructInclude all metadata for reconstruction
--dry-runPreview without writing
--forceExport even if context usage is low
--detectShow detected LLM CLI tools
--project IDProject scope for export attribution (ADR-159). Auto-detected from CWD if not set.
--verbose-vVerbose output

Interactive Display

╔══════════════════════════════════════════════════════════════╗
║ SESSION EXPORT ║
╠══════════════════════════════════════════════════════════════╣
║ LLM Status: ║
║ ├─ Claude: Running 42% context ✓ ║
║ ├─ Codex: Running 89% context ⚠️ (high) ║
║ ├─ Gemini: Running 31% context ✓ ║
║ └─ Kimi: Not running ║
╠══════════════════════════════════════════════════════════════╣
║ Selected: Claude, Codex ║
║ Exporting... ║
║ ├─ Claude → sessions-export-pending-anthropic/ ║
║ │ ✓ 156 messages (2.3 MB) ║
║ └─ Codex → sessions-export-pending-codex/ ║
║ ✓ 423 messages (5.1 MB) ║
╠══════════════════════════════════════════════════════════════╣
║ Total: 579 messages exported to 2 pending directories ║
║ ║
║ Next: Run /cx to process pending exports ║
╚══════════════════════════════════════════════════════════════╝

CUSF Output Format

Line-delimited JSON in CODITECT Universal Session Format:

{"_meta": {"format": "cusf", "version": "1.0.0", "exported_at": "2026-01-29T08:00:00Z"}}
{"type": "session_start", "session_id": "uuid", "llm_source": "claude", "llm_model": "claude-opus-4-5", ...}
{"type": "message", "role": "user", "content": "...", "timestamp": "...", ...}
{"type": "message", "role": "assistant", "content": "...", "timestamp": "...", ...}
{"type": "tool_use", "tool_name": "Read", "tool_input": {...}, ...}
{"type": "tool_result", "tool_id": "...", "result": "...", ...}
{"type": "session_end", "session_id": "uuid", "total_messages": 42, ...}

Workflow Integration

┌─────────────┐     ┌─────────────────────────────┐     ┌─────────────┐
│ /sx │────▶│ Pending Directories │────▶│ /cx │
│ (export) │ │ │ │ (extract) │
└─────────────┘ │ sessions-export-pending- │ └─────────────┘
│ anthropic/ │
│ codex/ │
│ gemini/ │
│ kimi/ │
└─────────────────────────────┘

One-step workflow:

/sx -p                    # Export + process in one command

Two-step workflow:

/sx && /cx                # Export, then extract

Examples

Interactive Multi-Select (Default)

/sx

Result: Shows multi-select dialog, exports selected LLMs to pending directories

Export All LLMs

/sx --llm all

Result: Exports all 4 LLMs without interaction

Export and Process Immediately

/sx --llm claude -p

Result: Exports Claude session, then runs /cx to extract messages

Check Status Only

/sx --status

Result: Shows which LLMs are running and their context usage

List Codex Sessions

/sx --list --llm codex

Result: Lists available sessions in Codex history

Export to SQLite

/sx --llm claude --format sqlite --output ~/backup.db

Result: Exports to portable SQLite database

Detect Installed Tools

/sx --detect

Result: Shows which LLM CLI tools are installed

Differences from /export

Feature/export (built-in)/sx
LLM SupportClaude onlyClaude, Codex, Gemini, Kimi
InteractiveNoYes (multi-select)
FormatTXTJSONL, JSON, SQLite (CUSF)
ReconstructionNoYes
Past SessionsNoYes (--session-id)
Cross-LLMNoYes (unified format)
Pending IntegrationNoYes (writes to pending dirs)
CommandPurpose
/cxProcess pending exports, extract messages to database
/cxqQuery extracted messages
/exportBuilt-in Claude export (text format)

Success Output

✅ COMMAND COMPLETE: /sx
LLMs Exported: Claude, Codex
Messages: 579 total
Pending: 2 directories ready for /cx
Next: Run /cx to process

Completion Checklist

  • LLM status detected
  • Interactive selection shown (if no --llm)
  • Selected LLMs exported
  • Files written to pending directories
  • Summary displayed

Failure Indicators

This command has FAILED if:

  • ❌ No LLMs running (and none specified)
  • ❌ Write permission denied to pending directory
  • ❌ Extractor script failed
  • ❌ No sessions to export

When NOT to Use

Do NOT use when:

  • Just want to process existing pending files (use /cx instead)
  • Want text export only (use /export built-in)
  • LLM is in middle of critical operation

Anti-Patterns (Avoid)

Anti-PatternProblemSolution
Export without /cxPending files accumulateUse /sx -p or run /cx after
Export low-context sessionsUnnecessary workCheck --status first
Ignore high-context warningsRisk context overflowExport soon when ⚠️ shown

Principles

This command embodies:

  • #3 Complete Execution - Full export pipeline
  • #6 Clear, Understandable - Interactive selection with status
  • #1 Recycle, Extend - Leverages existing extractors

Full Standard: CODITECT-STANDARD-AUTOMATION.md


Script: .coditect/scripts/session-export.py Version: 2.0.0 Created: 2026-01-28 Updated: 2026-01-29 Track: J.13 (Memory - Generic Session Export) Related ADRs: ADR-122 (Unified LLM Architecture), ADR-128 (CUSF Format)