I have been using Claude Code in loops a lot recently. I would have it implement a solution, then push the PR, and it would go through CI and CD. The problem was, if something failed and I did not check it, I had just wasted a bunch of valuable time.
So I changed how my Claude agent works. Now after it pushes the PR, it keeps running in a loop and periodically checks GitHub to see the status of the PR.
If a check fails, the agent goes back, fixes it, and pushes the changes. Then it keeps checking. It does this in a loop until the PR is green.
If something comes up that it cannot fix, it stops and asks me to investigate instead of spinning forever. That is the escape hatch.
I also tuned the timing. The first couple of stages get checked often so failures surface fast. But the long running stages like SonarQube, Snyk, and the Harness e2e tests get longer gaps between checks, since there is no point polling something that takes a while to finish.
The result has been faster PRs and a lot less babysitting. I spend my time on the next thing instead of refreshing a CI page!