claude-code - 💡(How to fix) Fix Hook errors for PreToolUse:Agent / PostToolUse:Agent surface cryptic "command not found" output [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#50839Fetched 2026-04-20 12:11:37
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2closed ×1

When a project-level hook is configured for the (formerly) Task tool with a command that is not resolvable on PATH, Claude Code surfaces two repeating entries per agent call:

⎿  PreToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found
⎿  PostToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found

There are a couple of things that make this worse than it needs to be:

  1. The hook matcher in settings is "Task" (matching Claude Code's documented tool name), but the error header reports the tool as Agent. This mismatch between the configured matcher and the reported tool name makes it non-obvious which hook entry is failing and which tool triggered it.
  2. The error is labelled "non-blocking status code", but each failing invocation still prints a multi-line error block in the transcript for every single Agent call, which is visually noisy and gives little actionable information (no hook index, no matcher, no command string).

Error Message

⎿ PreToolUse:Agent hook error ⎿ PostToolUse:Agent hook error

  1. The hook matcher in settings is "Task" (matching Claude Code's documented tool name), but the error header reports the tool as Agent. This mismatch between the configured matcher and the reported tool name makes it non-obvious which hook entry is failing and which tool triggered it.
  2. The error is labelled "non-blocking status code", but each failing invocation still prints a multi-line error block in the transcript for every single Agent call, which is visually noisy and gives little actionable information (no hook index, no matcher, no command string). With entire not installed / not on the hook process's PATH, any use of the agent tool produces the error shown above.
  • The hook error output includes the failing hook's matcher and the resolved command string, so the user can identify which hook to fix, or
  • The tool-name label in the error header uses the same identifier (Task vs Agent) that users are expected to put in matcher, so the config and the diagnostic stay in sync, or

Root Cause

When a project-level hook is configured for the (formerly) Task tool with a command that is not resolvable on PATH, Claude Code surfaces two repeating entries per agent call:

⎿  PreToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found
⎿  PostToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found

There are a couple of things that make this worse than it needs to be:

  1. The hook matcher in settings is "Task" (matching Claude Code's documented tool name), but the error header reports the tool as Agent. This mismatch between the configured matcher and the reported tool name makes it non-obvious which hook entry is failing and which tool triggered it.
  2. The error is labelled "non-blocking status code", but each failing invocation still prints a multi-line error block in the transcript for every single Agent call, which is visually noisy and gives little actionable information (no hook index, no matcher, no command string).

Code Example

PreToolUse:Agent hook error
Failed with non-blocking status code:
      /bin/sh: entire: command not found
PostToolUse:Agent hook error
Failed with non-blocking status code:
      /bin/sh: entire: command not found

---

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Task",
        "hooks": [
          { "type": "command", "command": "entire hooks claude-code pre-task" }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Task",
        "hooks": [
          { "type": "command", "command": "entire hooks claude-code post-task" }
        ]
      }
    ]
  }
}
RAW_BUFFERClick to expand / collapse

Summary

When a project-level hook is configured for the (formerly) Task tool with a command that is not resolvable on PATH, Claude Code surfaces two repeating entries per agent call:

⎿  PreToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found
⎿  PostToolUse:Agent hook error
⎿  Failed with non-blocking status code:
      /bin/sh: entire: command not found

There are a couple of things that make this worse than it needs to be:

  1. The hook matcher in settings is "Task" (matching Claude Code's documented tool name), but the error header reports the tool as Agent. This mismatch between the configured matcher and the reported tool name makes it non-obvious which hook entry is failing and which tool triggered it.
  2. The error is labelled "non-blocking status code", but each failing invocation still prints a multi-line error block in the transcript for every single Agent call, which is visually noisy and gives little actionable information (no hook index, no matcher, no command string).

Repro

.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Task",
        "hooks": [
          { "type": "command", "command": "entire hooks claude-code pre-task" }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Task",
        "hooks": [
          { "type": "command", "command": "entire hooks claude-code post-task" }
        ]
      }
    ]
  }
}

With entire not installed / not on the hook process's PATH, any use of the agent tool produces the error shown above.

Expected

Either:

  • The hook error output includes the failing hook's matcher and the resolved command string, so the user can identify which hook to fix, or
  • The tool-name label in the error header uses the same identifier (Task vs Agent) that users are expected to put in matcher, so the config and the diagnostic stay in sync, or
  • Non-blocking hook failures are coalesced into a single warning per session rather than being repeated on every invocation.

Environment

  • Claude Code CLI (Opus 4.7, 1M context)
  • macOS (Darwin 25.2.0)
  • Non-login /bin/sh shell is used for hook execution, which does not source ~/.zshrc — tools installed only under a user-customized PATH (e.g. ~/.local/bin, asdf, homebrew cellar) will not be found even when the same command runs fine in the interactive shell.

extent analysis

TL;DR

Update the matcher in the hook settings to match the actual tool name reported in the error header, which is Agent, or ensure the command is resolvable on the PATH used by the hook execution environment.

Guidance

  • Verify that the command entire is installed and available on the PATH of the non-login /bin/sh shell used for hook execution.
  • Consider modifying the matcher in the hook settings to use the tool name Agent instead of Task to match the error header.
  • To reduce visual noise, explore options for coalescing non-blocking hook failures into a single warning per session, such as modifying the hook execution script or the Claude Code CLI configuration.
  • Ensure that the environment variables and PATH settings are correctly configured for the hook execution environment, which may differ from the interactive shell environment.

Example

No code snippet is provided as the issue is more related to configuration and environment setup.

Notes

The issue seems to be related to the mismatch between the configured matcher and the actual tool name reported in the error header, as well as the command not being resolvable on the PATH. The solution may involve updating the matcher or ensuring the command is available on the PATH.

Recommendation

Apply workaround: Update the matcher to match the actual tool name Agent or ensure the command is resolvable on the PATH, as this seems to be the most straightforward way to address the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING