[FEATURE] Add persistent Mode for statusline commands
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
From the the Claude CLI statusline documentation:
- The status line is updated when the conversation messages update
- Updates run at most every 300ms
- The first line of stdout from your command becomes the status line text
This is a good approach for very efficient statusline implementations, i.e. the example commands in the documentation above which all run in the span of tens of milliseconds on a modern system.
Still, several community implementations are somewhat feature-heavy and provide very useful extra information such as cost and advanced usage metrics, while at the same time relying on interpreters (i.e. Node.js). Executing those implementations every 300ms can seriously impact resources (i.e. CPU, battery).
One might opine that users should select an efficient statusline implementation, but it is probably wiser to allow the community to develop persistent statusline applications, thus aiding the users who might not be fully aware of the resource consumption of the different implementations.
See the benchmarks in the Additional Content section.
Proposed Solution
- The current statusline implementation should be kept for backwards compatibility
- A new flag
persistentcan control if the statusline command has to be considered persistent; default tofalsefor backwards compatibility - If persistent, Claude CLI spawns the process and feeds multiple JSON status line via stdout/stdin
- The statusline process can be monitored via PID/waitpid() for early termination; EOF on write could be also monitored
- I am unsure how Claude CLI handles processes right now, but this implementation should not be riskier than the current one in case the spawned process exits early
Example of the persistent flag:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline_persistent.sh",
"padding": 0,
"persistent": true
}
}
Alternative Solutions
_No response_
Priority
Low - Nice to have
Feature Category
CLI commands and flags
Use Case Example
I raise this issue because I received some reports of claude CLI being very resource intensive, for then discovering that the issue was running npx/bunx applications as the statusline command.
Additional Context
In the effort of developing an efficient statusline for Claude, I did benchmark the examples on the Claude documentation and some reference community implementations in terms of startup time, cycles and memory usage.
The benchmarks are available here.
Please keep in mind these benchmarks express how it "works on my machine" and in the case of the 3rd party tools ccusage and ccstatusline I did not use a standard $CLAUDE_CONFIG_DIR so to make the results repetible; see here for more details.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗