Best for
- Design resume and continue flows for a coding-agent CLI
- Decide how session IDs, titles, or logs map to recovery behavior
- Restore transcripts, summaries, or worktree-bound state safely
vasilyu1983/AI-Agents-public/frameworks/shared-skills/skills/ai-coding-agents-sessions/SKILL.md
Designs session lifecycle for coding-agent runtimes. Use when implementing resume, transcript restoration, checkpoint rewind, cross-worktree recovery, or session-state persistence.
Decision brief
Use this skill to design or review the session lifecycle for a coding-agent runtime: session IDs, transcript persistence, resume pickers, stale-cache clearing, cross-worktree recovery, and what state must be restored versus recomputed.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Declared | Source record | Install path and trigger |
| Claude Code | Declared | Source record | Install path and trigger |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill "frameworks/shared-skills/skills/ai-coding-agents-sessions"Inspect the Agent Skill "ai-coding-agents-sessions" from https://github.com/vasilyu1983/AI-Agents-public/blob/53f6cb73ea53a2646e3e7d4665062ad66f3683ac/frameworks/shared-skills/skills/ai-coding-agents-sessions/SKILL.md at commit 53f6cb73ea53a2646e3e7d4665062ad66f3683ac. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Define session identity first. Use a stable session ID and keep title or search aliases as secondary lookup keys. 2. Split restoreable from recomputable state. Persist transcripts, summaries, and user-visible session identity; recompute caches and discovery indexes after resu…
Goose runs as an ACP stdio server. When an editor (Zed, JetBrains, etc.) disconnects and reconnects, the session ID is passed back on the new stdin pipe and the agent re-attaches in-place. This is different from in-process resume (already covered by rewind/checkpoint) and differ…
Review the “ASCII Flow” section in the pinned source before continuing.
Review the “Quick Reference” section in the pinned source before continuing.
Design resume and continue flows for a coding-agent CLI
Permission review
The documentation asks the agent to run terminal commands or scripts.
Claude Code supports background agents: daemon-supervised processes that run independently of the active terminal, persisting between invocations and resumable through the agent-view UI.Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 97/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 80 | Source | Repository attention, not individual Skill quality |
| Compatibility | 2 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill to design or review the session lifecycle for a coding-agent runtime: session IDs, transcript persistence, resume pickers, stale-cache clearing, cross-worktree recovery, and what state must be restored versus recomputed.
This skill owns runtime session lifecycle. For persistent repo instructions and always-loaded memory, use ../agents-memory/SKILL.md.
new or resumed invocation
|
v
session identity
project + worktree + session_id + title + runtime mode
|
v
state restoration
transcript + summaries + tool state + task state + provider cache metadata
|
v
branch decision
continue | rewind | compact | clear | fork subagent | exact resume | claude agents (background resume)
|
v
active turn
append events, persist checkpoints, keep recovery path auditable
| Question | Read | Outcome |
|---|---|---|
| What belongs in a coding-agent session model? | references/session-lifecycle-and-resume.md | Session IDs, picker flows, stale-cache reset, and resume semantics |
| How should transcripts recover across worktrees and summaries? | references/transcript-restoration-and-cross-worktree-recovery.md | Restoration boundaries, search, cross-project safeguards, and replay rules |
| How do users decide between continue / rewind / clear / compact / subagent at each turn? | references/context-lifecycle-and-branching.md | 1M-context branching model, context rot zone, rewind > correction, compact-vs-clear, bad-compact causes, subagent mental test |
| How do forked subagents change session lifecycle (cache, isolation, resume, cost)? | references/context-forking.md | Blank-vs-forked startup, CLAUDE_CODE_FORK_SUBAGENT=1 and /fork surfaces, cache-prefix economics, fork-as-exception rule |
| Which resume path should I use (session ID / picker / ACP re-attach / recipe re-seed)? | references/resume-path-decision-tree.md | Decision tree, path comparison table, prompt-cache economics in subagent spawning |
| How does OpenAI Codex split Session / Task / Turn protocol state? | references/openai-codex-session-task-turn-protocol.md | SQ/EQ protocol, response bookmarks, one-active-task invariant, and interruption rules |
| How does Codex persist, resume, fork, and cloud-resume sessions? | references/openai-codex-session-persistence.md | SQLite-backed session index, codex resume UUID lookup, codex fork branch semantics, codex cloud task-apply |
| Need | Use Instead |
|---|---|
| Persistent repo instructions and shared memory files | ../agents-memory/SKILL.md |
| Remote execution or bridge sessions | ../ai-coding-agents-remote-runtime/SKILL.md |
| Background task lifecycle | ../ai-coding-agents-tasks/SKILL.md |
Claude Code supports background agents: daemon-supervised processes that run independently of the active terminal, persisting between invocations and resumable through the agent-view UI.
| Aspect | Detail |
|---|---|
| Launch | claude --bg "<task>" from the shell, or /bg <task> / /background <task> from within a session (carries over in-flight shell commands, subagents, and workflows) |
| Isolation | Each background session moves into its own git worktree under project-relative .claude/worktrees/ before editing, unless it's already in a worktree, isn't a git repo, or worktree.bgIsolation is set to "none" |
| Session state | Written to ~/.claude/jobs/<id>/state.json; each job also gets a scratch dir at ~/.claude/jobs/<id>/tmp/ and a CLAUDE_JOB_DIR env var pointing at it |
| Roster | All active background sessions tracked in ~/.claude/daemon/roster.json, used to reconnect after a supervisor restart |
| Daemon | A persistent on-demand supervisor process runs background sessions and restarts stopped ones (idle timeout ~1 hour) with conversation state intact |
| Resume/manage | claude agents opens the agent-view roster (no /agents slash command exists); claude attach <id>, claude stop <id>, claude respawn <id>, claude rm <id> operate on a specific job from the shell |
| CI usage | claude agents --json (add --all for completed sessions, --cwd <path> to scope) returns the roster as JSON with id, state, status, waitingFor fields; CI can poll this before collecting output |
~/.claude/jobs/<id>/state.json — per-job session state (transcript, tool state, task state)
~/.claude/jobs/<id>/tmp/ — per-job scratch directory (no permission prompts)
~/.claude/daemon/roster.json — daemon-maintained roster of all known background jobs
~/.claude/daemon.log — supervisor process log
<project>/.claude/worktrees/ — isolated worktrees for background sessions (project-relative, not under the user's home config dir)
When a user returns to a background agent after leaving the terminal:
claude agents to open the roster (or claude agents --cwd <path> to scope to a directory) → select the row → attach with Enter/→, or peek with Space without attaching.claude attach <id> (or claude attach <name> if the session was renamed).disableAgentView: true in settings, or CLAUDE_CODE_DISABLE_AGENT_VIEW=1): fall back to claude --resume <id> using the job ID from roster.json.claude agents --json | jq '.[] | select(.id == "<id>") | .status' to poll job completion before collecting output.claude attach <id> restarts it in place; if the transcript was misread as empty on restart, Claude Code renames it with an .orphaned- suffix rather than discarding it (v2.1.196+).| Setting | Effect |
|---|---|
disableAgentView: true (or CLAUDE_CODE_DISABLE_AGENT_VIEW=1) | Turns off claude agents, --bg, /background, and the on-demand supervisor entirely — not just the panel |
cleanupPeriodDays: <n> | Governs local session/transcript retention generally (default 30 days, minimum 1); also bounds how long completed background jobs and their worktrees stick around |
awaySummaryEnabled: true (default) | Shows a one-line recap of what happened while you were away (5+ minutes) when you return to a session; set to false (or CLAUDE_CODE_ENABLE_AWAY_SUMMARY=0) to suppress it |
state.json is flushed on every checkpoint, and in-flight shell commands/subagents/scheduled tasks are handed off across a stop-restart cycle as of v2.1.196 — CLAUDE_CODE_DISABLE_BG_EXIT_HANDOFF=1 opts out).roster.json is the authoritative list of background sessions; session pickers should read from it when building the resume list, but it is a rebuildable cache over supervisor-managed process state, not the sole source of truth for a crashed daemon.disableAgentView is a managed enterprise setting exposed both as a settings.json key and an env var — enterprise deployments may hide the whole feature, not just the UI; implementations must not assume it is always present.awaySummaryEnabled is independent of agent-view visibility; a summary can be generated even for a foreground session resumed after being away.The references/resume-path-decision-tree.md decision tree should route to claude agents as a named path when:
--bg or /bgThis path sits between "exact session ID resume" (lower UX friction) and "picker search" (broader coverage) in the tree.
Claude Code creates a new checkpoint on every user prompt, capturing the code state before that prompt's edits begin. Checkpoints track only file changes made through Claude's own file-editing tools — they do not capture files touched by bash commands (rm, mv, cp, etc.) or by any process outside the current session. That is a load-bearing limitation, not an edge case: any runtime cloning this pattern must decide explicitly whether to widen tracked-change scope beyond editor-tool calls, and must not imply broader coverage than it has.
| Method | Behavior |
|---|---|
Esc Esc (double-tap, empty prompt) | Open the rewind menu. If the prompt has text, double-Esc clears the input instead (recoverable via Up) |
/rewind | Open the rewind menu via slash command |
| Select a checkpoint | Restore conversation, code, both — or summarize around that point |
Both summarize modes preserve the original messages in the session transcript (Claude can still reference them if needed) and accept optional steering instructions, the same way /compact does — but scoped to one side of a chosen point instead of the whole conversation.
If /clear ran earlier in the same process, the rewind menu shows an extra top entry, /resume <session-id> (previous session), to jump back to the pre-clear conversation (requires a recent-enough Claude Code version; on older versions use /resume and pick it from the picker instead). Design implication: /clear does not destroy the prior session's checkpoints — it starts a new one and the old session remains independently resumable/rewindable.
Checkpointing is not a replacement for git, and it is not the same primitive as branching a session. Three distinct mechanisms solve three distinct problems — conflating them is a common design mistake:
| Mechanism | Scope | What survives | Use when |
|---|---|---|---|
Rewind / checkpoint (/rewind, Esc Esc) | Same session, same conversation | Files reverted via copy-on-write/diff; conversation truncated or summarized in place | Undo the agent's own recent edits or steer the current thread without starting over |
Session branch (/branch, or claude --continue/--resume <id> --fork-session) | New, independent session — a full copy of the conversation so far | Original session is untouched and stays resumable; the new session diverges from that point forward | Try a different top-level approach while preserving the path you were on; A/B test prompting or implementation strategy from the same loaded context |
| Git commit | Durable, cross-session, cross-tool | Whatever you committed, forever | Permanent history and collaboration |
Rewind and /branch/--fork-session are easy to confuse because both "go back to an earlier point," but rewind mutates the current session in place while branching spins up a second, independent session ID that shows up grouped under the root session in the picker. Permissions approved with "allow for this session" do not carry over to a branched session. Users should still commit to git regularly — rewind and branching are for fast in-session experimentation, not long-term version control.
Checkpoints interact with compaction: "Summarize from here" and "Summarize up to here" let the user choose a point to compact around, keeping the side that matters intact while compressing the rest. This is a more targeted alternative to auto-compaction at the context limit, which always summarizes the entire history.
/branch or --fork-session mints a second, independent session ID. Documenting them as one feature causes users to lose the original thread when they only meant to peek at an alternative.Goose adds two session patterns not covered by the Claude Code-derived core: cross-process session re-attach over ACP, and recipe-as-session-seed for deterministic resume.
Goose runs as an ACP stdio server. When an editor (Zed, JetBrains, etc.) disconnects and reconnects, the session ID is passed back on the new stdin pipe and the agent re-attaches in-place. This is different from in-process resume (already covered by rewind/checkpoint) and different from same-machine file-watch continuation — the process may have restarted, but the session object persists.
A resumed session is usually rehydrated from the transcript. Goose's recipe model offers an alternative: a session can be re-seeded from the recipe that spawned it plus its parameters — a typed, versioned, much smaller artifact than a raw transcript. This is stronger than transcript replay because inputs are structured and the recipe version pins extension set and instructions.
(recipe ref, recipe version, parameter values, output checkpoints) alongside the transcript. Resume can choose: replay transcript (high fidelity, large) or re-spawn from recipe + parameters + last checkpoint (deterministic, small).seed_ref: Option<RecipeSeed> field to session metadata. When present, resume UI should offer "replay transcript" and "re-run recipe from last checkpoint" as named modes.references/session-lifecycle-and-resume.md — Session identity, picker flows, cache clearing, and resume entrypointsreferences/transcript-restoration-and-cross-worktree-recovery.md — Transcript recovery, summary persistence, and cross-worktree safeguardsreferences/context-lifecycle-and-branching.md — Per-turn branching (continue/rewind/clear/compact/subagent), 1M-context rot zone, steered compaction, and subagents as context-management primitivereferences/context-forking.md — Blank-vs-forked subagent startup, CLAUDE_CODE_FORK_SUBAGENT=1 and /fork surfaces, cache-prefix economics, isolation guarantees, and fork-as-exception rulereferences/resume-path-decision-tree.md — When to use session ID vs picker vs ACP re-attach vs recipe re-seedreferences/openai-codex-session-task-turn-protocol.md — OpenAI Codex Session / Task / Turn protocol, queue contract, response bookmarks, and interruption rulesreferences/openai-codex-session-persistence.md — SQLite session index, codex resume / fork / cloud subcommand semantics, storage path layeringdata/sources.json — Primary documentation and source references for session lifecycle guidance../agents-memory/SKILL.md../ai-coding-agents-remote-runtime/SKILL.md../ai-coding-agents-tasks/SKILL.mdcode.claude.com/docs/en/{sessions,checkpointing,sub-agents,agent-view} and learn.chatgpt.com/docs/developer-commands on 2026-07-11. Several details in this file are gated behind a specific Claude Code version (noted inline, e.g. "v2.1.117+", "v2.1.196+"); re-check the changelog before asserting exact behavior on an unknown build.learn.chatgpt.com/docs/developer-commands, 2026-07-11) and internal storage architecture (SQLite index, crate/file names) pinned to a specific openai/codex source commit from 2026-05-25 that is not restated in public docs — treat the storage-layer claims as commit-pinned engineering detail, not a documented public contract, and re-check against current source before relying on exact file/module names.Before applying this skill on a non-trivial task, read learnings.consolidated.md in this directory (and learnings.md if present).
After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to learnings.md via agents-skills-feedback-loop/scripts/append_learning.py. Do not modify SKILL.md itself.
Frequently asked questions
Use this skill to design or review the session lifecycle for a coding-agent runtime: session IDs, transcript persistence, resume pickers, stale-cache clearing, cross-worktree recovery, and what state must be restored versus recomputed.
The source record exposes this install command: npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill "frameworks/shared-skills/skills/ai-coding-agents-sessions". Inspect the command and pinned source before running it.
The pinned source record declares support for: codex, claude code.
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
vasilyu1983/AI-Agents-public
Guides iOS testing with XCTest, XCUITest, Swift Testing, simctl, and xcresult. Use when choosing destinations, controlling flakes, or parsing test artifacts for native apps.
vasilyu1983/AI-Agents-public
Designs and audits UI/UX systems with usability and accessibility requirements. Use when shaping flows, design systems, interaction patterns, or WCAG-aware product behavior.
vasilyu1983/AI-Agents-public
Designs and audits native Android interfaces. Use when reviewing Compose layout, typography, color, motion, or adaptive patterns on a verified emulator build.
vasilyu1983/AI-Agents-public
Systematic debugging for crashes, regressions, flakes, and production bugs. Use when diagnosing stack traces, logs, traces, or profiling data.