---
name: verify-ci
description: Use when you need to confirm CI is green before calling work done, when CI fails and you need to diagnose and fix, when the user says "watch CI", "wait for green", "verify CI", "is CI passing", "check the pipeline", or "fix CI". Also use proactively after pushing changes that need CI validation.
---

# Verify CI

Watch CI runs, capture failures, diagnose, fix, and re-verify — in a loop until green.

## When to Use

- After pushing changes that need CI validation
- User says "watch CI", "wait for green", "check the pipeline"
- You need to verify work is done (CI green = done)
- CI failed and you need to diagnose and fix

## Workflow

```
push → run script → read result → if failed: diagnose → fix → push → repeat
```

### Step 1: Run the watcher script

```bash
# Watch the latest run for a specific workflow
.agents/skills/verify-ci/watch-ci.sh --workflow "E2E Test"

# Watch latest run across all workflows
.agents/skills/verify-ci/watch-ci.sh

# Re-run the latest failed run and watch the new one
.agents/skills/verify-ci/watch-ci.sh --workflow "E2E Test" --rerun
```

The script blocks until the run completes (zero tokens burned while waiting), then writes results to `.opencode/ci-result/`.

### Step 2: Read results

```bash
cat .opencode/ci-result/result.json
```

The `status` field tells you what happened: `success`, `failure`, `cancelled`, or `no_runs`.

### Step 3: If failed, diagnose

Read the failure log — the script already extracted it:

```bash
# Key error lines
grep -E "Error:|FAILED|timeout|assert" .opencode/ci-result/failure.log | head -30
```

Then read the full log if needed (`.opencode/ci-result/failure.log`). Identify the root cause, fix the code, commit, push.

### Step 4: Re-run and watch

After pushing the fix:

```bash
# Re-run only the failed jobs and watch
.agents/skills/verify-ci/watch-ci.sh --workflow "E2E Test" --rerun
```

### Step 5: Repeat until green

Loop steps 2-4 until `result.json` shows `"status": "success"`. Max 3 iterations — if still failing after 3 attempts, stop and ask the user.

## Script Options

Run `.agents/skills/verify-ci/watch-ci.sh --help` for full usage.

| Option | Description |
|---|---|
| `--workflow <name>` | Filter to specific workflow (e.g., "E2E Test", "Unit Test") |
| `--branch <name>` | Override branch (defaults to current) |
| `--run-id <id>` | Watch a specific run by ID |
| `--rerun` | Re-run latest failed run, then watch the new one |
| `--output-dir <dir>` | Output directory (default: `.opencode/ci-result`) |

## Exit Codes

- `0` — CI passed
- `1` — CI failed (results written to output dir)
- `2` — No runs found or error
