Skip to content

Monitor CI status on clayde-opened PRs and self-fix failing pipelines #86

@ClaydeCode

Description

@ClaydeCode

Problem

When clayde opens a PR and the GitHub Actions pipeline fails, clayde currently does nothing — it only reacts to human review comments. A failing CI is effectively a blocking review signal that should be handled autonomously.

Desired behaviour

During the pr_open phase, in addition to checking for PR reviews, clayde should:

  1. Fetch the CI status for the PR's head commit (GitHub Checks API)
  2. If any required check has failed and clayde has not yet attempted a fix for that run:
    • Invoke Claude with the failing job logs + current branch state
    • Claude analyzes the failure, pushes a fix commit to the branch
    • Clayde posts an issue comment summarising what failed and what was changed
  3. Re-check on the next cycle — if CI is still failing after a fix attempt, retry (up to a configurable max, e.g. 3 attempts per PR)
  4. If CI is green (or no required checks exist), continue existing review-monitoring logic unchanged

Implementation notes

  • New helper in github.py: get_check_runs(g, owner, repo, ref) — wraps the Checks API to return failed check runs for a given commit SHA
  • New Jinja2 prompt template fix_ci.j2 — includes: issue context, PR branch, list of failed checks with their log URLs, instruction to fetch logs via gh run view --log-failed and push a fix
  • State: track last_ci_fix_attempt_sha in issue state — only attempt a fix once per head SHA to avoid infinite loops on unfixable failures
  • Max attempts: ci_fix_max_attempts setting (default 3), tracked as ci_fix_attempts in state; stop attempting and notify operator if exceeded
  • Notification: ntfy alert when max attempts exceeded ("Clayde: CI still failing after N attempts")
  • Scope: only act on required checks (same checks that block merging), ignore informational ones

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions