/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:
- IMMEDIATELY execute the command - no questions, no explanations first
- ALWAYS show full output from the script execution
- 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:
- Check which LLMs are running:
pgrep -l "claude|codex|gemini|kimi" - Get context usage for each running LLM
- 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
| Option | Short | Description |
|---|---|---|
--llm LLM | LLM(s) to export: claude, codex, gemini, kimi, all, or comma-separated | |
--status | -s | Show LLM status only (running, context %, session info) |
--process | -p | Run /cx after export to process pending files |
--list | -l | List available sessions |
--source PATH | Specific session file to export | |
--session-id ID | Specific session ID to extract | |
--output PATH | -o | Output file path (default: pending directory) |
--format FMT | -f | Output format: jsonl, json, sqlite |
--pending | Write to pending directory (default for interactive) | |
--compress | Gzip compress output | |
--reconstruct | Include all metadata for reconstruction | |
--dry-run | Preview without writing | |
--force | Export even if context usage is low | |
--detect | Show detected LLM CLI tools | |
--project ID | Project scope for export attribution (ADR-159). Auto-detected from CWD if not set. | |
--verbose | -v | Verbose 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 Support | Claude only | Claude, Codex, Gemini, Kimi |
| Interactive | No | Yes (multi-select) |
| Format | TXT | JSONL, JSON, SQLite (CUSF) |
| Reconstruction | No | Yes |
| Past Sessions | No | Yes (--session-id) |
| Cross-LLM | No | Yes (unified format) |
| Pending Integration | No | Yes (writes to pending dirs) |
Related Commands
| Command | Purpose |
|---|---|
/cx | Process pending exports, extract messages to database |
/cxq | Query extracted messages |
/export | Built-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
/cxinstead) - Want text export only (use
/exportbuilt-in) - LLM is in middle of critical operation
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Export without /cx | Pending files accumulate | Use /sx -p or run /cx after |
| Export low-context sessions | Unnecessary work | Check --status first |
| Ignore high-context warnings | Risk context overflow | Export 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)