AI审查CI失败分诊
ai-review-max-turns
分诊红色的 Claude 驱动的 CI 审查检查。用于 AI 审查作业失败或出现不稳定(flaky)情况时:通过 subtype 和 is_error 将真实的、尚未发布的审查发现,与回合预算(turn-budget)或上限溢出以及基础设施重跑区分开。
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 60
- Forks
- 6
01 前言 Front Matter
- name
- ai-review-max-turns
- created
- 1788307200000
- modified
- 1791504000000
- reviewed
- 1790121600000
- description
- Triage a red Claude-powered CI review check. Use when an AI review job fails or flakes: tell a real unpublished finding from turn-budget or ceiling overruns and infra reruns via subtype + is_error.
- allowed-tools
- Bash, Read, Grep, Glob, TodoWrite
02 资源文件 9
- 许可证LICENSE1.0 KB
- 参考文档REFERENCE.md5.9 KB
- 参考文档references/bot-actor-refusal.md4.4 KB
- 参考文档references/budget-exhaustion.md2.9 KB
- 参考文档references/errored-despite-completing.md1.9 KB
- 参考文档references/turn-ceiling-overrun.md6.5 KB
- 参考文档references/unpublished-finding.md944 B
- 参考文档SOURCE.md364 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
A Red AI-Review CI Check Has Five Very Different Causes — Separate Them Before Acting
A growing class of CI checks are Claude-powered reviewers — a workflow
that runs the Claude Code action over the PR diff and reports findings as a
pass/fail check. They are usually a family of reusable-quality-*,
reusable-security-*, and reusable-a11y-* workflows, surfaced on the PR as
checks named typescript / analyze, secrets / scan, owasp / scan,
aria / analyze, wcag / analyze, and the like.
When to Use This Skill
| Use this skill when... | Use something else when... |
|---|---|
The red check is Claude-powered (owasp / scan, secrets / scan, aria/wcag, …) |
A deterministic check failed and you need its error → github-actions-inspection |
| Deciding whether that red is a finding or noise | The failure is real and needs a code fix pushed → git-plugin:git-fix-pr |
| The AI review stays green but re-runs on every push — see REFERENCE.md |
The five causes
They go red for five reasons that demand opposite responses. Reading one as another is the whole hazard:
| Cause | Tell | Response |
|---|---|---|
| Budget exhaustion — the run died mid-flight | error_max_turns in the log; is_error: true |
Ignore the failure; it says nothing about the code |
| Turn-ceiling overrun — the run finished, the wrapper failed the job | is_error: false, subtype: "success", no Found N line, and ##[error]Claude reported a successful result after N turns, exceeding the configured maximum of M |
Ignore the failure; the scan completed and found nothing |
| A real finding it could not publish | is_error: false, subtype: "success", a ::error::Found N … line, and no PR comment |
Investigate the code by hand — the check found something |
| Result flagged errored despite completing | subtype: "success" and is_error: true, low num_turns, 0 denials, no Found N line, no result string |
Rerun the identical commit once; a pass means it was infra |
| Bot-actor refusal — the action refused to start Claude | No execution file, no is_error, no num_turns; the log says non-human actor: <name> (type: Bot); when a workflow pushed with github.token, also run_attempt ≥ 2 with actor ≠ triggering_actor |
Ignore the failure; fix the workflow with allowed_bots, or push with a PAT or App token |
The law: the red X is never the discriminator, and neither is
is_erroron its own. Rule out Cause 5 first: a refused run has nothing to read. Then readsubtypeandis_errortogether.error_max_turnsmeans the run died mid-flight.subtype: "success"means it finished, and a finished run can still reportis_error: true(Cause 4), sois_erroralone does not separate a run that died from one that finished. Among finished runs readingis_error: false, the finding count decides: aFound Nline means the check is trying to tell you something through a blocked channel; its absence alongside a turn-count error means the wrapper failed a scan that had nothing to say.
Read subtype and is_error, then the finding count, before forming any
theory. Stopping at is_error sends a turn-ceiling overrun to the hand-audit
response, and files Cause 4 under budget exhaustion, whose upstream fix (raise
max_turns) cannot help a five-turn run.
url=$(gh pr checks <pr> -R <owner>/<repo> --json name,link \
--jq '.[]|select(.name=="<check>")|.link')
runid=$(echo "$url" | sed -E 's#.*/runs/([0-9]+)/.*#\1#')
gh run view "$runid" --log-failed 2>&1 | grep -iE '"is_error"|"subtype"|error_max_turns|num_turns|non-human actor'
Cause 1 (budget exhaustion) — when the log shows error_max_turns, open references/budget-exhaustion.md for the rotating-failure tell, why not to blind-rerun, the mergeStateStatus check, and the upstream fix.
Cause 2 (turn-ceiling overrun) — when a subtype: "success" run logs exceeding the configured maximum, open references/turn-ceiling-overrun.md for the grep, the evidence, where the turns went (including a base-branch restore that parks a PR's .claude/ edits in .claude-pr/), and the upstream fix.
Cause 4 (errored despite completing) — when subtype: "success" and is_error: true appear together, open references/errored-despite-completing.md for the full signature, the grep, and the rerun-once rule.
Cause 5 (bot-actor refusal) — when the step fails with no execution file and the log says non-human actor, open references/bot-actor-refusal.md for the approval-hold mechanism, the allowed_bots fix, and a scan counting them across a repo's failed runs.
Cause 3 — a real finding the check cannot publish
These workflows are told Leave a PR comment with findings but are granted no
comment tool, so every attempt is denied and the prose is discarded — while
fail-on-critical still fails the build off the count in structured_output.
The result is a gate that blocks a merge on a finding nobody can read.
gh run view --job <job-id> --log | grep -E '"is_error"|"subtype"|permission_denials_count|critical security'
gh pr view <n> --json comments --jq '.comments | length' # 0 = it could not publish
gh api repos/<o>/<r>/check-runs/<job-id> --jq .output # all null = nothing to read
permission_denials_count in double digits is the signature: the model retries
the blocked call, which also burns budget.
Do not treat an unreadable finding as a false positive. Read the analyzed files yourself against the check's own category list. The finding is often in pre-existing code the scan read alongside the diff — but not always.
A worked case where the finding was real is in references/unpublished-finding.md.
The count is not stable. Same commit, different answer. Never treat a delta between runs as evidence a fix worked.
The trap under all five: a check that never ran looks exactly like a pass
Before using a sibling PR as a "it's green there" control, check the
duration. These workflows carry file-patterns filters, so a PR touching
no matching files completes in 4–6 seconds having analyzed nothing — and
reports pass.
gh pr checks <n> | grep -E "owasp|code-smell" # 4s pass = skipped, not clean
gh run list --workflow security.yml --branch main -L 5 # empty = PR-triggered only, no main baseline
A green tick from a skipped run is not a control. This is
never-fabricate-test-identifiers.md's known-good control applied to CI: if
the "passing" comparison never executed, you have no baseline, and
pr-merge-hazards.md's merge-over-red test ("same check already fails on
main") cannot be satisfied.
No history at all: the workflow has ≤1 historical run
The control above presumes some earlier run exists. A newly added workflow may have none, and its only run can be the failing one:
gh run list --workflow <file>.yml -L 12 # only the failing run, or nothing
When the workflow has ≤1 historical run, state it in the triage: no baseline exists,
so "is this normal for this check?" cannot be answered from history. An empty
gh run list reads as nothing to see; it means there is nothing to compare
against. Rerunning the identical commit then becomes the primary discriminator
rather than a follow-up (a deterministic failure repeats, a flake does not),
alongside reading the changed files against the check's own criteria.
Evidence (thelma#1524) is in references/errored-despite-completing.md.
When it bites
- Large PRs that outrun a per-file reviewer's turn budget, and repos that mark these checks required: references/budget-exhaustion.md § When it bites.
- Any security-category scan whose red you are tempted to wave through on the strength of green deterministic gates. Cause 3 looks identical from the outside and is exactly where that reflex is most expensive.
Rationale
A red check on valid code is worse than no check: it reads as a real finding,
so it pulls a reviewer into chasing a non-existent defect and erodes trust in
the AI-review signal. But the inverse error is worse still — treating every
AI-review red as flakiness waves through the findings that are real and merely
unpublishable. Ruling out the bot-actor refusal, then reading subtype,
is_error and the finding count together, separates all five. Same instinct as
github-actions-plugin:multirepo-ci-cd: diagnose against what CI actually
did (read the run), not against the surface red.
Related
- REFERENCE.md — the green runaway: a
synchronize-triggered review loop with no round counter, why draft does not stop it, the kill switches and their blast radius, and where the per-run cost actually lives .claude/rules/pr-merge-hazards.md§4 —UNSTABLEvsBLOCKED, and the two checks required before merging over redlaurigates/.claude/rules/ci-cd-workflows.md— the three green-but-inert modes of these same workflows (empty secret, workflow anti-tampering, skipped by filter); this skill covers the red modes~/.claude/rules/diagnose-at-the-failure-point.md— measure at the failure point rather than accepting the framing the error hands yougithub-actions-plugin:multirepo-ci-cd— portfolio-wide CI diagnosis discipline
04 同仓库更多 Skills
session-workflow-capture
Workflow-tool scripts and workflow friction from this session, filed as issues here or in the plugins repo. Use when a session ran Workflow scripts.
kitty-show-image
Show the user an image with a note on what to judge, via a file send or a labelled kitty tab. Use when the user must see an image, or icat fails with no /dev/tty.
kitty-session-persistence
Snapshot and restore kitty terminal sessions on macOS. Use when surviving WindowServer hangs without losing tabs, configuring snapshots, or restoring after a force-reboot.
kitty-remote-control
Safe kitty remote control from an agent — read panes with kitty @ ls/get-text, notify, and never mutate the live terminal unasked. Use when running inside kitty.
docs-reference-check
Dangling doc-reference gate: flag markdown naming repo paths or relative links that no longer exist. Use when docs cite moved/deleted files, or wiring a doc-drift lint.
YouTube 视频上传与编辑
youtube-upload
通过 Data API v3 将视频上传到 YouTube,并在之后编辑其标题、描述、标签或缩略图。适用于发布 YouTube 视频或修改其标题。