Sessions & Undo
AtomCode persists every conversation by default, so you can restore, resume, clear, or compact at any time. A single /undo rewinds conversation memory back to any earlier turn.
Session lifecycle
Each atomcode launch creates a session. A session contains:
- Full message history (user prompts, AI replies, tool calls)
- The associated working directory
- The associated provider / model
- Token usage stats
- File-history snapshots of every file edit made in that session
Session data is persisted under ~/.atomcode/sessions/, grouped by project (working-directory hash).
Resuming sessions
Continue the last one from the CLI
atomcode -c # or atomcode --continue
The most common case: pick up exactly where you left off yesterday.
Switch sessions inside the TUI
/resume
Opens the session picker. It lists this project's historical sessions newest-first; jump to any of them quickly. Each entry uses the most recent user prompt as its label for easy recognition.
Start a clean new session
/session
Spin up a fresh context without changing the working directory. Good for "the previous task is wrapped — onto something totally unrelated".
Background sessions (/bg)
Need to juggle multiple tasks without losing the current conversation? /bg parks the current session in the background and opens a fresh foreground — switch back any time. Up to 16 concurrent background slots.
| Command | What it does |
|---|---|
/bg | Send the current session to the background and open a new foreground |
/bg list (alias /bg ls) | List all background sessions: slot, ID, state, created, summary |
/bg <N> | Resume slot N as foreground (the current foreground is swapped to background) |
/bg drop <N> | Drop background slot N |
/bg help (aliases -h, --help) | Show built-in help |
Session states
The state column in /bg list reflects what each background session is doing:
- running — the model loop is still executing; tool calls and output keep advancing in the background
- idle — the model turn finished; waiting for your next prompt
- done — the session was explicitly ended
- cancelled / error — interrupted, or the background run hit an error
So /bg isn't just "suspend" — the model actually keeps working in the background; when you switch back, the result is already there.
/background <task> — one-shot dispatch
If you don't want to swap foreground/background manually and just want to "have it look something up real quick", use the /background compatibility entry:
/background list every unused dependency under src
It starts a one-shot task in a /bg slot (configured with a read-only tool subset by default so the main conversation context isn't polluted). When done, check /bg list, use /bg <N> to read the result, /bg drop <N> to discard.
The foreground is debugging module A; the model is editing and running cargo check (slow). You realise you also want to refactor module B — /bg straight to a new foreground for B. The build on A finishes in the background, state flips to done; /bg 1 to switch back and read the result.
Clear vs compact vs new session
| Command | Keeps history | Keeps session ID | When to use |
|---|---|---|---|
/clear | No | Yes | "Reset the dialogue" within the same session; keep the session entry so you can /resume later |
/compact | Partial (summarised) | Yes | Context is filling up but you don't want to lose the earlier thread |
/session | Starts new thread | No (new ID) | Beginning a completely unrelated task |
Rewinding conversation memory with /undo
/undo rewinds conversation memory to before a given turn — removing that turn and everything after it — and drops the prompt you typed for that turn back into the input box so you can edit and resend it.
/undo # rewind the last turn
/undo N # rewind to turn N (1-based; counts only the prompts you actually typed)
The scrollback dividers for the removed turns are cleared too, and the session is saved immediately — so your next /resume reflects the rewound state.
/undo rewinds conversation memory only — it does not restore files on disk. If the AI edited code during those turns, those changes stay in your working tree; use /diff to review and revert them manually, or rely on git. You can't /undo while a turn is in flight — press Esc to cancel it first.
Inspecting and trimming cost
/cost
Shows cumulative input / output tokens for the current session. When the number approaches the provider's context_window:
- Use
/compactto compact history (early messages become a summary) - Or just
/sessionand start fresh - To avoid keeping large tool-call results, tell the model in the prompt to "stop re-reading those big files"
Multi-project workflows
AtomCode groups sessions by working directory. Recommended ways to switch:
- From the CLI, specify with
-C - While running, use
/cd;default_workdiris persisted automatically
Next steps
- Project Instructions — lock in per-project context with
.atomcode.md