A Claude Code status line goes blank, or shows a stale git branch while background subagents work: what decides when the statusLine command runs, and how do you fix each?
answer
- events, not a clock
- 300ms debounce, in-flight cancelled
- refreshInterval for idle sessions
- non-zero exit or empty stdout
- trust and claude --debug
basics
~20 sThe statusLine command runs at session start and on events such as a new assistant message, /compact, or a permission-mode change, debounced 300ms. Idle sessions fire none, so set refreshInterval; blank means a non-zero exit, empty stdout or an untrusted folder.
solid answer
~40 sThe command runs when a session starts or resumes, then again when a new assistant message arrives, `/compact` finishes, the permission mode or vim mode changes, the `command` setting changes, or a `refreshInterval` timer elapses. Updates are debounced at 300 ms, and a new trigger cancels a script still running. While a coordinator waits on background subagents, no events fire, so a branch they changed stays stale: set `refreshInterval` to N seconds, minimum `1`. A blank line usually means the script exited non-zero, printed nothing to stdout, or is not executable; the status line also stays blank until you accept the workspace trust dialog, and `disableAllHooks` turns it off. Run `claude --debug` to log the script's stderr, and keep slow `git` calls cached per `session_id`.
go deeper
Recall that the status line updates on events like new messages rather than constantly, and that a script error can leave it blank.
List the triggers, the 300ms debounce and cancellation of an in-flight run, and what refreshInterval adds with its one-second minimum.
Diagnose a blank or stale footer methodically: exit code, stdout, executable bit, workspace trust, disableAllHooks, claude --debug, then fix slow git calls with a session_id-keyed cache.
Weigh refresh frequency against cost on large repositories and shared machines, and decide what a team status line may run given trust and organisation-level restrictions.
## When the command runs A status line is not a clock. Claude Code runs the `statusLine` command **once when a session starts**, including on resume, and then again when: - a new assistant message arrives; - `/compact` finishes; - the permission mode changes; - vim mode toggles; - the `command` in your `statusLine` settings changes; - a `refreshInterval` timer elapses, if you set one; - a rate-limit window or a warm prompt cache in the last JSON it received reaches its reset or expiry time. ## Debounce and cancellation Claude Code **debounces updates at 300 ms**, so a burst of changes produces one run after things settle. A change to the `command` itself skips the debounce and runs at once. If a new update triggers while your script is still running, Claude Code **cancels the in-flight script**. A slow script therefore blocks updates until it completes and may be cancelled repeatedly during a busy turn, which looks like a frozen footer. Edits to the script file need no restart: they appear the next time a trigger re-runs it. ## Why it goes stale while idle The event triggers go quiet when the main session is idle, for example while a coordinator waits on background subagents that are committing and switching branches. Nothing re-runs the command, so the branch shown is whatever it was at the last event. The fix is `refreshInterval`: ```json { "statusLine": { "type": "command", "command": "~/.claude/statusline.sh", "refreshInterval": 5 } } ``` It re-runs the command every N seconds **in addition to** event updates, with a minimum of `1`. Use it when the line shows a clock, elapsed time or anything an outside process changes; leave it unset when nothing time-based or external is shown, because every tick runs your script again. A footer that briefly disappears is not always broken: the status line hides during certain interface interactions, such as the help menu and permission prompts, and comes back afterwards. ## Why it goes blank | Symptom | Likely cause | Fix | |---|---|---| | Blank after an error | Script exited non-zero | Make every path exit 0 and print something | | Blank, script "works" | Output went to stderr, or nothing printed | Print to stdout | | Never appears | Script not executable | `chmod +x` the script | | Blank in one folder | Workspace trust not accepted; the status line runs under the same trust rule as hooks in settings files | Restart and accept the trust dialog | | Blank everywhere | `disableAllHooks` is `true` outside managed settings | Remove it or set it to `false` where it is set | | Blank on Windows with Git Bash | Backslashes in the `command` path consumed as escapes | Write the path with forward slashes | | Shows `--` or empty values | Fields are `null` before the first API response | Use fallbacks such as `// 0` | Two organisation-level cases also exist: managed settings can restrict status lines to a managed value, so a personal one disappears without warning, and `claude --safe-mode` loads no custom status line. ## Diagnosing 1. Run the script by hand with mock JSON piped to stdin and check its exit code. 2. Start `claude --debug`: it logs the script's stderr on every invocation and its exit code on the first invocation in a session. An untrusted folder logs `Status line command skipped: workspace trust not accepted`. 3. Check which settings file sets `statusLine` and `disableAllHooks` after precedence. ## Keeping it fast Because the script runs often, `git status` or `git diff` in a large repository can lag every update. Cache the git output in a temp file refreshed every few seconds, and key the file by `session_id` from the JSON: it is stable for the session and unique across sessions. A process ID such as `$$` changes on every invocation and defeats the cache.
- Why key a status-line git cache file by session_id rather than by $$?Each status-line run is a new process, so `$$` changes on every invocation and the cache is never hit. `session_id` from the stdin JSON is stable for the whole session and unique per session, so concurrent sessions in different repositories do not read each other's cached git state.
- You edit the status-line script and the footer does not change. Do you need to restart Claude Code?No. Script edits appear the next time an update trigger re-runs it, such as the next assistant message or a `refreshInterval` tick. Changing the `command` value in settings is different: settings reload on save and the new command runs right away, skipping the 300 ms debounce.
- The status line is blank only in a newly cloned repository. What is the likely cause?Workspace trust. Because `statusLine` executes a shell command, Claude Code runs it under the same trust rule as hooks in settings files, and until the folder is trusted the status line stays blank. `claude --debug` logs `Status line command skipped: workspace trust not accepted`. Restart and accept the trust dialog.
- The status line re-runs on a one-second timer by default.
- A slow script always finishes before the next update runs.
- refreshInterval accepts fractions of a second for smoother clocks.
- A non-zero exit still shows whatever the script printed.
- Script edits need a Claude Code restart to show up.
- A process ID like $$ makes a good cache key for git output.