| name | s-continue |
| description | Cheaper and faster than /compact. Restores previous session context from Claude Code AND Codex transcripts by reading them directly — no LLM calls, no token cost. Also auto-loads a handoff written by /s-compact, if one exists. Triggers on "s-continue", "restore context", "what was I doing", "pick up where I left off", "resume work", "previous session", "codex session". |
| when_to_use | Use when starting a new session and want to pick up previous work, including work left unfinished in Codex — the read-side pair of /s-compact (end a session with /s-compact → start the next with /s-continue). Triggers on "s-continue", "restore context", "what was I doing", "pick up where I left off", "resume work", "previous session", "codex session". |
Restore context from previous sessions so the user can pick up where they left off — without the cost of /compact.
Two tools, one history. Sessions come from Claude Code (~/.claude/projects/) and from Codex
(~/.codex/sessions/). A Codex rollout is rewritten into the shape Claude Code writes, one output
line per input line, so both are read by the same code and an L{n} marker still points at the
Codex original's line. Work stopped in one tool is therefore resumable in the other.
Help
ONLY show help if the user's argument literally contains the word "help" (e.g. /s-continue help). If no argument or any other argument is given, SKIP this section entirely and proceed to Step 1.
If the user provides "help" as argument, show usage summary and stop:
/s-continue — Restore context from previous sessions (zero LLM calls)
Options:
(nothing) Show session list (Claude Code + Codex), pick which to restore
- Current session with context-loss events appears as #0 [default]
- Press Enter to restore just #0, or add more numbers
last Quick restore:
- Current session if it had /compact or auto-compact
- Otherwise, most recent other session
claude|codex Restrict the list to one tool
help Show this help
Examples:
/s-continue
/s-continue codex
/s-continue codex : rust migration
Do not run any analysis or restoration. Just display the help text and stop.
What a restore contains
compact.txt is a preview, not a transcript. The preprocessor truncated it when it was built:
| Threshold | Kept |
|---|
| User message | 500 chars | first 300 + ..[N lines omitted].. + last 200 |
| Assistant reply | 200 chars | first 100 + [...truncated...] + last 100 |
Every turn of a selected session is restored. Within one turn the first 24 and last 24 replies are
kept as stored and the ones in between are shortened to 50 chars — during an autonomous run the
assistant answers dozens of times under one user turn, and without that cut a single turn is
unbounded (60 replies under one message measured 27 KB on their own). No reply is dropped: the
-> N AI responses at lines X-Y pointer above each turn locates the originals in the JSONL, and the
reply's own number is its position within that range.
The # compact-format: preamble and the trailing # Session references: footer are kept. On a
Codex session that footer names the original rollout — it is the only line saying which file an
L{n} marker addresses, so dropping it breaks recovery.
The only path back to real original text is a topic (Step 5), which re-reads the matched
turns from the JSONL at up to 3,000 chars each — and only for the top 20 turns that match it.
A --level N argument from an older habit is accepted and ignored.
Language
Detect the user's language from their message accompanying the /s-continue invocation. If no message was provided (bare /s-continue), detect the dominant language from the session list's firstMsg/lastMsg content after Step 1 runs. All UI messages (session list header, selection prompt, progress updates, final reference note) MUST be in the detected language. The examples below are in English — translate naturally, don't transliterate.
Quick Restore: /s-continue last
If the user invoked /s-continue last, skip the session list entirely. Run list-sessions with --limit 3 (same flags as Step 1). Then pick automatically based on the isCurrent and hasContextLoss fields:
- If the current session has context-loss (
isCurrent: true AND hasContextLoss: true) → auto-pick the CURRENT session. Its pre-context-loss content is what needs restoration.
- Otherwise → auto-pick the most recent session where
isCurrent: false (the previous session).
- If no valid target (current session has no context-loss AND no previous sessions exist) → print "No previous sessions found in this project." and stop.
Jump directly to Step 3 with the selected session. No user prompt needed.
Step 1: List & Select
If /s-continue last was used, skip this step (see above).
Run the list-sessions script to get main sessions only (subtask/system-only sessions are filtered out). Requires Node.js.
PROJECT_HASH=$(echo "${PWD}" | sed 's/[^a-zA-Z0-9]/-/g')
TRANSCRIPTS_DIR="${HOME}/.claude/projects/${PROJECT_HASH}"
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT}}"
node "${PLUGIN_ROOT}/scripts/list-sessions.js" "${TRANSCRIPTS_DIR}" \
--source all --cwd "${PWD}" --current-source claude --limit 11 --offset 0
Resolving PLUGIN_ROOT. Claude Code exports CLAUDE_PLUGIN_ROOT; Codex does not always export
CODEX_PLUGIN_ROOT. If both are empty, use the directory that contains THIS SKILL.md, two levels
up — the host tells you that path when it loads the skill. Do not guess an install location.
When this skill runs under Codex, pass --current-source codex instead of claude in every command
below.
--current-source names the tool this skill is running in, so isCurrent marks the session being
written right now instead of whichever transcript happens to be newest. --source takes all
(default for this skill), claude, or codex. Pass codex or claude when
the user named one tool. Codex keeps every session in one global tree, so --cwd is what scopes them
to this project; Codex subagent rollouts are excluded, the same way Claude subtask transcripts are.
Each result carries source (claude | codex) and, for Codex, originalPath (the rollout the
line numbers belong to) alongside path (the normalized copy the other scripts read).
The script outputs JSON. If the script returns an empty array, display "No previous sessions found in this project." and stop.
Current session identification: The script sets isCurrent: true on the session whose JSONL is most recently modified (the one being actively written). This is reliable even after auto-compact (unlike firstMsg comparison, which fails because the LLM's first visible message becomes the summary).
Case A/B/C/D list display:
- Look at the session with
isCurrent: true:
- If
hasContextLoss: true → display it as #0 [default] (with 📍 marker plus any @@/+/++ event badges). #1..N are other sessions.
- If
hasContextLoss: false → exclude it entirely from the list (its full content is in live memory, nothing to restore). #1..N are other sessions.
- If no other sessions exist and current has context-loss → auto-restore current session, skip list display (Case C).
- If no other sessions exist and current has no context-loss → print "No previous sessions found in this project." and stop (Case D).
Format each session for display (preserve existing Case A/B/C/D logic — current session #0 with context-loss marker, etc.):
📂 Found {N} previous sessions in this project (Claude Code + Codex).
Pick the ones you want to restore — Claude will read them and bring the
context into this session so you can continue where you left off.
💡 Tip: Selecting 1-2 sessions is fast (almost always faster than /compact).
Selecting many sessions takes longer, but still no LLM summarization needed.
| # | Tool | Started | Last active | First message | Last message | Size |
|---|------|---------|-------------|---------------|--------------|------|
| 1 | CC | Mar 31 09:00 | today 14:05 | "improve the skill..." | "ok go ahead..." | 122KB · 3 msgs |
| 2 | Codex | Mar 31 08:30 | today 13:59 | "local agent actually..." | "let me test the skill..." | 2.1MB · 82 msgs |
| ... | | | | | | |
Enter:
- numbers only (e.g., "1,3" or "1-4") — fast restore
- numbers + ":" + topic (e.g., "1,3 : PDCA implementation") — topic-based restore (slower, more accurate)
- "more" for pagination
- (empty) for default
💡 Topic search adds an LLM step so it takes longer, but restores specific memories more accurately.
Use --limit N and --offset N for pagination. When the user types "more", re-run list-sessions with --offset increased by 10 (the limit). Numbers continue sequentially across pages.
Wait for user selection before proceeding. This avoids preprocessing sessions the user doesn't need.
Step 2: Parse Input
First, strip any --level N (or -lN) token from anywhere in the argument and discard it — it is
accepted for older habits and changes nothing.
Next, if the remaining ARGUMENT is claude or codex (alone or before a : topic), that
is a source filter, not a selection — re-run Step 1 with --source claude or --source codex and
show the narrowed list.
Then split the rest on the first ::
- Left side → numbers part. Parse using existing Case A/B/C/D logic (additive with #0, ranges, comma lists).
- Right side (optional) → topic string (trim whitespace). May be absent.
Examples:
1,3 → sessions [1, 3], no topic
1-4 : PDCA implementation → sessions [1, 2, 3, 4], topic = "PDCA implementation"
: error handling → only #0 (default), topic = "error handling"
- `` (empty) → default selection, no topic
1,3 : auth bug → sessions [1, 3], topic = "auth bug"
Step 3: Ensure Cache & Preprocess
preprocess.js is self-managing: it derives the cache path from the JSONL path, checks format version + mtime, and skips if fresh. Just call it for each selected session.
node "${PLUGIN_ROOT}/scripts/preprocess.js" "${TRANSCRIPT_PATH}"
node "${PLUGIN_ROOT}/scripts/preprocess.js" "${TRANSCRIPT_PATH}" --original "${ORIGINAL_PATH}"
The cache file is at (Claude Code sessions; a Codex session's cache is the same path with
codex/ inserted after super-token-saver-data/ — restore.js resolves both, so only build
this by hand to inspect the cache):
PROJECT_HASH=$(echo "${PWD}" | sed 's/[^a-zA-Z0-9]/-/g')
CACHE_FILE="${HOME}/.claude/super-token-saver-data/${PROJECT_HASH}/${SESSION_ID}/compact.txt"
Current session with context-loss: The compact.txt contains the FULL session. When reading it, use lastContextLossLine from list-sessions.js to filter: only read entries where L{n} < lastContextLossLine. Content after the last context-loss event is already in live LLM memory.
restore.js --before-boundary (Step 4) already does this cut, and finds the boundary from the
compact file's own System: "[auto-compact boundary]" block rather than from a line number — so
Step 4 alone is enough and this step is only worth running on its own to inspect the cache.
Current session WITHOUT context-loss: Skip — entire session is in live memory.
Past sessions: Read the full compact.txt (none of their content is in live memory).
The preprocessor (v6) outputs a compact text transcript with [Session:{sid} {ISO} L{n}] headers. The L{n} is the JSONL line number of the user message — this enables direct seek into the original transcript for topic-based restoration.
Preprocessing is instant (< 1 second even for 60MB+ transcripts).
Step 4: Load Compact
Render every turn of each selected session. For a compacted current session, restore only the
pre-boundary content. There are no restore levels.
Compact text is a sequence of blocks, each starting with a [Session:...] header line. Cut on that
boundary, never on raw line counts, or a turn gets split in half.
node "${PLUGIN_ROOT}/scripts/restore.js" "${TRANSCRIPT}" [--before-boundary] --out "${OUT}"
restore.js owns the rendering and refreshes the compact cache first (so Step 3 is folded in).
Do not reimplement the rendering here — one rule with two copies is how this skill and the
after-compact hook drifted apart once already. (That hook now has its own path,
restore-ledger.js, which restores verbatim from a per-session ledger; it does not read
compact.txt.)
Then:
- No topic → Read the whole file. For files over ~10K tokens read in chunks using
offset/limit. Always read the ENTIRE file — never skip sections. Proceed to Step 6.
- Topic provided → Do NOT Read compact.txt yet. Proceed to Step 5.
Step 5: Topic-Based Original Restoration
Goal: Load compact.txt with the top 20 most topic-relevant truncated turns replaced by their full JSONL originals. The original compact.txt files are never modified — the assembled result is written to a temp file.
Step 5a: Extract user turn list
Extract all user message headers from compact.txt files programmatically (no LLM Read needed):
python3 << 'PYEOF'
import json, os, re
sessions = [
]
results = []
for sid, path in sessions:
with open(os.path.expanduser(path)) as f:
content = f.read()
for m in re.finditer(
r'\[Session:([a-f0-9]+) (\S+) L(\d+)\].*?User: "(.*?)"',
content
):
results.append({
"sid": m.group(1),
"ts": m.group(2),
"line": int(m.group(3)),
"msg": m.group(4)[:300]
})
print(json.dumps(results, ensure_ascii=False))
PYEOF
Step 5b: LLM selects top 20
Read the JSON output from Step 5a. For each user turn, judge topic relevance. Select the top 20 most relevant turns (by topic match strength). Output a list of (sid, line) pairs.
If fewer than 20 turns match, include only those that match. If zero match, skip to Step 4 no-topic path (load compact as-is).
Step 5c: Batch extract originals
Extract all 20 matched turns' originals from JSONL files in a single python script (one pass per JSONL file):
jsonl_path is the path field from list-sessions, never originalPath. For a Codex session
those differ: the extractor below parses the shape Claude Code writes, so handing it the raw Codex
rollout produces empty user text instead of an error — a silent, plausible-looking failure. The
normalized copy carries the same line numbers, so L{n} still lands on the right turn.
python3 << 'PYEOF'
import json, sys
extractions = {}
results = {}
for sid, info in extractions.items():
target_lines = set(info["lines"])
all_lines = {}
with open(info["jsonl_path"]) as f:
for i, raw in enumerate(f, 1):
if i in target_lines or any(i > t for t in target_lines):
all_lines[i] = raw
for target_line in info["lines"]:
d = json.loads(all_lines.get(target_line, '{}'))
content = d.get("message", {}).get("content", "")
if isinstance(content, list):
user_text = " ".join(
b["text"] for b in content
if isinstance(b, dict) and b.get("type") == "text"
)[:3000]
else:
user_text = str(content)[:3000]
assistants = []