Skip to content

SessionStart + PostToolUse hooks emit non-blocking stderr on fresh checkout: redirect target .remember/logs/hook-errors.log doesn't exist yet #27

Closed

Description

@vizionik25

Summary

The SessionStart and PostToolUse hook commands in hooks/hooks.json redirect stderr to ${CLAUDE_PROJECT_DIR:-.}/.remember/logs/hook-errors.log using 2>>. On the first session in a fresh checkout (or any time .remember/ has been cleaned up), that path does not exist yet — the script that creates it (session-start-hook.sh, lines 57–59) hasn't run. The shell opens redirection before invoking the command, so it fails with:

/bin/sh: <project>/.remember/logs/hook-errors.log: No such file or directory

Claude Code surfaces this as a hook_non_blocking_error on SessionStart:startup and every PostToolUse firing until the directory finally exists. The inner script still runs and eventually creates the directory, so it's cosmetic — but it spams the user with repeated hook errors on first use.

Repro

  1. Fresh project dir with no .remember/.
  2. Open Claude Code session in that dir with the plugin enabled.
  3. Observe hook_non_blocking_error entries in the transcript for SessionStart:startup, PostToolUse:Read, PostToolUse:Bash, etc.

Suggested fix

Pre-create the log dir in the hook command itself so the redirect target is guaranteed to exist before `2>>` evaluates, e.g.:

```
mkdir -p "${CLAUDE_PROJECT_DIR:-.}/.remember/logs" && \
bash "${CLAUDE_PLUGIN_ROOT}/scripts/session-start-hook.sh" \
2>> "${CLAUDE_PROJECT_DIR:-.}/.remember/logs/hook-errors.log"
```

Same treatment on the PostToolUse entry.

Env

  • Claude Code 2.1.118
  • macOS (Darwin 25.4.0), zsh/bash
  • Plugin: remember@claude-plugins-official v0.5.0

Activity

  1. leo-artuai commented on Apr 23, 2026

    @leo-artuai

    +1, same failure mode as #23 — the stderr redirect target is opened by the shell before the plugin's own mkdir -p ever runs.

    Repro: Claude Code 2.1.118 / macOS Darwin 25.2, multiple git worktrees in parallel. The proposed mkdir -p "${CLAUDE_PROJECT_DIR:-.}/.remember/logs" && bash ... in both issues is the cleanest fix.

    For anyone looking for a workaround before this merges, I left a user-level SessionStart hook recipe in #23 that pre-creates the directory globally — applies to all worktrees without patching the plugin.

  2. fdaviddpt commented on Apr 25, 2026

    @fdaviddpt
    Contributor

    Fixed in #33 — bootstrap-dirs.sh now creates the .remember/logs/ directory before any stderr redirect. hooks.json no longer contains inline 2>> redirects.

    Thank you @vizionik25 for reporting this! With 20k installs, every fresh-project bug report helps us catch what our own testing missed. The fix includes 17 tests covering fresh projects, partial state, git worktrees, read-only filesystems, and more — so this class of bug shouldn't come back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions