[BUG] gh pr view polling causes repeated 200-500% CPU spikes when branch has no PR
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code automatically polls gh pr view --json number,url,reviewDecision,isDraft,headRefName,state approximately every 60 seconds. When the current branch has no associated PR, the command fails and appears to retry aggressively, causing CPU spikes of 200-500% per invocation as observed via ps aux --sort=-%cpu.
This was observed on a git repo where the current branch (nvim) has no open PR. Every time we sampled the process list, a new gh pr view process was at the top consuming 200-500% CPU:
USER PID %CPU COMMAND
efreibe+ 145196 500 gh pr view --json number,url,reviewDecision,isDraft,headRefName,state
efreibe+ 142044 250 gh pr view --json number,url,reviewDecision,isDraft,headRefName,state
efreibe+ 139902 200 gh pr view --json number,url,reviewDecision,isDraft,headRefName,state
The parent PID of these processes traces back to the claude process itself. Combined with other background processes, this contributed to sustained CPU package temperatures of 97-103°C on a Dell laptop.
This polling bypasses the permission system (it's not a Bash tool invocation), cannot be disabled via any setting or environment variable, and there is no way to opt out.
What Should Happen?
- The polling should not retry aggressively when
gh pr viewfails (no PR exists for the branch) - There should be a way to disable PR status polling entirely (e.g.,
CLAUDE_CODE_DISABLE_PR_POLLING=1or a/configtoggle) - The polling should respect the permission system or at minimum be documented as an exception
Error Messages/Logs
$ gh pr view --json number,url,state
no pull requests found for branch "nvim"
Steps to Reproduce
- Open a git repository where the current branch has no associated GitHub PR
- Start Claude Code (
claude) - Run
ps aux --sort=-%cpu | head -10repeatedly (e.g., every 30-60 seconds) - Observe
gh pr viewprocesses spawning repeatedly at high CPU usage
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.81 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
This was previously reported in #23580 which was auto-closed as stale without being addressed. That issue contains a detailed analysis by @bborn who reverse-engineered the minified source and found:
- A
/configtoggle (prStatusFooterEnabled) exists but is gated behind a feature flag (tengu_pr_status_cli), making it inaccessible to most users - Two proposed fixes were suggested: making the toggle unconditional, and adding a
CLAUDE_CODE_DISABLE_PR_POLLINGenv var
Neither fix was implemented before the issue was closed.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗