[BUG] Task list (TaskCreate/TaskList) not restored on --resume/--continue — task-list id resolves to a new runtime id
Environment
- Claude Code version: 2.1.207
- Platform: macOS (darwin 25.4.0), zsh
- Task system: the current
TaskCreate/TaskList/TaskUpdatetools (not the deprecatedTodoWrite)
Bug description
Tasks created with TaskCreate are not restored when a session is resumed with claude --resume or claude --continue. After resume, TaskList returns an empty list and task numbering restarts from #1, even though the original task files are still present on disk.
Steps to reproduce
- Start a session, have Claude create a task via
TaskCreate("Test task"). - Observe it persisted on disk:
~/.claude/tasks/session-<8-hex>/1.json. - Exit the session.
claude --resume <that-session>(orclaude --continue).- Ask for the task list.
Expected: the task list from the resumed session is visible ("Test task" present).
Actual: the task list is empty; a newly created task lands in a different directory and gets id #1 again.
Diagnosis
Task lists are stored per list-id under ~/.claude/tasks/<list-id>/N.json. On resume, the conversation transcript correctly continues in the same ~/.claude/projects/<project>/<session-id>.jsonl, but the task-list id resolves to a new runtime id, so the session gets a fresh empty directory:
- Original session
9201ae0c-…wrote tasks to~/.claude/tasks/session-9201ae0c/. - After
--resume, the same conversation wrote new tasks to~/.claude/tasks/session-92efd67b/(verified by creating a marker task and checking which directory received it). - The old directory with the original tasks remains on disk, orphaned.
From the minified binary (2.1.207), the list id is resolved roughly as: CLAUDE_CODE_TASK_LIST_ID env var → team name → runtime session id. The env var works as a stable, shareable list id (verified: launching with CLAUDE_CODE_TASK_LIST_ID=test-list routes new tasks to ~/.claude/tasks/test-list/), but it is undocumented; the default session-derived fallback is what breaks resume continuity.
Expected behavior
Resuming a session should reattach the task list the session was using before exit (the harness even nudges the model about "existing tasks", which makes the silent reset more confusing). Alternatively/additionally, documenting CLAUDE_CODE_TASK_LIST_ID would give users a supported way to keep a task list across sessions.