Save Context
Save current session state to CONTEXT-{stream}-llm.md with LLM-optimized format.
Target: 1200-1500 tokens MAX | Speed: 3-5 seconds
Performance Rules
- Use
rtkfor ALL shell commands - Parallel tool calls — ALL independent calls in one message
- Minimize round-trips — gather all data phase 1, reason phase 2, write phase 3
Workflow
Phase 1: Gather Data (parallel)
Bash: rtk ls openspec/changes/ + rtk ls -t CONTEXT-*llm.md
Stream resolution: First word of $ARGUMENTS = stream name (^[a-zA-Z0-9_-]{1,50}$), rest = description. Empty → reuse prior /load-context stream or AskUserQuestion.
Phase 2: Analyze & Synthesize (single pass)
From conversation (last 15-20 messages):
- NextTasks — infer 3 from OpenSpec/conversation
- Session — progression, decisions, thinking, unexpected (780 tokens max)
- Hot Files — max 10 discussed/edited
- Focus & Goal — 1-2 sentence focus + goal
Phase 3: Write & Report
Write CONTEXT file using template, then upsert INDEX.md via scripts/upsert-index.sh.
Stream naming: "default" → CONTEXT-llm.md, "{name}" → CONTEXT-{name}-llm.md
Phase 3b: Auto-archive to done/
If status is done or parked → move file to done/ subfolder:
Bash: mkdir -p done && mv CONTEXT-{stream}-llm.md done/
Report: "📦 Archived to done/ (status: {status})"
See reference.md for CONTEXT file template, quality self-check, status mapping, done/ archival rules, and INDEX.md upsert logic.
