Real work rarely fits into ten minutes. You start the dev server and leave it running all afternoon, finish issue #3 and move on to issue #2, shut the laptop for lunch and want to pick up exactly where you were, and after a few hours the session's context is full of things you no longer need. The last lesson of level 7 gathers the tools for long sessions: background work, naming and resuming sessions, and keeping context lean.
The trouble with long sessions
Three things tend to happen over hours of work:
- Waiting: a dev server, a long test suite, a build. While you wait, both you and Claude sit idle.
- Stopping: the day ends, you switch tasks, the machine restarts. Tomorrow you want to carry on without retelling everything.
- Context filling up: every file Claude reads and every command output stays in the session. The fuller the context, the easier it is for Claude to mix up old and new, and the more each message costs in tokens.
Each problem has its own tools, and the sections below go through them in turn.
Background work
Background commands. Two ways:
- Tell Claude: "start the dev server in the background".
- While a Bash command is taking a while, press
Ctrl+Bto push it to the background. In tmux, press it twice.
A background command writes its output to a file that Claude reads when needed, while you and Claude carry on. A command that runs past its timeout also moves to the background instead of being stopped. Type /tasks to see and stop running work. When you exit Claude Code, it's cleaned up.
Good candidates for the background: a dev server (todo-api's npm start), tests in watch mode, builds, package installs.
No need to wait your turn. While Claude is working, you can still type and press Enter: the message is queued and sent when Claude finishes the turn, without interrupting. To run a command yourself without going through Claude, start it with !, as in ! npm test; the output lands in the context and Claude reads it.
A whole session in the background. /background (short form /bg) moves the entire conversation to the background and gives you your terminal back. claude --bg "fix issue #2" starts a background session straight from the shell. claude agents opens agent view, a screen for watching every background session: which ones are working, which need your answer. It's in research preview, so the interface may still change. This is the next step after level 4's subagents: not just a side task, but a whole independent session.
Naming and resuming sessions
Sessions are saved continuously, so shutting down loses nothing. To resume:
| Command | Opens |
|---|---|
claude --continue |
The most recent session in this folder |
claude --resume |
The session picker |
claude --resume <name or id> |
That exact session |
/resume |
Switch to another session from inside one |
A resumed session has its full conversation and model; resuming from a terminal with --continue or --resume usually keeps the permission mode too. Background commands do not restart; unfinished background work shows up as a note so Claude knows.
Name sessions so they're easy to find: claude -n done-filter when you start, or /rename done-filter while working. Approving a plan in plan mode (lesson 7.1) sets a title too. In the picker, Space previews, Ctrl+R renames, Ctrl+B filters by git branch, and typing searches.
One thing we ran into when testing: names don't have to be unique. After a few runs, three sessions shared the name done-filter-notes. Then claude --resume done-filter-notes doesn't guess: in an interactive session it opens the picker with the name as the search term, and with claude -p it reports an error listing the three IDs. Resuming by ID went to the right session, and Claude remembered the decision exactly. The lesson: give each job a specific name, such as issue-3-done-filter, rather than reusing a generic one.
Context filling up
Type /context to see what's taking up space: messages, files read, MCP tools, CLAUDE.md, skills.
When context gets close to full, Claude Code compacts it automatically: it replaces most of the history with a summary. The session carries on, but it's worth knowing what's left afterwards:
- Reloaded from disk: the root
CLAUDE.md, rules withoutpaths, auto memory, skill descriptions, and the plan written in plan mode. - Re-read: up to 5 of the files Claude most recently read or edited.
- Trimmed: invoked skills keep only their first 5,000 tokens (which is why lesson 3.3 advised putting what matters at the top of
SKILL.md). - Summarized away: rules with
pathsand subfolderCLAUDE.mdfiles (they reload when Claude touches a matching file), and context that hooks added. ASessionStarthook matchingcompactruns again to make up for that.
Background commands and subagents that are running keep running after compaction.
Keeping context lean
Don't wait for automatic compaction. A few habits:
/clearwhen switching to unrelated work. Done with issue #3, moving to issue #2: #3's history only adds noise. The old session is still saved, and/resumebrings it back.- A focused
/compactbefore a long new job:/compact focus on the done filter decisions. The summary keeps what you choose, rather than what Claude Code guesses matters. - Summarize one stretch with "Summarize from here" in
/rewind(lesson 7.2) when only a long debugging detour needs compressing. - Hand heavy reading to a subagent (level 4): the files it reads sit in its context, not yours.
- Quick questions with
/btw: the answer doesn't go into the history.
And if a job genuinely needs more context rather than a leaner one, some models have a 1 million token window variant ([1m]). But a bigger window doesn't replace the habit of tidying up.
A day with todo-api
Putting all of level 7 together into a working day:
- Morning:
claude --resume issue-3-done-filterto carry on from yesterday, orclaude -n issue-2-bad-jsonfor a new job. - Background: "start the dev server in the background", then keep working while it runs.
- Plan:
/planfor the issue (lesson 7.1), read carefully, approve. - Work, and step back when needed: hooks keep the tests green (level 6),
Esc Escwhen a step goes wrong (lesson 7.2). - Switch jobs: commit, then
/clearbefore moving to another issue. - One big job on its own:
/bgorclaude --bgfor work you don't need to watch step by step, and check on it withclaude agents.
Level 8, the last one, takes everything out of your terminal: running Claude Code unattended (claude -p) in CI, then packaging all of todo-api's tooling into a plugin the whole team installs once.