watch-ci

CI を監視し、失敗したら自律的に修正してパスするまでループするスキル。push 後・PR 作成後・rebase 後に CI が通るか確認したいとき、CI が落ちていたら直してほしいとき、CI の結果を待ちたいときに使う。「CI 監視して」「CI が通るまで待って」「CI 直して」「push したので CI を見ておいて」など、CI の状態確認・自動修正が必要な場面では必ずこのスキルを呼び出すこと。

15 stars

Best use case

watch-ci is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

CI を監視し、失敗したら自律的に修正してパスするまでループするスキル。push 後・PR 作成後・rebase 後に CI が通るか確認したいとき、CI が落ちていたら直してほしいとき、CI の結果を待ちたいときに使う。「CI 監視して」「CI が通るまで待って」「CI 直して」「push したので CI を見ておいて」など、CI の状態確認・自動修正が必要な場面では必ずこのスキルを呼び出すこと。

Teams using watch-ci should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/watch-ci/SKILL.md --create-dirs "https://raw.githubusercontent.com/sushichan044/dotfiles/main/.agents/skills/watch-ci/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/watch-ci/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How watch-ci Compares

Feature / Agentwatch-ciStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

CI を監視し、失敗したら自律的に修正してパスするまでループするスキル。push 後・PR 作成後・rebase 後に CI が通るか確認したいとき、CI が落ちていたら直してほしいとき、CI の結果を待ちたいときに使う。「CI 監視して」「CI が通るまで待って」「CI 直して」「push したので CI を見ておいて」など、CI の状態確認・自動修正が必要な場面では必ずこのスキルを呼び出すこと。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# watch-ci

push または PR 作成後の CI を監視し、失敗したら re-run を試みてから原因をトリアージし、適切なスキルで修正してパスするまでループする。

## Procedure

### 1. コンテキスト確認

```bash
git branch --show-current
gh pr view --json number,url,headRefName 2>/dev/null
```

### 2. PR チェック一覧を取得して失敗を検出

**PR が存在する場合**: `gh run list` ではなく `gh pr checks` を使うこと。
`gh run list --limit 1` はブランチ上の最後に起動した run しか見ないため、
複数 workflow が走るリポジトリでは失敗した run を見逃す原因になる。

```bash
# PR に紐づく全チェックの状態を取得
gh pr checks --json name,status,conclusion,link 2>/dev/null
```

判定:

- `conclusion=failure` のチェックが 1 件でもある → 失敗。リンクから run ID を取得して Step 3 へ。
- 全件が `success` / `skipped` / `neutral` → 成功。完了レポートを出して終了。
- `status=in_progress` / `queued` が残っている → 待機してリトライ。

**PR が存在しない場合**: 直近 5 件の run を確認する。

```bash
gh run list --branch "$(git branch --show-current)" --limit 5 \
  --json databaseId,status,conclusion,url,workflowName
```

いずれも run が存在しない場合(push 直後)は 5 秒待って最大 6 回再試行する。
6 回試しても run が現れなければユーザーに報告して終了する。

失敗 run の ID は `gh pr checks` のリンク URL から取得する:

```bash
# リンク例: https://github.com/owner/repo/actions/runs/12345678/job/...
# run ID は runs/ と /job の間の数値
gh pr checks --json link --jq '[.[] | select(.conclusion=="failure") | .link | capture("runs/(?P<id>[0-9]+)") | .id] | unique'
```

### 3. CI run を監視

Bash tool に background 実行のためのパラメータがある場合明示的に background 実行すること。

```bash
gh run watch <run-id> --compact
```

### 4. 失敗時: re-run を試みる

失敗した job だけを再実行する:

```bash
gh run rerun <run-id> --failed
```

re-run の結果を監視する:
Bash tool に background 実行のためのパラメータがある場合明示的に background 実行すること。

```bash
gh run watch <new-run-id> --compact
```

- passing with re-run: → **flaky として記録**し Step 2 に戻る(次の run を監視)。
  - 完了レポートの `Flaky` 欄に記録する。
- re-run and failed again: → Step 5 に進む。

### 5. 失敗トリアージ: PR 影響箇所との関連チェック

re-run しても失敗する場合、CI の失敗が PR の変更と関連しているかどうかを判定する。

```bash
# PR の変更ファイル一覧を取得
gh pr view --json files --jq '[.files[].path]'

# 失敗ログを取得してファイルパス・エラー箇所を確認
gh run view <run-id> --log-failed
```

**判定基準:**

- 失敗ログに含まれるファイルパスやディレクトリが PR 変更ファイルと重複する → **関連あり**
- 重複なし、または失敗が依存関係解決・インフラ・外部サービス系の step → **関連なし(flaky 疑い)**

**判定結果によるルーティング:**

- **関連あり** → `fix-github-actions-ci` スキルを呼び出す。このスキルが原因特定・修正・commit/push まで完走する。
- **関連なし** → `investigate-flaky-test` スキルを呼び出す。調査レポートをユーザーに提示して終了する。

### 6. 修正後: ループ

`fix-github-actions-ci` による修正 push 完了後、Step 2 に戻って新しい run を取得・監視する。

**ループ終了条件:**

- CI がパスした → 成功レポートを出して終了
- flaky として記録し re-run でパスした → 成功レポート(flaky 注記付き)を出して終了
- `investigate-flaky-test` が完了した → 調査レポートをユーザーに渡して終了
- 同一ブランチで `fix-github-actions-ci` による修正を 3 回試みたが CI が改善しない → ユーザーに報告して終了(無限ループ防止)
- ユーザーが停止を指示した

## 完了レポート

```
CI Watch Report
  Branch  : <branch>
  PR      : <url>
  Result  : ✅ passed | ✅ passed (flaky rerun) | ❌ failed after <N> attempts
  Runs    : <run-url-1>, <run-url-2>, ...
  Flaky   : <flaky が検出された場合のみ> <step-name> (rerun passed on <run-url>)
```

Related Skills

We are still matching the closest adjacent skills for this page. In the meantime, continue through the full directory.