claude-code - 💡(How to fix) Fix Cowork: Support Claude Code hooks (~/.claude/settings.json — UserPromptSubmit, Stop, etc.)

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…
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Claude Code supports lifecycle hooks configured in ~/.claude/settings.json (UserPromptSubmit, Stop, PreToolUse, PostToolUse, etc.). Cowork is built on Claude Code, but does not fire these hooks.

Verified May 28, 2026: two hooks configured in ~/.claude/settings.json with scripts installed at ~/.claude/hooks/ —

  • UserPromptSubmit → inject-datetime.sh (adds a "Current date/time:" line to each prompt's context)
  • Stop → record-session-event.sh (logs a timestamped row after each assistant turn)

In a fresh Cowork chat after a full quit-and-restart:

  1. UserPromptSubmit did not fire — the assistant got the date from Cowork's own <env> block, not from the injected line. Confirmed across two fresh chats. The script itself works: run directly in Terminal it emits correct JSON. So Cowork just never triggers it.
  2. Stop did not fire — no log file was ever written.
  3. There is no /hooks command in Cowork — typing /hooks returns "Unknown skill: hooks". Cowork treats a leading slash as a skill invocation and has no concept of Claude Code's command set, so hooks can't be inspected or reloaded from a chat either.

Proposed Solution

Honour the Claude Code hooks lifecycle in Cowork, at minimum UserPromptSubmit and Stop (ideally PreToolUse/PostToolUse too). Read ~/.claude/settings.json and fire the configured commands at the corresponding lifecycle points.

Open question for Anthropic to resolve: Cowork sessions run in a Linux sandbox while the hooks config and scripts live on the host Mac. It's unclear whether hooks should fire host-side (where settings.json lives) or inside the sandbox. Host-side is likely most useful, since that's where the config and scripts already are — and it parallels how Cowork's first-party Word/PowerPoint connectors already bridge to the host.

Bonus: expose a way to inspect configured hooks from within Cowork (the equivalent of Claude Code's /hooks command).

Alternative Solutions

  • Use Claude Code CLI on the Mac for any workflow needing hooks — works natively, but terminal-only and breaks the Cowork-chat workflow.
  • For session-duration tracking specifically: have the assistant log a start timestamp when each chat opens and an end timestamp when the chat is wrapped up. Wall-time only, no active-vs-wait split, and only captures chats that are explicitly closed out.
  • Use the session_info MCP for chat count and topic listing — but it has no timestamps, so no duration data.

Priority

Medium - Would be very helpful

Feature Category

Other

Use Case Example

Scenario — per-chat session-duration tracking:

  1. A Stop hook fires after every assistant turn and logs "timestamp | session_id | stop" to a file in the Cowork workspace.
  2. A UserPromptSubmit hook injects the current date/time into each user message.
  3. A daily aggregator reads both signals and computes, per chat: wall time, active time (sum of conversational bursts), and wait time (idle gaps).
  4. This distinguishes a chat worked on steadily for 20 minutes from one that sat open for 6 hours before being closed out.

Today none of this is possible in Cowork — neither hook fires, so the only signals available are coarse (session count and topic from the session_info MCP, with no timestamps).

Additional Context

Verified May 28, 2026 on macOS with Cowork desktop app:

  • inject-datetime.sh run directly in Terminal: emits correct JSON. Script is sound.
  • Same hook in a fresh Cowork chat: did not fire (date came from <env> block instead).
  • /hooks in a Cowork chat: "Unknown skill: hooks".
  • Cowork session sandbox: Linux 6.8.0-106-generic, aarch64, Ubuntu.

Related issues:

  • #60651 — Cowork host-Mac AppleScript bridge FR (same root: Cowork Linux sandbox lacks host integration)
  • #40495 — Confirms Cowork sandbox is Linux/aarch64, not host macOS
  • #48909 — Custom stdio MCP support in Cowork (related host-integration gap)

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