Skip to content

"Task" PreToolUse hook matcher incorrectly intercepts TaskCreate/TaskUpdate/TaskList todo tools #241

@johnstamly

Description

@johnstamly

Bug Report

Version: v1.0.75

Summary

In hooks/hooks.json, the PreToolUse hook has a matcher "Task". Claude Code hook matchers use substring matching, so this catches all Task* tools — including TaskCreate, TaskUpdate, TaskList, TaskGet, TaskStop, TaskOutput (the todo/task management tools) — not just the intended Task subagent tool.

Reproduction

  1. Use Claude Code with context-mode enabled
  2. Claude attempts to call TaskCreate or TaskUpdate to manage a todo list
  3. The pretooluse.mjs routing logic fires and detects the task field in the input (via ["prompt", "request", ..., "task"] field detection)
  4. The context-mode routing block is appended to the task title/description, corrupting the entry
  5. The hook fails or the task tool receives malformed input → todo list gets stuck, "hook failed" message shown in terminal

Root Cause

routing.mjs line 286:

if (canonical === "Agent" || canonical === "Task") {

This was presumably intended to intercept a Task subagent tool, but in modern Claude Code the subagent spawning tool is called Agent. There is no standalone Task tool — only the Task* family of todo management tools (TaskCreate, TaskUpdate, etc.).

The "Task" substring matcher in hooks.json fires for all of these, and the routing logic then corrupts their inputs.

Fix

Remove the "Task" matcher from PreToolUse in hooks.json. The Agent matcher already covers subagent prompt injection.

- {
-   "matcher": "Task",
-   "hooks": [{ "type": "command", "command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/pretooluse.mjs" }]
- },

Also consider removing the canonical === "Task" branch in routing.mjs line 286 since it is now unreachable.

Workaround

Manually remove the "Task" matcher block from both:

  • hooks/hooks.json
  • .claude-plugin/hooks/hooks.json

in the plugin cache directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions