Explainer

Why AI coding agents lose context between machines

AI coding agents lose context when you switch between your laptop and desktop or restart on another development machine because language models are stateless and each agent saves transcripts (prompts, replies, and tool calls) as local-only files on one disk — and Claude Code deletes them after 30 days by default. Atuin Threads fixes this by keeping its own copy in local SQLite with no retention cap, syncing it end-to-end encrypted across machines, and restoring native sessions across 10 locally stored agents (11 captured total) with atuin resume.

install.sh
curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
desktop — local transcripts
~/.claude/projects/api/8f3a1c.jsonl 30d TTL
~/.codex/sessions/.../rollout-019b.jsonl
~/.local/share/opencode/opencode.db
laptop — next morning
$ claude --resume
No conversations found to resume
Local transcripts never left desktop.

Quick answer

Your AI coding agent loses prompts, tool calls, and debugging context between machines or restarts because LLMs carry no memory between calls and local agents write session files only to the disk where they ran — in incompatible per-agent formats that never sync. To fix it, capture sessions into Atuin Threads: it keeps its own local SQLite copy past Claude Code's 30-day default deletion, syncs end-to-end encrypted across machines, and restores native transcripts with atuin resume or exposes them to any agent over MCP.

Why context disappears — and what fixes it
  1. 01

    Local-only session files: Claude Code, Codex, opencode, Copilot CLI, Kiro, and Cursor write transcripts to one machine's local disk. Moving from desktop to laptop — or between development machines — leaves every prompt and tool call behind.

  2. 02

    Incompatible formats & automatic expiry: Every harness uses its own JSONL or SQLite schema, so agents cannot open each other's files. Worse, Claude Code deletes local transcripts after 30 days by default (cleanupPeriodDays).

  3. 03

    Restarts, compaction, and static rules: Fresh sessions start with an empty context window, long sessions compact away earlier tool outputs, and CLAUDE.md or AGENTS.md store static project rules rather than past session history.

  4. 04

    The fix: Atuin Threads (free, MIT open source) captures 11 coding agents into local SQLite with no retention cap, syncs end-to-end encrypted across machines, restores or forks native sessions across all 10 locally stored agents, and lets fresh sessions search past work over MCP.

Six ways AI coding agents lose context (symptoms, causes, fixes)

Switching from desktop to laptop, restarting on another dev machine, and switching harnesses each break context for a different reason. Match the symptom you hit to the underlying cause and fix.

Symptom, cause, and fix table
Cause Symptom Why it happens Fix
Local-only files Prompts, tool calls, and sessions vanish when you switch between laptop and desktop; --resume shows nothing. Agents write transcripts to local disk (~/.claude, ~/.codex, local SQLite) with no cross-machine sync. Enable Atuin Threads capture and E2E encrypted sync on both machines, pull git, and run atuin resume to restore the native transcript.
Agent-specific formats You start in Claude Code and switch to Codex or opencode, but the second agent cannot see earlier turns or tool outputs. Every harness uses its own transcript schema, message roles, and tool-call structure. None read another agent's files. Run atuin resume <id> --in codex (or --in opencode) to write the session in the target agent's native format with tool calls mapped over.
30-day retention cleanup An investigation from last month disappears from the resume picker on the exact same machine. Claude Code deletes local session transcripts after 30 days by default (cleanupPeriodDays in settings.json). Capture sessions with Atuin Threads (no retention cap); atuin resume rewrites deleted transcripts back to disk before launching Claude Code. You can also raise cleanupPeriodDays.
Context compaction Mid-session, the agent forgets an earlier constraint, repeats a failed check, or loses exact error output. When a conversation approaches the model's context window limit, the agent compacts or truncates older turns into a shorter summary. Keep sessions focused, fork before risky detours with atuin resume <session-id> --fork (or pick fork in atuin resume), or connect atuin mcp so the agent can query the full uncompacted transcript.
Fresh session restarts Restarting an agent on the same or a different dev machine forces you to re-explain yesterday's debugging and ruled-out fixes. Language models are stateless: new sessions start with an empty prompt history unless prior transcripts are restored or queried. Resume the thread with atuin resume, or connect Atuin MCP so the fresh session searches past threads via atuin_threads_search.
Rules vs. session history You wrote a thorough CLAUDE.md or AGENTS.md, yet the agent still repeats work from earlier sessions. Repo memory files store durable conventions and commands, not a chronological log of prompts, tool calls, and debugging dead ends. Keep static conventions in git memory files and keep chronological session history in Atuin Threads where agents can resume or search it.

Where each agent stores sessions locally

Six widely used local coding agents each persist conversations in a different directory, file format, and retention policy. None of these local stores sync across machines by default, and no agent reads another agent's directory.

Local session storage across 6 coding agents
Agent Local storage location Format Retention & sync Source
Claude Code ~/.claude/projects/<project>/<session-id>.jsonl (respects $CLAUDE_CONFIG_DIR) JSONL (one file per session) Deleted after 30 days by default (cleanupPeriodDays); local disk only Claude Code settings docs
Codex CLI ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl (under $CODEX_HOME), indexed by state_5.sqlite Append-only JSONL rollouts + SQLite index No automatic expiry; local disk only until deleted or moved to archived_sessions/ openai/codex
opencode ~/.local/share/opencode/opencode.db (respects $XDG_DATA_HOME; older versions used JSON under storage/) SQLite database (opencode.db) No automatic expiry; local disk only anomalyco/opencode
GitHub Copilot CLI ~/.copilot/session-state/<session-id>/events.jsonl (respects $COPILOT_HOME) JSONL event log Stored locally per session; no built-in cross-machine sync GitHub Copilot CLI docs
Kiro CLI ~/.kiro/sessions/<bucket>/<session-id>/messages.jsonl (respects $KIRO_HOME) Append-only JSONL Stored locally per session; no built-in cross-machine sync Kiro CLI docs
Cursor globalStorage/state.vscdb and workspaceStorage/<hash>/state.vscdb under the Cursor User data folder (macOS: ~/Library/Application Support/Cursor/User/; Linux: ~/.config/Cursor/User/; Windows: %APPDATA%\Cursor\User\), plus ~/.cursor/projects/<slug>/agent-transcripts/ SQLite (state.vscdb) + JSONL agent transcripts No documented automatic expiry; workspace history is keyed to local folder paths Cursor hooks docs

Storage paths reflect current upstream documentation and source code. Path encoding also matters: moving or renaming a project folder — or using different home paths on macOS (/Users/...) vs Linux (/home/...) — hides local sessions from an agent's picker even if you copy the files over.

Five ways to carry context between machines (compared)

Developers handle cross-machine handoffs in five common ways. Only a synced session store preserves full prompts and tool calls offline, avoids SQLite conflicts, survives Claude Code's 30-day cleanup, and translates between agents.

Cross-machine handoff methods compared
Method Preserves prompts & tool calls? Works across machines? Cross-agent? Survives 30d cleanup? Trade-off / limit
Atuin Threads ✓Full transcript (~64 KiB clip per huge tool output) ✓E2E encrypted sync + offline local SQLite ✓10 local agents restorable (11 captured) ✓Yes (no expiry) Free ($0, MIT); requires Atuin 18.24+ and opt-in setup on each machine.
SSH or tmux into one dev box ✓Yes (on that host) —Online only —No —No Breaks offline (flights, trains), adds latency, and locks you to one host and agent.
rsync, Dropbox or iCloud folder sync ✓Partial —Fragile —No —No (deletions sync) Concurrent writes corrupt SQLite (opencode.db, state_5.sqlite, state.vscdb); macOS/Linux paths mismatch.
Pasting handoff summaries —Summary only ✓Manual ✓Manual —Only what you pasted Drops exact tool outputs, diffs, and ruled-out fixes; fails if you forget before closing your laptop.
CLAUDE.md / AGENTS.md in git —Static rules only ✓Via git ✓Shared conventions ✓Yes Essential for repo rules, not a session log; ephemeral debugging state bloats every future prompt.

Four layers of coding-agent context

"Agent memory" is not one thing. Coding agents split context across four distinct layers with different lifetimes, storage limits, and portability across machines.

Coding-agent context layers compared
Context layer Where it lives Survives restart? Survives machine switch? What it holds & limits
Active context window In-memory prompt sent on each model turn —No —No Live conversation, file reads and tool results; bounded by the model window and thinned by compaction.
Local session transcripts Per-agent files on one machine (JSONL or SQLite) ✓Same machine —No Full prompts, replies and tool calls; locked to one harness and subject to local cleanup (30 days by default in Claude Code).
Repo memory files CLAUDE.md, AGENTS.md, .cursor/rules in git ✓Yes ✓Via git Static project conventions, architecture rules and commands; not a record of past sessions or debugging dead ends.
Synced thread store Atuin Threads: local SQLite + E2E encrypted sync ✓Yes ✓Yes Prompts, replies and tool calls across 11 agents (10 locally restorable) with no retention cap (~64 KiB cap per large tool payload). Free offline and free personal cloud sync, or self-hosted (MIT).

The fix: keep and sync every session with Atuin Threads

If your AI coding agent loses context after you restart it on a different device, pull your git branch on the second machine and run atuin resume. Atuin Threads keeps its own copy of every prompt, reply, and tool call in a local SQLite database with no retention cap — so sessions survive Claude Code's 30-day default cleanup — and syncs them end-to-end encrypted across every laptop, desktop, and development machine.

Atuin Threads captures 11 coding agents and supports full cross-machine restore, session forking, and continue-in handoffs across all 10 locally stored agents (Claude Code, Codex, opencode, GitHub Copilot CLI, Grok Build, Hermes Agent, Kiro, Pi, oh-my-pi, and Mistral Vibe, plus capture and continue-out from Amp). When you switch machines, atuin resume writes the native transcript back out before launching the agent, or continues it in a different harness with tool calls mapped over. When you start a fresh session and only need what an earlier one learned, Atuin's MCP server lets the agent search past threads and shell history directly without resuming them.

Local capture and personal end-to-end encrypted sync on Atuin Cloud are free ($0, MIT open source), or you can self-host the sync server on your own infrastructure. For teams working across shared repositories and multiple dev machines, Threads for teams (beta) lets teammates opt in to sharing workspace threads on the web and over MCP.

  1. 01 Install Atuin on each machine

    The installer runs atuin setup, which walks you through turning on Threads capture, MCP, and end-to-end encrypted sync (requires Atuin 18.24+).

    install.sh
    curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
  2. 02 Import existing sessions

    Capture starts when you turn it on. This imports local transcripts your agents already wrote on this machine.

    sh
    atuin threads import
  3. 03 Resume on your other machine

    Pull your git branch on the second device, then pick the synced session. Atuin restores the native transcript automatically before launching the agent.

    sh
    atuin resume

For the full walk-through and the 11-agent capability matrix, read the resume agent sessions guide. You can also explore Atuin for agents, our 2026 comparison of agent session tools, or the Atuin Threads announcement post.

Frequently asked questions

FAQ
Why do my AI coding agents lose context when I switch between machines or restart the session?

Language models are stateless, and local coding agents save conversation transcripts — including prompts and tool calls — to local disk on the machine where the session ran (such as ~/.claude/projects/ for Claude Code or ~/.codex/sessions/ for Codex). Because those files do not sync across machines and new sessions start with an empty context window, switching devices or starting fresh leaves prior context behind unless a tool like Atuin Threads captures, syncs, and restores it.

Why do my AI agent prompts and tool calls get lost when I switch between my laptop and desktop?

Every prompt, reply, and tool call is written only to the local transcript store on the machine where you ran the agent — JSONL files or a local SQLite database that never leave that disk. Turning on Atuin Threads capture and end-to-end encrypted sync on both your laptop and desktop copies those transcripts automatically so atuin resume restores them on arrival.

Why do we lose context when resuming AI agent work on different development machines?

Each development machine keeps its own isolated agent directories, and different OS home paths (such as macOS /Users/ vs Linux /home/) or incompatible per-agent schemas break naive file copies. Atuin Threads stores transcripts in a harness-independent SQLite database, syncs them end-to-end encrypted across machines, and rewrites native transcripts into the target machine's paths when you run atuin resume (and Threads for teams shares selected workspace threads across a team over MCP and the web).

What should I do when my AI coding agent loses context after I restart it on a different device?

Pull your latest git branch so the files on disk match where you left off. If Atuin Threads capture and sync are enabled on both devices, run atuin resume to restore the native transcript on the new device (or query it over Atuin MCP from a fresh session); otherwise install Atuin and run atuin setup and atuin threads import on both machines so future switches carry your prompts and tool calls automatically.

Why did my old Claude Code sessions disappear on the same machine?

Claude Code deletes local session transcripts after 30 days by default via the cleanupPeriodDays setting (documented in the Claude Code settings docs). Raising that setting keeps local files longer, or Atuin Threads keeps its own SQLite copy with no retention cap so atuin resume can rewrite and reopen expired sessions even after Claude Code deletes them.

Why don't CLAUDE.md or AGENTS.md prevent context loss?

Repo memory files are loaded as static instructions at the start of a session. They work well for coding standards, architecture notes, and commands, but they do not record what happened during yesterday's debugging session, which hypotheses failed, or what tool outputs came back.