Tasks orphaned when 'clear context' creates new session in plan mode
Resolved 💬 6 comments Opened Jan 25, 2026 by Nescio Closed Mar 6, 2026
Description
When exiting plan mode and selecting option 1 "Yes, clear context and auto-accept edits" (the default), a new session is created. Tasks created with TaskCreate remain in the old session's directory and become invisible to Claude's internal task tools.
Steps to Reproduce
- Start a Claude Code session
- Create tasks using
TaskCreate - Enter plan mode and create a plan
- When prompted "Would you like to proceed?", select option 1 "Yes, clear context and auto-accept edits" (default)
- Run
TaskList
Expected: Tasks from the planning session are visible
Actual: TaskList returns empty - tasks are orphaned in the old session's directory
Technical Details
- Tasks are stored in
~/.claude/tasks/{sessionId}/*.json - "Clear context" creates a new session with a new
sessionId - The task files remain in the old session's directory
- Claude's internal
TaskList/TaskGet/TaskUpdatetools only see the current session's tasks
Impact
This breaks the workflow of using tasks for high-level planning. Users who:
- Create a plan with tasks to track work
- Accept the plan with the default option
- Lose visibility into their task list
The tasks still exist on disk but are disconnected from the active session.
Possible Solutions
- Add a
SessionStarthook - allow users to run scripts when a new session starts (e.g., to migrate incomplete tasks from previous sessions for the same project) - Warn users - indicate that "clear context" will orphan tasks
- Project-scoped tasks - store tasks by project path instead of session ID
- Migrate tasks when clearing context - copy task files to new session directory (updating IDs if needed)
Environment
- Claude Code version: 2.1.16+ (Task feature is new)
- OS: Linux (Ubuntu 20.04)
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗