SessionStart hook /dev/tty output races with welcome banner on /clear

Resolved 💬 2 comments Opened Feb 18, 2026 by jdomenech-vf Closed Mar 19, 2026

Problem

When using a SessionStart hook that writes to /dev/tty (e.g. to display a custom welcome message), the output works correctly on a new session startup but races with the welcome banner on /clear, causing interleaved/garbled terminal output.

Use Case

Showing a custom message on session start and /clear with useful tips, common workflows, or command reminders. For example:

#!/bin/bash
cols=$(tput cols 2>/dev/null || echo 48)
line=$(printf '━%.0s' $(seq 1 "$cols"))
msg="${line}
  Common Workflows
${line}

  /resolve-ticket          Resolve a Jira ticket end-to-end
  /brainstorming           Plan before building features
  /commit                  Commit changes

${line}"
printf '%s\n' "$msg" > /dev/tty
exit 0

Current Behavior

  • New session (startup): Hook output renders cleanly above the welcome banner.
  • /clear: Hook output and Claude Code's welcome banner write to the terminal concurrently, producing garbled/interleaved output. Tried various workarounds:
  • Adding sleep delays — partial output shows then gets cut off, welcome banner disappears.
  • Single atomic printf write — still interleaves with the welcome banner.

Expected Behavior

SessionStart hooks with "clear" matcher should be able to write to /dev/tty without racing against the welcome banner, just like they can on startup.

Suggested Solutions

  • Sequence hook execution before rendering the welcome banner on /clear (same as startup behavior).
  • Or provide a dedicated hook event (e.g. PostClear / PostBanner) that fires after the welcome banner has fully rendered.

Environment

  • Claude Code (latest)
  • macOS (Darwin 25.3.0)
  • Terminal: default macOS terminal / iTerm2

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗