Set a delay and Claude Code will shut itself down after sitting idle that long.
What's wrong with this entry?
Set CLAUDE_CODE_EXIT_AFTER_STOP_DELAY to a positive value and Claude Code will now shut itself down once the session has sat idle for that whole window. With the variable unset or non-positive the watchdog never starts, so behaviour is unchanged.
- The timer restarts itself after each check rather than firing once, so a session that becomes busy again resets the window.
- If the idleness check itself throws, the chain stops and the error is logged instead of taking the process down.
CLAUDE_CODE_EXIT_AFTER_STOP_DELAY=300000 claudeExiting after
Strings lifted out of the shipped bundle, so the claim above can be checked against them.