Skip to content

SessionStart hook (check-config.sh) exits 1 when no last-run.json → Claude Code flags hook as failed #424

@jonasspezia

Description

@jonasspezia

Summary

The SessionStart hook hooks/scripts/check-config.sh (v3.3.0) exits with status 1 on every session start when there is no recent run, causing Claude Code to display:

SessionStart:startup hookFailed with non-blocking status code: No stderr output

stdout is correct (the "Ready — N sources active" message prints fine); only the exit code is wrong, so it's a cosmetic-but-persistent red error on every new session.

Root cause

The script runs under set -euo pipefail. In the configured branches, the last command executed is:

[[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"

When ~/.config/last30days/last-run.json does not exist (fresh install, or user hasn't run /last30days yet), $LAST_RUN_LINE is empty. [[ -n "" ]] evaluates false, the && list returns exit status 1, and because it's the final command in the script, the whole script exits 1.

The new-user branch is unaffected because it has an explicit exit 0 after the same line. The two configured branches (lines ~164 and ~169, HAS_SCRAPECREATORS set/unset) do not.

Reproduce

# With a configured env and no ~/.config/last30days/last-run.json
echo '{"hook_event_name":"SessionStart","source":"startup"}' \
  | bash hooks/scripts/check-config.sh; echo "exit=$?"
# -> prints the Ready message, exit=1

Suggested fix

Add an explicit exit 0 at the end of the script (the hook is informational — stdout carries the payload, exit status should always be 0). Alternatively, replace the trailing [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE" lines with an if:

if [[ -n "$LAST_RUN_LINE" ]]; then echo "$LAST_RUN_LINE"; fi

Either makes all branches exit 0.

Environment

  • last30days-skill 3.3.0
  • Claude Code CLI v2.1.143, macOS (bash 3.2 /bin/bash)
  • ScrapeCreators configured (9 sources), no last-run.json present

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