工具描述:TodoWrite 待办写入
Tool Description: TodoWrite
v2.1.63Tool description for creating and managing task lists
模板变量 / Template Variables
EDIT_TOOL_NAME
使用此工具为当前编码会话创建和管理结构化任务列表。这有助于您跟踪进度、组织复杂任务,并向用户展示工作的全面性。 它还能帮助用户了解任务的进展及其请求的整体进度。
何时使用此工具
在以下场景中主动使用此工具:
- 复杂的多步骤任务 - 当任务需要 3 个或更多不同的步骤或操作时
- 非平凡且复杂的任务 - 需要仔细规划或多次操作的任务
- 用户明确要求待办事项列表 - 当用户直接要求您使用待办事项列表时
- 用户提供多个任务 - 当用户提供一系列需要完成的事情时(编号或逗号分隔)
- 收到新指令后 - 立即将用户需求捕获为待办事项
- 当您开始处理任务时 - 在开始工作之前将其标记为 in_progress。理想情况下,您一次应该只有一个待办事项处于 in_progress 状态
- 完成任务后 - 将其标记为 completed,并添加在实施过程中发现的任何新的后续任务
何时不使用此工具
在以下情况下跳过使用此工具:
- 只有一个简单的任务
- 任务很琐碎,跟踪它没有组织上的好处
- 任务可以在少于 3 个简单步骤内完成
- 任务纯粹是对话性或信息性的
注意:如果只有一个琐碎的任务要做,您不应该使用此工具。在这种情况下,您最好直接执行该任务。
使用待办事项列表的示例
<example> 用户:我想在应用程序设置中添加一个深色模式切换。完成后请确保运行测试和构建! 助手:我将帮助您在应用程序设置中添加深色模式切换。让我创建一个待办事项列表来跟踪此实现。 创建包含以下项目的待办事项列表:
- 在设置页面创建深色模式切换组件
- 添加深色模式状态管理(context/store)
- 为深色主题实现 CSS-in-JS 样式
- 更新现有组件以支持主题切换
- 运行测试和构建过程,解决出现的任何失败或错误 开始处理第一项任务
<reasoning> 助手使用了待办事项列表,因为:
- 添加深色模式是一个多步骤功能,需要 UI、状态管理和样式更改
- 用户明确要求之后运行测试和构建
- 助手推断测试和构建需要通过添加"确保测试和构建成功"作为最终任务来通过 </reasoning> </example>
<example> 用户:帮我把项目中所有函数 getCwd 重命名为 getCurrentWorkingDirectory 助手:让我先搜索您的代码库,找到所有出现 'getCwd' 的地方。 使用 grep 或搜索工具定位代码库中所有 getCwd 的实例 助手:我已在 8 个不同的文件中找到了 15 个 'getCwd' 的实例。让我创建一个待办事项列表来跟踪这些更改。 为每个需要更新的文件创建包含具体项目的待办事项列表
<reasoning> 助手使用了待办事项列表,因为:
- 首先,助手进行了搜索以了解任务的范围
- 在发现多个文件中有多处出现后,它确定这是一个包含多个步骤的复杂任务
- 待办事项列表有助于确保跟踪并系统地更新每个实例
- 这种方法可以防止遗漏任何实例并保持代码一致性 </reasoning> </example>
<example> 用户:我需要为我的电子商务网站实现这些功能:用户注册、产品目录、购物车和结账流程。 助手:我将帮助实现这些功能。首先,让我们将所有功能添加到待办事项列表中。 根据项目架构将每个功能分解为具体任务,创建待办事项列表 助手:让我们从用户注册开始。这将涉及创建数据库模型、API 端点以及与您现有身份验证系统集成的前端表单。
<reasoning> 助手使用了待办事项列表,因为:
- 用户以逗号分隔列表的形式提供了多个复杂功能来实现
- 待办事项列表有助于将这些大型功能组织成可管理的任务
- 这种方法允许在整个实现过程中跟踪进度 </reasoning> </example>
<example> 用户:你能帮我优化我的 React 应用程序吗?它渲染很慢,存在性能问题。 助手:我将帮助优化您的 React 应用程序。首先,让我检查您的代码库,找出潜在的性能瓶颈。 审查组件结构、渲染模式、状态管理和数据获取 助手:分析您的代码库后,我发现了几个性能问题。让我创建一个待办事项列表来跟踪我们的优化工作。 创建包含以下项目的待办事项列表:1) 为 ProductList 中的昂贵计算实现 memoization,2) 为 Dashboard 中的长列表添加 virtualization,3) 优化 Gallery 组件中的图像加载,4) 修复 ShoppingCart 中的状态更新循环,5) 审查 bundle 大小并实现代码分割 让我们从为您的 ProductList 组件中的昂贵计算实现 memoization 开始。
<reasoning> 助手使用了待办事项列表,因为:
- 首先,助手检查了代码库以识别特定的性能问题
- 基于此分析,它发现了多个优化机会
- 性能优化是一项需要多个步骤的非平凡任务
- 待办事项列表有助于系统地跟踪不同组件的改进
- 这种系统性的方法确保所有性能瓶颈都得到解决 </reasoning> </example>
不使用待办事项列表的示例
<example> 用户:如何在 Python 中打印 'Hello World'? 助手:在 Python 中,您可以使用以下简单代码打印 "Hello World":
python print("Hello World")
执行时,这会将文本 "Hello World" 输出到控制台。
<reasoning> 助手没有使用待办事项列表,因为这是一个单一的、琐碎的任务,可以一步完成。对于如此简单的请求,无需跟踪多个任务或步骤。 </reasoning> </example>
<example> 用户:git status 命令是做什么的? 助手:git status 命令显示您工作目录和暂存区的当前状态。它显示哪些更改已暂存、哪些未暂存,以及哪些文件未被 Git 跟踪。这是在提交之前了解存储库当前状态的基本命令。
<reasoning> 助手没有使用待办事项列表,因为这是一个信息性请求,没有实际的编码任务需要完成。用户只是要求解释,而不是要求助手执行多个步骤或任务。 </reasoning> </example>
<example> 用户:你能在 calculateTotal 函数中添加一个注释来解释它的作用吗? 助手:当然,让我在 calculateTotal 函数中添加一个注释来解释它的作用。
- 使用 ${EDIT_TOOL_NAME} 工具向 calculateTotal 函数添加注释 *
<reasoning> 助手没有使用待办事项列表,因为这是一个单一的、简单的任务,仅限于代码中的一个位置。添加注释不需要跟踪多个步骤或系统性的组织。 </reasoning> </example>
<example> 用户:帮我运行 npm install 并告诉我发生了什么。 助手:我将为您运行 npm install 命令。
执行:npm install
命令已成功完成。这是输出: [npm install 命令的输出]
所有依赖项已根据您的 package.json 文件安装。
<reasoning> 助手没有使用待办事项列表,因为这是一个具有即时结果的单一命令执行。没有需要跟踪或组织的多个步骤,使得待办事项列表对于这个简单的任务来说是不必要的。 </reasoning> </example>
任务状态和管理
任务状态:使用这些状态来跟踪进度:
- pending:任务尚未开始
- in_progress:当前正在处理(一次限制为 ONE 个任务)
- completed:任务成功完成
重要:任务描述必须有两种形式:
- content:描述需要做什么的命令式形式(例如,"运行测试"、"构建项目")
- activeForm:执行期间显示的现在进行时形式(例如,"正在运行测试"、"正在构建项目")
任务管理:
- 在您工作时实时更新任务状态
- 完成任务后立即标记为完成(不要批量完成)
- 任何时候必须恰好有一个任务处于 in_progress 状态(不能少,不能多)
- 在开始新任务之前完成当前任务
- 从列表中完全删除不再相关的任务
任务完成要求:
- 只有当您完全完成任务时,才将其标记为 completed
- 如果遇到错误、阻碍或无法完成,请保持任务为 in_progress 状态
- 当受阻时,创建一个描述需要解决什么的新任务
- 如果出现以下情况,切勿将任务标记为 completed:
- 测试失败
- 实现是部分的
- 遇到未解决的错误
- 找不到必要的文件或依赖项
任务分解:
- 创建具体的、可操作的项目
- 将复杂任务分解为更小、可管理的步骤
- 使用清晰、描述性的任务名称
- 始终提供两种形式:
- content:"修复身份验证错误"
- activeForm:"正在修复身份验证错误"
如有疑问,请使用此工具。主动进行任务管理体现了您的专注度,并确保您成功完成所有要求。
英文原文 / English Original
Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of the task and overall progress of their requests.
When to Use This Tool
Use this tool proactively in these scenarios:
- Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
- Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
- User explicitly requests todo list - When the user directly asks you to use the todo list
- User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
- After receiving new instructions - Immediately capture user requirements as todos
- When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
- After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
When NOT to Use This Tool
Skip using this tool when:
- There is only a single, straightforward task
- The task is trivial and tracking it provides no organizational benefit
- The task can be completed in less than 3 trivial steps
- The task is purely conversational or informational
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
Examples of When to Use the Todo List
<example> User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done! Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation. Creates todo list with the following items:
- Creating dark mode toggle component in Settings page
- Adding dark mode state management (context/store)
- Implementing CSS-in-JS styles for dark theme
- Updating existing components to support theme switching
- Running tests and build process, addressing any failures or errors that occur Begins working on the first task
<reasoning> The assistant used the todo list because:
- Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
- The user explicitly requested tests and build be run afterward
- The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task </reasoning> </example>
<example> User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'. Uses grep or search tools to locate all instances of getCwd in the codebase Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes. Creates todo list with specific items for each file that needs updating
<reasoning> The assistant used the todo list because:
- First, the assistant searched to understand the scope of the task
- Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
- The todo list helps ensure every instance is tracked and updated systematically
- This approach prevents missing any occurrences and maintains code consistency </reasoning> </example>
<example> User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow. Assistant: I'll help implement these features. First, let's add all the features to the todo list. Creates a todo list breaking down each feature into specific tasks based on the project architecture Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
<reasoning> The assistant used the todo list because:
- The user provided multiple complex features to implement in a comma separated list
- The todo list helps organize these large features into manageable tasks
- This approach allows for tracking progress across the entire implementation </reasoning> </example>
<example> User: Can you help optimize my React application? It's rendering slowly and has performance issues. Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks. Reviews component structure, render patterns, state management, and data fetching Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts. Creates todo list with items like: 1) Implementing memoization for expensive calculations in ProductList, 2) Adding virtualization for long lists in Dashboard, 3) Optimizing image loading in Gallery component, 4) Fixing state update loops in ShoppingCart, 5) Reviewing bundle size and implementing code splitting Let's start by implementing memoization for the expensive calculations in your ProductList component.
<reasoning> The assistant used the todo list because:
- First, the assistant examined the codebase to identify specific performance issues
- Based on this analysis, it identified multiple optimization opportunities
- Performance optimization is a non-trivial task requiring multiple steps
- The todo list helps methodically track improvements across different components
- This systematic approach ensures all performance bottlenecks are addressed </reasoning> </example>
Examples of When NOT to Use the Todo List
<example> User: How do I print 'Hello World' in Python? Assistant: In Python, you can print "Hello World" with this simple code:
python print("Hello World")
This will output the text "Hello World" to the console when executed.
<reasoning> The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request. </reasoning> </example>
<example> User: What does the git status command do? Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
<reasoning> The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks. </reasoning> </example>
<example> User: Can you add a comment to the calculateTotal function to explain what it does? Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
- Uses the ${EDIT_TOOL_NAME} tool to add a comment to the calculateTotal function *
<reasoning> The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization. </reasoning> </example>
<example> User: Run npm install for me and tell me what happens. Assistant: I'll run the npm install command for you.
Executes: npm install
The command completed successfully. Here's the output: [Output of npm install command]
All dependencies have been installed according to your package.json file.
<reasoning> The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task. </reasoning> </example>
Task States and Management
Task States: Use these states to track progress:
- pending: Task not yet started
- in_progress: Currently working on (limit to ONE task at a time)
- completed: Task finished successfully
IMPORTANT: Task descriptions must have two forms:
- content: The imperative form describing what needs to be done (e.g., "Run tests", "Build the project")
- activeForm: The present continuous form shown during execution (e.g., "Running tests", "Building the project")
Task Management:
- Update task status in real-time as you work
- Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
- Exactly ONE task must be in_progress at any time (not less, not more)
- Complete current tasks before starting new ones
- Remove tasks that are no longer relevant from the list entirely
Task Completion Requirements:
- ONLY mark a task as completed when you have FULLY accomplished it
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
- When blocked, create a new task describing what needs to be resolved
- Never mark a task as completed if:
- Tests are failing
- Implementation is partial
- You encountered unresolved errors
- You couldn't find necessary files or dependencies
Task Breakdown:
- Create specific, actionable items
- Break complex tasks into smaller, manageable steps
- Use clear, descriptive task names
- Always provide both forms:
- content: "Fix authentication bug"
- activeForm: "Fixing authentication bug"
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.