BrainBank
AI Classroom/SkillClaude Code Deep Dive

**TodoWriteTool: To-Do List**

8/2/2026, 2:50:28 PM · Source

AI-translated on 8/2/2026, 2:51:24 PM · by Qwen3.6 35B (fast, default)

#state-management#skill#todo#task-management#claudes-code

`TodoWriteTool` est un outil de gestion de tâches léger dans Claude Code qui suit explicitement les travaux au niveau de la session via des mises à jour de l'AppState, nettoie automatiquement les tâches terminées et déclenche des invites de vérification pour les flux de travail complexes.

It's not an ordinary checklist, but making in-session tasks explicit

TodoWriteTool is Claude Code's classic lightweight task management tool.
Its purpose isn't to replace a formal task system, but to allow the model to break down work into a visible sequence of todos within the current session.

You can think of it as:

  • TodoWriteTool: Lightweight, in-session, quick tracking
  • TaskCreateTool series: Structured, formal task system

Key Source Code

tools/TodoWriteTool/TodoWriteTool.ts:

const inputSchema = z.strictObject({
  todos: TodoListSchema().describe('The updated todo list'),
})

The actual state write-back is:

context.setAppState(prev => ({
  ...prev,
  todos: {
    ...prev.todos,
    [todoKey]: newTodos,
  },
}))

This shows that it's essentially an AppState writing tool.

Call Chain

Model splits current work > TodoWriteTool > Updates AppState.todos > UI displays checklist > Model proceeds to next step according to the list

Implementation Highlights

It has two interesting design features:

  1. When all todos are completed, the list is directly cleared
  2. If finishing a complex task with more than 3 items and containing no verification step, it prompts to generate a verification nudge

This part of the source code is crucial:

if (
  allDone &&
  todos.length >= 3 &&
  !todos.some(t => /verif/i.test(t.content))
) {
  verificationNudgeNeeded = true
}

This shows it doesn't just "write lists," but also pushes for more rigorous verification when wrapping up a task.

A Typical Usage Path

  1. The user provides a medium-complexity task
  2. The model first writes 3-5 todos
  3. After completing each item, the state is updated
  4. When closing the final item, if no verification is present, it's reminded to add one

Its Relationship with Adjacent Tools

TodoWriteTool > Lightweight in-session task tracking

TaskCreate/Update/List > Formal task system

Summary

The value of TodoWriteTool is:

Make the model's current plan explicit at minimum cost, and integrate process constraints like "clear the list when done, don't forget verification for complex tasks" into the session state.

Learning map

Application Ability Cultivation

  • Foundation Level: Understand the core concept of task decomposition, master practical approaches for lightweight tracking and session state management
  • Intermediate Level: Use TodoWriteTool to implement dynamic task view construction and state management logic
  • Advanced Level: Integrate todo tools into complex workflows and adopt systematic thinking for adding verification mechanisms at critical checkpoints

Get hands-on — step by step

  1. Environment preparation: Ensure Claude Code is deployed and has a development environment ready.
  2. Create TodoWriteTool instance:
    import { TodoWriteTool } from 'claudes-code/tools';
    const todoTool = new TodoWriteTool();
    
  3. Task creation and maintenance:
    • Call todoTool.addTask('Implement UI')
    • After completing each item, call todoTool.complete('UI Task')
  4. Completion verification prompt settings:
    • Modify the configuration so the tool does not automatically clean up when completing 5+ tasks
    • Add custom validation conditions
  5. Verification flow testing: Execute a complete task flow and observe when todos disappear and verification prompts are triggered

Top 3 sources

  1. 1
    Claude Code 官方工具文档

    包含TodoWriteTool实现细节和应用场景的完整指引

    https://docs.anthropic.com/claude/latest

  2. 2
    Zod 输入验证库指南

    了解工具如何通过类型安全架构处理任务数据输入

    https://zod.dev/

  3. 3
    状态管理最佳实践

    学习 AppState 的设计原理与实际应用案例

    https://react.dev/docs/state

Links are AI-suggested — worth a quick sanity check before diving in.