/cxs - Context Save (Automated Workflow)
Usage
/cxs <query>
Execute the context preservation workflow immediately.
System Prompt
System Prompt
⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:
- IMMEDIATELY execute - no questions, no explanations first
- ALWAYS show full output from script/tool 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 unless
requires_confirmation: truein frontmatter - Skip execution even if it seems redundant - run it anyway
The user invoking the command IS the confirmation.
You are executing the CODITECT context save workflow. This is an automated execution - perform all steps without asking for confirmation.
EXECUTE THESE STEPS IN ORDER:
Step 1: Export Conversation
Run the built-in export command to save the current conversation:
/export
Step 2: Extract & Index Messages
Run the unified message extractor to process the export:
python3 scripts/unified-message-extractor.py
This will:
- Find the export file (recursive search)
- Extract messages to unified_messages.jsonl
- Index into SQLite (decisions, patterns, errors)
- Archive the export file automatically
Step 3: Notify User
After extraction completes, tell the user:
✅ Context saved successfully!
Your work has been preserved:
- Messages extracted to unified_messages.jsonl
- Indexed to sessions.db (ADR-118 Tier 3) (searchable)
- Export archived
Next steps:
1. Run /compact to reduce context
2. After compact, run: /cxq --recent 20 to recall
Or just continue working - your context is safe.
Automatic Trigger
This workflow runs automatically when context drops below 5%.
See hook: hooks/context-monitor.json
Manual Usage
/cxs
Executes: export → extract → notify
After running, manually run /compact if needed, then /cxq --recent 20 to recall context.
Success Output
When context save completes:
✅ COMMAND COMPLETE: /cxs
Export: Completed
Messages: N extracted
Database: sessions.db (ADR-118 Tier 3) updated
Archive: Export archived
Completion Checklist
Before marking complete:
- Export executed
- Messages extracted
- Database indexed
- Export archived
- User notified
Failure Indicators
This command has FAILED if:
- ❌ Export failed
- ❌ Extraction failed
- ❌ Database not updated
- ❌ No confirmation shown
When NOT to Use
Do NOT use when:
- Session just started (nothing to save)
- Already exported recently
- No meaningful work done
Anti-Patterns (Avoid)
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Skip before compact | Lost context | Always save first |
| Ignore errors | Lost work | Check output |
| Run too often | Redundant exports | Use when needed |
Principles
This command embodies:
- #3 Complete Execution - Full save workflow
- #6 Clear, Understandable - Clear status
- #9 Based on Facts - Verify completion
Full Standard: CODITECT-STANDARD-AUTOMATION.md