Claude Code: Start a Fresh Session for Each Task

Separate AI task cards connected to durable repository files

Start a fresh Claude Code session for each distinct task. Keep lasting knowledge in repository files so the next session can begin with focused context.

In Claude Code, a session works well as a disposable, single-task scratchpad. Finish a feature or bug fix, verify the result, save the changes, and begin the next task with a new session or /clear. Anthropic’s best practices still recommend clearing between tasks, even as automatic compaction supports long-running work.

This is a workflow recommendation, not a benchmark showing that fresh sessions are always faster or that each compaction causes a fixed accuracy loss. It can reduce stale assumptions and unnecessary context; results depend on the task, model, and information you carry forward.

Why an endless session becomes harder to trust

A summary cannot preserve every detail

Compaction replaces conversation history with a shorter summary. Exact function signatures, exceptions, and the reasons behind a rejected approach may need to be recovered from the files or transcript. Summarizing repeatedly can carry forward an earlier omission, but the “photocopy of a photocopy” metaphor is a risk model, not a measured degradation curve. The architecture documentation explicitly warns that early detailed instructions can be lost.

Official Claude Code documentation explaining automatic compaction and how to specify what a summary should retain

Captured public page from Anthropic’s Claude Code architecture documentation, showing compaction and focused instructions. Captured 2026-10-29.

Old assumptions compete with the current task

A long conversation can mix abandoned debugging paths, superseded code, and constraints from another feature. That creates opportunities for Claude to reuse an outdated assumption or propose a fix for an issue that is already resolved. Before making another change, ask it to read the current files and diff. When the task itself changes, clearing the conversation is a useful boundary.

Less context does not guarantee a faster next turn

Unnecessary history adds input context, but latency and cost also depend on prompt caching, output length, and tool work. A fresh session may need to read files again; compaction also requires a summarization request. The prompt caching documentation explains these tradeoffs. Evaluate the whole task rather than assuming that every shorter prompt is cheaper.

Choose /clear, /compact, or /rewind

SituationPreferred actionReason
Moving to a different feature, bug, or PRNew session or /clearGive the new task its own relevant context.
Continuing one large feature/compact with a focusPreserve the same task’s decisions while shortening history.
Recovering from a failed detour/rewindReturn to an earlier conversation point; choose whether to restore code too.
Task verified and committedNew session or /clearUse the saved code and a short handoff as the next starting point.

The command reference describes these commands. /clear starts a new conversation without reverting working files. Earlier sessions remain resumable; see session management.

For /rewind, inspect the restore options. Restoring conversation, restoring code, and restoring both have different effects. Checkpoints do not cover every shell-only file change and do not replace version control. See the checkpointing documentation.

Claude Code checkpointing documentation listing separate options to restore conversation, restore code, restore both, and summarize

Captured public page from Anthropic’s checkpointing documentation. The restore choices distinguish conversation state from file state. Captured 2026-10-29.

A practical session workflow

  1. Keep stable rules in CLAUDE.md. Record actual build and test commands, repository conventions, and architectural boundaries. Keep it short; link to detailed documents rather than pasting old conversations. Claude Code loads applicable instruction files when a normal session starts. See project memory. For a starting structure, use the project setup guide.
  2. Use Git for durable code history. Complete one scoped task, run the relevant checks, review the diff, and commit the intended files with Git. Record unfinished work and important decisions in a task document or issue: a commit alone does not explain every decision. Then run /clear or start a new session.
  3. Compact when the same task still needs continuity. Tell Claude what must survive, then have it verify current files before editing again.

For example, run this inside Claude Code:

/compact focus on the schema migration and updated route handlers; preserve decisions, changed file paths, test results, and remaining work

Before resetting an unfinished task, ask for a brief handoff:

Record the current goal, decisions, changed files, checks actually run,
known failures, and the next step in docs/task-handoff.md.

Treat that path as an example and adapt it to the repository. In the next session, provide the goal and handoff path, then ask Claude to inspect the current code and Git diff. This gives the session a clear starting point while keeping the durable record reviewable outside the conversation.