Task 1.4
Session Management
Resume, fork, and named sessions for long-running workflows
📘What You Need to Know
Session Operations Overview
Claude Code sessions preserve conversation context across interactions. Understanding session operations is essential for multi-day development workflows, parallel feature branches, and exploratory coding without polluting your main work.
- •--resume: continue a previous session with full preserved context
- •--resume --session-name "feature-auth": resume a specifically named session
- •--session-name "feature-auth": start or tag a session with a memorable name
- •fork_session: branch for exploration — changes do not affect the main session
Named Sessions for Organized Workflows
Named sessions let you maintain parallel work streams. A developer working on authentication might run --session-name "feature-auth-redesign" while simultaneously having --session-name "bugfix-checkout" for an urgent fix. Each session preserves its own context independently.
Resume a named session with --resume --session-name "feature-auth-redesign". The session picks up exactly where you left off — all prior context, file reads, and decisions are preserved.
Use descriptive session names tied to tickets or features. "session-1" is useless when you have five active sessions.
fork_session vs --resume
Resume continues the same conversation thread — all prior context carries forward. Use resume when you want to pick up where you left off on the same task.
fork_session creates an independent branch for exploration. Changes made in the fork do not affect the main session. Use fork when you want to try an alternative approach without risking your current progress — like creating a git branch for experimentation.
# Continue main implementation
claude --resume --session-name "feature-auth"
# Explore alternative approach without affecting main session
# (fork_session creates independent branch)
claude --resume --session-name "feature-auth" --fork-sessionStale Context Risk in Long Sessions
In long-running sessions, data retrieved early may become outdated. An agent that fetched order status 50 turns ago may still reference stale information. This is a critical risk — the agent confidently acts on outdated facts.
Mitigation strategies: periodically re-fetch critical data at key decision points, use scratchpad files to persist important state across context resets, and use /compact to reclaim context space while preserving essential facts in immutable case facts blocks.
Never assume resumed sessions have fresh data. Re-fetch critical information before making decisions based on it.
⚠️Exam Traps
Trap: Assuming resumed sessions always have fresh data
Why it's wrong: Stale context is a critical risk — data retrieved 50 turns ago may be outdated.
Trap: Using fork_session when you want to continue the same workflow
Why it's wrong: Fork creates an independent branch — changes do not merge back automatically.
Trap: Using generic session names like "session-1" across multiple work streams
Why it's wrong: Impossible to identify which session contains which work when resuming days later.
Trap: Never compacting or managing context in sessions lasting hours
Why it's wrong: Context window fills up, causing degradation and forgotten constraints.
✓Concept Check
You want to explore an alternative implementation without affecting your main session. What should you use?
🔨Build Exercise
Beginner35 minutesManage Multi-Session Development Workflow
What you'll learn
- •Use named sessions and fork_session correctly
- •Understand stale context risks in long sessions