This guide explains how to set up task lists that persist across Claude Code sessions for a specific project.
Claude Code's task system stores tasks in ~/.claude/tasks/<task-list-id>/. By default, each session gets a random UUID. To persist tasks across sessions, you set the CLAUDE_CODE_TASK_LIST_ID environment variable to a consistent ID for your project.
-
Install direnv:
brew install direnv
-
Add direnv hook to your shell (add to
~/.zshrc):eval "$(direnv hook zsh)"
-
Restart your terminal or run
source ~/.zshrc
In your project root, create a .envrc file:
export CLAUDE_CODE_TASK_LIST_ID=your-project-slugUse a descriptive slug like pe-value-creation-s2026, startup-app, etc.
mkdir -p ~/.claude/tasks/your-project-slugUse the same slug as in your .envrc file.
From the project directory:
direnv allowStart a new Claude Code session in the project directory. The environment variable will be automatically set.
Ask Claude to create tasks for your project. Example prompts:
- "Let's create a task list for this project"
- "Create tasks for [describe your goals]"
- "Add a task to [specific task]"
- Ask: "What are my tasks?" or "Show the task list"
- Claude will use the
TaskListtool
- "Mark task 3 as complete"
- "Start working on task 5" (sets to in_progress)
- "Add a task to review the syllabus"
- Claude will use
TaskCreate
If you created tasks in a session before setting up persistence, ask Claude:
"Copy the current session's tasks to ~/.claude/tasks/your-project-slug/"
Then set up the .envrc as described above.
- Verify the env var is set:
echo $CLAUDE_CODE_TASK_LIST_ID - Make sure you ran
direnv allow - Restart Claude Code (not just the terminal)
- Check that the hook is in your
.zshrc - Run
source ~/.zshrc - Verify with
direnv status
ls ~/.claude/tasks/$CLAUDE_CODE_TASK_LIST_ID/
cat ~/.claude/tasks/$CLAUDE_CODE_TASK_LIST_ID/1.json- Task IDs are simple integers (1, 2, 3...)
- Each task is stored as a separate JSON file
- Tasks support dependencies via
blocksandblockedByfields - The task system is session-aware but file-based for persistence