Agent loops endlessly watching CI checks on already-merged PRs

Resolved 💬 3 comments Opened Jan 11, 2026 by firascoding Closed Feb 24, 2026

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?

When Claude creates a PR and the user merges it manually (outside of Claude's session), Claude does not detect the PR has been merged. It enters an endless loop watching CI checks, spawns multiple subagent tasks, and requires manual interruption to stop.

---
To Reproduce

  1. Ask Claude to make changes and create a PR (e.g., PR #237)
  2. Merge the PR manually via GitHub UI while Claude is working or between sessions
  3. Return to Claude or let it continue
  4. Observe Claude repeatedly running gh pr checks <number> --watch

---
Expected behavior

---

---
Environment

  • Claude Code version: 2.1.4
  • OS: Ubuntu 24.04.3 LTS
  • Shell: bash
  • Terminal: SSH session

What Should Happen?

Claude should check PR state first (gh pr view <number> --json state), detect MERGED, and report "PR was already merged" instead of watching checks.

Error Messages/Logs

Steps to Reproduce

  1. Ask Claude to make changes and create a PR (e.g., PR #237)
  2. Merge the PR manually via GitHub UI while Claude is working or between sessions
  3. Return to Claude or let it continue
  4. Observe Claude repeatedly running gh pr checks <number> --watch

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Claude Code version: 2.1.4

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Terminal.app (macOS)

Additional Information

● Bash(gh pr checks 237 --watch) timeout: 5m 0s
● Bash(gh pr checks 237 --watch) timeout: 5m 0s
[repeated 10+ times, then interrupted]

● Bash(gh pr checks 237)
⎿ Error: Exit code 8
[all checks show "pass" - PR was merged]

● CI still running. Let me wait a bit more and check again.
● Bash(sleep 30 && gh pr checks 237)
● Bash(sleep 60 && gh pr checks 237)

● Task "Commit rate limiting changes" killed
● Task "Commit rate limit recording fix" killed
[multiple spawned tasks killed]

View original on GitHub ↗

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