claude-code - 💡(How to fix) Fix Plugin-scoped PostToolUse hooks silently skip in Claude Desktop / Agent Mode [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#51904Fetched 2026-04-23 07:41:48
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×4commented ×2cross-referenced ×1

PostToolUse hooks defined in a plugin's hooks/hooks.json fire correctly in Claude Code CLI but silently do not fire in Claude Desktop / Agent Mode sessions, even though:

  • The plugin is installed and up-to-date on both surfaces
  • Skills from the same plugin execute correctly in Desktop
  • MCP servers from the same plugin work in Desktop
  • The hook command executes fine when run manually

Likely the same root cause documented in #27398 (closed as duplicate of #16288): the Cowork VM spawns the CLI with --setting-sources user, which excludes plugin-scope hook discovery.

Error Message

  1. Observe: hook silently does not fire (no script output, no network call, no error logged)

Root Cause

Likely the same root cause documented in #27398 (closed as duplicate of #16288): the Cowork VM spawns the CLI with --setting-sources user, which excludes plugin-scope hook discovery.

Fix Action

Workaround

Placing hooks in ~/.claude/settings.json is not viable for plugin-based distribution - it defeats the admin console's automatic rollout and requires per-user manual setup.

Code Example

my-plugin/
├── .claude-plugin/plugin.json
├── hooks/
│   ├── hooks.json
│   └── log_event.py
└── skills/...

---

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Skill",
        "hooks": [
          {
            "type": "command",
            "command": "python \"${CLAUDE_PLUGIN_ROOT}/hooks/log_event.py\"",
            "timeout": 15,
            "async": true
          }
        ]
      }
    ]
  }
}
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • Searched existing issues
  • Single bug report
  • Using latest version

Summary

PostToolUse hooks defined in a plugin's hooks/hooks.json fire correctly in Claude Code CLI but silently do not fire in Claude Desktop / Agent Mode sessions, even though:

  • The plugin is installed and up-to-date on both surfaces
  • Skills from the same plugin execute correctly in Desktop
  • MCP servers from the same plugin work in Desktop
  • The hook command executes fine when run manually

Likely the same root cause documented in #27398 (closed as duplicate of #16288): the Cowork VM spawns the CLI with --setting-sources user, which excludes plugin-scope hook discovery.

Environment

  • OS: Windows 11
  • Claude Desktop: 1.1.4088
  • Claude Code CLI: 2.1.92
  • Plugin installed via admin console (enterprise distribution, "Installed by default")

Plugin structure

my-plugin/
├── .claude-plugin/plugin.json
├── hooks/
│   ├── hooks.json
│   └── log_event.py
└── skills/...

hooks/hooks.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Skill",
        "hooks": [
          {
            "type": "command",
            "command": "python \"${CLAUDE_PLUGIN_ROOT}/hooks/log_event.py\"",
            "timeout": 15,
            "async": true
          }
        ]
      }
    ]
  }
}

Steps to reproduce

  1. Install a plugin whose hooks/hooks.json defines a PostToolUse matcher on Skill
  2. Open a Claude Desktop → Agent Mode session
  3. Invoke a skill from that plugin
  4. Observe: hook silently does not fire (no script output, no network call, no error logged)
  5. Open Claude Code CLI on the same machine, same user
  6. Invoke the same skill
  7. Observe: hook fires correctly on every invocation

Expected

Plugin-defined hooks/hooks.json hooks should fire on both surfaces, identically to how they behave in CLI.

Actual

  • ✅ CLI: hook fires consistently
  • ❌ Desktop / Agent Mode: hook silently skipped

Evidence

Over a 14-day observation window using an external logging endpoint, the same user on the same Windows laptop produced captured events only from CLI sessions. Multiple Agent Mode invocations during the same window produced zero events. Skills and MCP servers work correctly in both surfaces; only the hook is invisible to Desktop.

Impact

This blocks any plugin-based telemetry, workflow automation, session logging, or side-effect tracking. For organizations distributing plugins via admin console Installed by default, the usable audience for any hook-based feature collapses to CLI power users only - typically a small minority of a broader team deployment.

Related

  • #16288 (canonical, open)
  • #27398 (closed as duplicate; includes cowork_vm_node.log evidence showing --setting-sources user is the spawn flag)
  • #18547 (related, VSCode extension, different root cause)

Workaround

Placing hooks in ~/.claude/settings.json is not viable for plugin-based distribution - it defeats the admin console's automatic rollout and requires per-user manual setup.

Ask

Please prioritize fixing plugin-scope hook discovery in Desktop / Agent Mode. Without this, plugin extensibility in the Desktop app is limited to skills and MCP servers; hooks are effectively unavailable.

extent analysis

TL;DR

The issue can be addressed by modifying the Cowork VM to spawn the CLI without the --setting-sources user flag, allowing plugin-scope hook discovery in Desktop / Agent Mode sessions.

Guidance

  • Investigate the cowork_vm_node.log to confirm the presence of the --setting-sources user flag, as mentioned in #27398.
  • Consider modifying the Cowork VM configuration to remove or override the --setting-sources user flag, enabling plugin-scope hook discovery.
  • Review the plugin structure and hooks/hooks.json file to ensure correct formatting and configuration.
  • Test the hook functionality in both CLI and Desktop / Agent Mode sessions to verify the fix.

Example

No code snippet is provided, as the issue is related to configuration and plugin discovery rather than code implementation.

Notes

The issue is likely related to the --setting-sources user flag, which excludes plugin-scope hook discovery. Modifying the Cowork VM configuration may resolve the issue, but further investigation is needed to confirm the root cause.

Recommendation

Apply a workaround by modifying the Cowork VM configuration to remove or override the --setting-sources user flag, as this is the most likely cause of the issue and has been identified in related issues (#16288 and #27398).

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

claude-code - 💡(How to fix) Fix Plugin-scoped PostToolUse hooks silently skip in Claude Desktop / Agent Mode [2 comments, 2 participants]