From ca137eb22d0591a5156a6bfa80643bbb7451e64b Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Tue, 8 Sep 2026 18:46:25 -0500 Subject: [PATCH] Fix monitor-ci.sh doc/script mismatch: no --commit flag exists CLAUDE.md and the /ci skill's own SKILL.md described a --commit SHA flag for monitor-ci.sh, but the script only ever took positional args ([repos] [branch] [sha_pgxntool_test] [sha_pgxntool]) - that flag text apparently crept in from ../ai/CLAUDE.md's general gh-CLI advice (gh run list/gh pr checks do take --commit) getting conflated with this script's own interface. An agent following the doc literally invoked `monitor-ci.sh --commit SHA`, which silently misparsed into REPOS="--commit" (falls through to the "both" default) with the SHA landing in BRANCH, polling a nonexistent branch for ~35 minutes before timing out. Also fixes SKILL.md's Usage line, which showed the wrong arg order/count ( , missing the leading `repos` arg and with the two SHAs swapped relative to the script's real sha_pgxntool_test/sha_pgxntool order). Kept the positional interface rather than adding a --commit flag: "both" mode (the default) needs two separate SHAs for two separate repos' pushes, so a single --commit flag can't express the primary use case, and the positional form is already load-bearing in the release skill. Added a guard so a future --flag-style invocation fails fast with a usage message instead of silently misparsing and hanging until timeout. --- .claude/skills/ci/SKILL.md | 10 ++++++---- .claude/skills/ci/scripts/monitor-ci.sh | 11 +++++++++++ CLAUDE.md | 12 +++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.claude/skills/ci/SKILL.md b/.claude/skills/ci/SKILL.md index 864ae81..5416a5d 100644 --- a/.claude/skills/ci/SKILL.md +++ b/.claude/skills/ci/SKILL.md @@ -18,7 +18,7 @@ Monitor GitHub Actions CI across both repos after a push. Always run in backgrou - `/ci` — monitor the most recent CI run on both repos for the current branch - `/ci pgxntool-test` — monitor pgxntool-test only - `/ci pgxntool` — monitor pgxntool only -- `/ci ` — monitor specific push SHAs (most reliable) +- `/ci both ` — monitor specific push SHAs (most reliable) ## Workflow @@ -41,9 +41,11 @@ When pushing to both repos, always pass the SHAs to avoid a race condition where > **Race condition note**: `gh run list --branch` returns the most recent run on > that branch — if two pushes happen close together (e.g. two sessions pushing -> in parallel), it may pick up the wrong run. Passing `--commit SHA` targets the -> exact push and avoids this. When SHA is unavailable, always verify the -> `=== BRANCHES: ===` line in the output matches the code you pushed. +> in parallel), it may pick up the wrong run. Passing the `sha1`/`sha2` +> positional arguments above lets the script resolve the run via `gh run list +> --commit` internally, targeting the exact push and avoiding this — the +> script itself has no `--commit` flag. When SHA is unavailable, always verify +> the `=== BRANCHES: ===` line in the output matches the code you pushed. **Always use `run_in_background: true`.** diff --git a/.claude/skills/ci/scripts/monitor-ci.sh b/.claude/skills/ci/scripts/monitor-ci.sh index da19659..9917d7b 100755 --- a/.claude/skills/ci/scripts/monitor-ci.sh +++ b/.claude/skills/ci/scripts/monitor-ci.sh @@ -22,6 +22,17 @@ set -euo pipefail +# Purely positional args, no flags (see the header comment above) - catch a +# "--commit SHA"-style invocation here instead of letting it silently +# misparse into REPOS="--commit" (falls through to the "both" default) with +# the SHA itself landing in BRANCH, which then polls a nonexistent branch +# until timeout. +if [[ "${1:-}" == --* ]]; then + echo "monitor-ci.sh takes positional args, not flags: [repos] [branch] [sha_pgxntool_test] [sha_pgxntool]" >&2 + echo "Got '$1' where 'repos' was expected. See the /ci skill's Usage section." >&2 + exit 64 +fi + REPOS="${1:-both}" BRANCH="${2:-$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")}" SHA_TEST="${3:-}" diff --git a/CLAUDE.md b/CLAUDE.md index 335cc48..c32319d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -25,11 +25,13 @@ convention in `../ai/CLAUDE.md`: for each repo — do not monitor them sequentially. - Always use the `/ci` skill (`bash .claude/skills/ci/scripts/monitor-ci.sh`) rather than raw `gh run`/`gh pr checks` calls — it derives the owner from - the current repo and monitors both. Pass the exact push SHA when - available — `gh run list --branch` has a race condition: if two pushes - land close together on the same branch (e.g., two Claude sessions pushing - in parallel), `--branch` may pick up the wrong run. `--commit SHA` targets - the exact push and avoids this. + the current repo and monitors both. Pass the exact push SHA(s) as + positional arguments when available (see the `/ci` skill for exact + usage — the script takes `[repos] [branch] [sha_pgxntool_test] + [sha_pgxntool]`, not a `--commit` flag) — `gh run list --branch` has a + race condition: if two pushes land close together on the same branch + (e.g., two Claude sessions pushing in parallel), `--branch` may pick up + the wrong run. An exact SHA targets the push directly and avoids this. - **After every monitor run, check the `=== BRANCHES: pgxntool=X pgxntool-test=Y ===` line** to verify the right code is under test. If the branches don't match what you pushed, cancel the run and re-trigger.