Skip to content

PostToolUse hook missing cwd field - observations not being saved #260

@YuTian9292

Description

@YuTian9292

Environment

  • Claude Code version: 2.0.67 (also tested on 2.0.36)
  • claude-mem version: 7.1.3
  • OS: macOS Darwin 25.1.0
  • Node.js: v25.1.0
  • Bun: 1.3.4

Description

The PostToolUse hook is being triggered, but the cwd field is missing from the input data, causing observations to fail to save. According to Claude Code hooks documentation, the cwd field should be included in all hook inputs.

Error Messages

From ~/.claude-mem/silent.log:

[2025-12-13T07:41:19.402Z] [HAPPY-PATH-ERROR] [save-hook.js:11] Missing cwd in PostToolUse hook input {"session_id":"f51cc89f-5f2a-44e9-8f42-5797f766ee66","tool_name":"Bash"} [2025-12-13T07:41:19.407Z] [HAPPY-PATH-ERROR] [worker-service.cjs:1035] Missing cwd when queueing observation in SessionRoutes {"sessionDbId":16,"tool_name":"Bash"} [2025-12-13T07:41:26.738Z] [HAPPY-PATH-ERROR] [summary-hook.js:15] Missing transcript_path in Stop hook input {"session_id":"f51cc89f-5f2a-44e9-8f42-5797f766ee66"}

Expected Behavior

According to Claude Code documentation, PostToolUse hook should receive:

{
  "session_id": "abc123",
  "transcript_path": "/Users/.../.claude/projects/.../xxx.jsonl",
  "cwd": "/Users/...",
  "permission_mode": "default",
  "hook_event_name": "PostToolUse",
  "tool_name": "Bash",
  "tool_input": {...},
  "tool_response": {...}
}

Actual Behavior

The hook receives data without cwd and transcript_path:

{
"session_id": "f51cc89f-5f2a-44e9-8f42-5797f766ee66",
"tool_name": "Bash"
}

Impact

observations table remains empty (0 records)
user_prompts table works correctly (UserPromptSubmit hook functions properly)
Session summaries also fail due to missing transcript_path
Additional Issue: VSCode Extension
When using Claude Code through the VSCode extension (not CLI), hooks are not triggered at all. The worker log shows no incoming requests from the VSCode session, while CLI sessions do trigger hooks (albeit with missing fields).

Database State

SELECT COUNT() FROM observations; -- 0
SELECT COUNT(
) FROM user_prompts; -- 4 (working)
SELECT COUNT(*) FROM session_summaries; -- 0

Steps to Reproduce

Install claude-mem: /plugin marketplace add thedotmack/claude-mem && /plugin install claude-mem
Start a CLI session with claude or use VSCode extension
Execute any tool (e.g., run a Bash command)
Check ~/.claude-mem/silent.log for "Missing cwd" errors
Verify observations table is empty

Possible Cause

This could be:
A Claude Code bug where cwd is not being passed to plugin hooks
A field name mismatch (Claude Code might use a different field name)
A regression in recent Claude Code versions

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