[BUG] SDK (TypeScript at least) fails to invoke hooks
Resolved 💬 10 comments Opened Aug 21, 2025 by ivawzh Closed Jan 10, 2026
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: <!-- specify -->
- Claude SDK version: 1.0.86
- Claude CLI version: 1.0.86
- Operating System: WSL Ubuntu 22.04
- Terminal: Warp
Bug Description
Hi team.
I am trying to use TypeScript Claude Code SDK to invoke hooks. I am following all the type guides. But none of the event works.
#
Steps to Reproduce
Run $ bun reproduce.ts
// this is reproduce.ts
import { query } from "@anthropic-ai/claude-code";
for await (const message of query({
prompt: "Just say 'Hello, world!'",
options: {
hooks: {
SessionStart: [
{
matcher: '*',
hooks: [
async (input, toolUseID, options) => {
console.log(
"[Claude Code] SessionStart hook called. ",
input.hook_event_name,
input.session_id,
input.transcript_path,
);
return { continue: false };
},
],
},
],
},
},
})) {
console.log(message);
}
Expected Behavior
Showing log "[Claude Code] SessionStart hook called. "
Actual Behavior
"[Claude Code] SessionStart hook called. " is never shown.
Additional Context
Logs I received are the normal messages:
{
type: "system",
subtype: "init",
cwd: "...",
session_id: "4e1ff81d-5864-4767-bd9b-f0aa20fb4fe3",
tools: [
"Task", "Bash", "Glob", "Grep", "LS", "ExitPlanMode", "Read", "Edit", "MultiEdit", "Write", "NotebookEdit",
"WebFetch", "TodoWrite", "WebSearch", "BashOutput", "KillBash"
],
mcp_servers: [],
model: "claude-sonnet-4-20250514",
permissionMode: "default",
slash_commands: [
"add-dir", "agents", "clear", "compact", "config", "context", "cost", "doctor", "exit", "help", "ide",
"init", "install-github-app", "mcp", "memory", "migrate-installer", "model", "output-style",
"output-style:new", "pr-comments", "release-notes", "resume", "status", "statusline", "bug",
"review", "security-review", "upgrade", "vim", "permissions", "hooks", "export", "logout", "login",
"bashes"
],
apiKeySource: "none",
output_style: "default",
uuid: "a2b78952-f535-4a35-85d2-c618453f78e8",
}
{
type: "assistant",
message: {
id: "msg_01VVxKBGYgi6fH3qPJRVN54b",
type: "message",
role: "assistant",
model: "claude-sonnet-4-20250514",
content: [
[Object ...]
],
stop_reason: null,
stop_sequence: null,
usage: {
input_tokens: 4,
cache_creation_input_tokens: 4064,
cache_read_input_tokens: 11326,
cache_creation: [Object ...],
output_tokens: 7,
service_tier: "standard",
},
},
parent_tool_use_id: null,
session_id: "4e1ff81d-5864-4767-bd9b-f0aa20fb4fe3",
uuid: "2fabf843-7681-432d-96b6-735e700c5921",
}
{
type: "result",
subtype: "success",
is_error: false,
duration_ms: 1927,
duration_api_ms: 1772,
num_turns: 1,
result: "Hello, world!",
session_id: "4e1ff81d-5864-4767-bd9b-f0aa20fb4fe3",
total_cost_usd: 0.0375096,
usage: {
input_tokens: 8,
cache_creation_input_tokens: 8128,
cache_read_input_tokens: 22652,
output_tokens: 14,
server_tool_use: {
web_search_requests: 0,
},
service_tier: "standard",
},
permission_denials: [],
uuid: "691e7c18-4423-4799-93c3-d375fd099852",
}This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗