Skip to content

fix: silence hook stderr when running outside tmux#64

Open
asturwebs wants to merge 1 commit intosix-ddc:mainfrom
asturwebs:fix/silent-exit-outside-tmux
Open

fix: silence hook stderr when running outside tmux#64
asturwebs wants to merge 1 commit intosix-ddc:mainfrom
asturwebs:fix/silent-exit-outside-tmux

Conversation

@asturwebs
Copy link
Contributor

Summary

  • Fixes spurious "hook error" message on every Claude Code session start when running outside tmux
  • When TMUX_PANE env var is not set, the hook now exits silently instead of logging a WARNING to stderr
  • Claude Code treats any stderr output from hooks as an error, so even a benign warning was displayed to the user

Root Cause

hook.py:193 called logger.warning("TMUX_PANE not set...") which writes to stderr via logging.basicConfig(stream=sys.stderr). Since the hook is designed to run as a SessionStart hook, it fires on every Claude Code session — including those outside tmux where it's not applicable.

Changes

src/ccbot/handlers/hook.py (line 192-194):

  • Removed logger.warning() call
  • Added comment explaining why silent exit is correct behavior

Test plan

  • ruff check passes
  • ruff format --check passes
  • pyright — 0 errors
  • Manual: echo '{"session_id":"...","hook_event_name":"SessionStart","cwd":"/tmp"}' | ccbot hook outside tmux — no stderr output

🤖 Generated with Claude Code

@asturwebs
Copy link
Contributor Author

Note: the 2 failing checks are pre-existing issues on main, not introduced by this PR.

  • check (3.12): ruff format --check fails on bot.py (would reformat 1 file) — this file already needs reformatting on the base branch
  • check (3.13): Cancelled as a dependency of the above
  • claude-review: Internal error in the Claude Code Action, unrelated to this change

This PR's change to hook.py passes both ruff check and ruff format --check cleanly.

When TMUX_PANE is not set (Claude Code session outside tmux), the hook
logged a WARNING to stderr. Claude Code treats any stderr output as a
hook error, showing a spurious error message on every session start.

Replace the warning with a silent return — the hook is simply not
applicable outside tmux.

Co-Authored-By: BytIA <bytia@asturwebs.com>
@asturwebs asturwebs force-pushed the fix/silent-exit-outside-tmux branch from d6ae68f to 7605a5b Compare March 21, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant