From aef01371e7d8f28fa200bb42b72c9ce0a7b3360c Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:23:31 +1100 Subject: [PATCH 01/15] ci: show why a Claude review failed The review action hides Claude's output, so a failed review only logged "is_error: true" (it did on #52, with no tokens used). A new step after a failed review prints Claude's error and last result, which name the cause, such as an expired token. --- .github/workflows/claude-code-review.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 4ae0ee8..60ab23f 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,6 +58,7 @@ jobs: with: fetch-depth: 1 - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 + id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} @@ -77,3 +78,16 @@ jobs: --model claude-sonnet-5-5 --max-turns 25 --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Read,Grep,Glob" + # The action hides Claude's output, so a failed review only says "is_error: true". Show the reason (an expired + # token, a used-up plan, an unknown model) from Claude's last result, which holds no secrets. + - name: Say why the review failed + if: failure() && steps.review.conclusion == 'failure' + env: + LOG: ${{ steps.review.outputs.execution_file }} + run: | + [ -f "$LOG" ] || LOG="$RUNNER_TEMP/claude-execution-output.json" + [ -f "$LOG" ] || { echo "::error::Claude left no output file to read."; exit 0; } + jq -r '(if type == "array" then . else [.] end) + | (map(select(.type == "assistant" and .error != null) | "Claude error: \(.error)") | unique[]), + (map(select(.type == "result")) | last | "Claude said: \(.result // "nothing" | tostring | .[0:500])")' "$LOG" | + sed 's/^/::error::/' From 60ad9a77342fa4e4109c581c1c8393ef8b1e850a Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:26:18 +1100 Subject: [PATCH 02/15] ci: prefer an API key for the Claude review The subscription token in CLAUDE_CODE_OAUTH_TOKEN was revoked. The review now uses ANTHROPIC_API_KEY whenever it's set, like Vivid's review, and falls back to the subscription token only when there's no key. --- .github/workflows/claude-code-review.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 60ab23f..e6aa332 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -4,8 +4,8 @@ # Reviews each pull request once with a single Claude Sonnet pass and posts inline comments plus a short summary. # Later pushes are skipped once the summary (marked ) exists. # Skips drafts, bots, fork PRs (GitHub withholds secrets from them) and Markdown-only changes. Uses the -# CLAUDE_CODE_OAUTH_TOKEN secret (a Claude subscription token from `claude setup-token`), or ANTHROPIC_API_KEY when -# that isn't set. Without either, the job does nothing. +# ANTHROPIC_API_KEY secret (an API key, billed per review), or CLAUDE_CODE_OAUTH_TOKEN (a Claude subscription token +# from `claude setup-token`) when there's no API key. Without either, the job does nothing. name: Claude Code Review on: @@ -38,7 +38,7 @@ jobs: steps: - name: Skip without credentials if: env.HAS_CREDENTIALS != 'true' - run: echo "::notice::Add a CLAUDE_CODE_OAUTH_TOKEN (or ANTHROPIC_API_KEY) repository secret to turn on Claude reviews." + run: echo "::notice::Add an ANTHROPIC_API_KEY (or CLAUDE_CODE_OAUTH_TOKEN) repository secret to turn on Claude reviews." - name: Check for an earlier review id: earlier if: env.HAS_CREDENTIALS == 'true' @@ -61,8 +61,8 @@ jobs: id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - anthropic_api_key: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN == '' && secrets.ANTHROPIC_API_KEY || '' }} + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_code_oauth_token: ${{ secrets.ANTHROPIC_API_KEY == '' && secrets.CLAUDE_CODE_OAUTH_TOKEN || '' }} github_token: ${{ secrets.GITHUB_TOKEN }} prompt: | You're reviewing pull request #${{ github.event.pull_request.number }} in ${{ github.repository }}. The PR branch is checked out in the working directory. From 7833074a2717a54dc445e5bb5f1393cb4a05325e Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:31:53 +1100 Subject: [PATCH 03/15] ci: run the Claude review on an API key only Reviews should come out of API credit, not a Claude subscription, so the workflow no longer reads CLAUDE_CODE_OAUTH_TOKEN at all. It needs the ANTHROPIC_API_KEY secret and skips the review without it. --- .github/workflows/claude-code-review.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index e6aa332..1c253ac 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -4,8 +4,7 @@ # Reviews each pull request once with a single Claude Sonnet pass and posts inline comments plus a short summary. # Later pushes are skipped once the summary (marked ) exists. # Skips drafts, bots, fork PRs (GitHub withholds secrets from them) and Markdown-only changes. Uses the -# ANTHROPIC_API_KEY secret (an API key, billed per review), or CLAUDE_CODE_OAUTH_TOKEN (a Claude subscription token -# from `claude setup-token`) when there's no API key. Without either, the job does nothing. +# ANTHROPIC_API_KEY secret (a Claude API key, billed per review). Without it, the job does nothing. name: Claude Code Review on: @@ -34,11 +33,11 @@ jobs: contents: read pull-requests: write env: - HAS_CREDENTIALS: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN != '' || secrets.ANTHROPIC_API_KEY != '' }} + HAS_CREDENTIALS: ${{ secrets.ANTHROPIC_API_KEY != '' }} steps: - name: Skip without credentials if: env.HAS_CREDENTIALS != 'true' - run: echo "::notice::Add an ANTHROPIC_API_KEY (or CLAUDE_CODE_OAUTH_TOKEN) repository secret to turn on Claude reviews." + run: echo "::notice::Add an ANTHROPIC_API_KEY repository secret to turn on Claude reviews." - name: Check for an earlier review id: earlier if: env.HAS_CREDENTIALS == 'true' @@ -62,7 +61,6 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - claude_code_oauth_token: ${{ secrets.ANTHROPIC_API_KEY == '' && secrets.CLAUDE_CODE_OAUTH_TOKEN || '' }} github_token: ${{ secrets.GITHUB_TOKEN }} prompt: | You're reviewing pull request #${{ github.event.pull_request.number }} in ${{ github.repository }}. The PR branch is checked out in the working directory. @@ -78,8 +76,8 @@ jobs: --model claude-sonnet-5-5 --max-turns 25 --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Read,Grep,Glob" - # The action hides Claude's output, so a failed review only says "is_error: true". Show the reason (an expired - # token, a used-up plan, an unknown model) from Claude's last result, which holds no secrets. + # The action hides Claude's output, so a failed review only says "is_error: true". Show the reason (a revoked or + # wrong key, no API credit left, an unknown model) from Claude's last result, which holds no secrets. - name: Say why the review failed if: failure() && steps.review.conclusion == 'failure' env: From 5555e8f436bcbe9fc43d27fe11ee6ff150a2aec4 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:50:19 +1100 Subject: [PATCH 04/15] ci: bill the Claude review to a workspace An API key linked to an account rather than one workspace (sk-ant-usr-...) needs the workspace named on each request, or the API answers "Credit balance is too low" (it did on #53). The review now sends the ANTHROPIC_WORKSPACE_ID secret as the anthropic-workspace-id header, as Vivid's review does. --- .github/workflows/claude-code-review.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 1c253ac..10b3cc2 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -4,7 +4,9 @@ # Reviews each pull request once with a single Claude Sonnet pass and posts inline comments plus a short summary. # Later pushes are skipped once the summary (marked ) exists. # Skips drafts, bots, fork PRs (GitHub withholds secrets from them) and Markdown-only changes. Uses the -# ANTHROPIC_API_KEY secret (a Claude API key, billed per review). Without it, the job does nothing. +# ANTHROPIC_API_KEY secret (a Claude API key, billed per review), plus ANTHROPIC_WORKSPACE_ID for a key linked to an +# account rather than one workspace (sk-ant-usr-...): without it the API bills no workspace and answers "Credit +# balance is too low". Without a key, the job does nothing. name: Claude Code Review on: @@ -59,6 +61,11 @@ jobs: - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' + env: + # the workspace to bill, sent as a header the way Vivid's review sends it (the action's own + # anthropic_workspace_id input is for workload identity federation) + ANTHROPIC_CUSTOM_HEADERS: >- + ${{ secrets.ANTHROPIC_WORKSPACE_ID != '' && format('anthropic-workspace-id: {0}', secrets.ANTHROPIC_WORKSPACE_ID) || '' }} with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} From e979b477581ca4d7bc8ec4699d18ba5f1a0b6d54 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:54:42 +1100 Subject: [PATCH 05/15] ci: TEMP check the workspace id --- .github/workflows/claude-code-review.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 10b3cc2..88c223c 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,6 +58,23 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 + - name: TEMP check the workspace id (prints no secret) + if: env.HAS_CREDENTIALS == 'true' + env: + KEY: ${{ secrets.ANTHROPIC_API_KEY }} + WS: ${{ secrets.ANTHROPIC_WORKSPACE_ID }} + run: | + echo "id length: ${#WS}" + case "$WS" in wrkspc_*) echo "starts with wrkspc_: yes" ;; *) echo "starts with wrkspc_: no" ;; esac + if printf '%s' "$WS" | grep -q '[[:space:]]'; then echo "has whitespace: yes"; else echo "has whitespace: no"; fi + if printf '%s' "$WS" | grep -Eq '^wrkspc_[A-Za-z0-9]+$'; then echo "shape ok: yes"; else echo "shape ok: no"; fi + body='{"model":"claude-sonnet-5-5","messages":[{"role":"user","content":"hi"}]}' + for h in with without; do + if [ "$h" = with ]; then extra=(-H "anthropic-workspace-id: $WS"); else extra=(); fi + code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/messages/count_tokens \ + -H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" "${extra[@]}" -d "$body") + echo "count_tokens $h the header: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-200)" + done - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' From 0a859968c08506e73ca5a0296e01ecd1ecf9b1db Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:55:37 +1100 Subject: [PATCH 06/15] ci: TEMP check the key and workspace id --- .github/workflows/claude-code-review.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 88c223c..1f44e7d 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -64,7 +64,12 @@ jobs: KEY: ${{ secrets.ANTHROPIC_API_KEY }} WS: ${{ secrets.ANTHROPIC_WORKSPACE_ID }} run: | - echo "id length: ${#WS}" + echo "id length: ${#WS}, key length: ${#KEY}" + [ "$WS" = "$KEY" ] && echo "id is the same as the key: yes" || echo "id is the same as the key: no" + for v in KEY WS; do + val="${!v}" + for pre in sk-ant-usr- sk-ant-api sk-ant-oat wrkspc_; do case "$val" in "$pre"*) echo "$v starts with $pre";; esac; done + done case "$WS" in wrkspc_*) echo "starts with wrkspc_: yes" ;; *) echo "starts with wrkspc_: no" ;; esac if printf '%s' "$WS" | grep -q '[[:space:]]'; then echo "has whitespace: yes"; else echo "has whitespace: no"; fi if printf '%s' "$WS" | grep -Eq '^wrkspc_[A-Za-z0-9]+$'; then echo "shape ok: yes"; else echo "shape ok: no"; fi From ea2c9d770c17148a51601e02f7f1fe1599e32c5d Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:00:30 +1100 Subject: [PATCH 07/15] ci: TEMP try each way of sending the key --- .github/workflows/claude-code-review.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 1f44e7d..09fed34 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -73,12 +73,14 @@ jobs: case "$WS" in wrkspc_*) echo "starts with wrkspc_: yes" ;; *) echo "starts with wrkspc_: no" ;; esac if printf '%s' "$WS" | grep -q '[[:space:]]'; then echo "has whitespace: yes"; else echo "has whitespace: no"; fi if printf '%s' "$WS" | grep -Eq '^wrkspc_[A-Za-z0-9]+$'; then echo "shape ok: yes"; else echo "shape ok: no"; fi - body='{"model":"claude-sonnet-5-5","messages":[{"role":"user","content":"hi"}]}' - for h in with without; do - if [ "$h" = with ]; then extra=(-H "anthropic-workspace-id: $WS"); else extra=(); fi - code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/messages/count_tokens \ - -H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" "${extra[@]}" -d "$body") - echo "count_tokens $h the header: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-200)" + for auth in x-api-key bearer; do + for ws in with without; do + args=(-H "anthropic-version: 2023-06-01") + if [ "$auth" = bearer ]; then args+=(-H "Authorization: Bearer $KEY"); else args+=(-H "x-api-key: $KEY"); fi + if [ "$ws" = with ]; then args+=(-H "anthropic-workspace-id: $WS"); fi + code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/models "${args[@]}") + echo "models via $auth, $ws workspace: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-160)" + done done - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review From 4f30d173f74bf82f5b5ed0c657f323b99ade2b9c Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:04:16 +1100 Subject: [PATCH 08/15] ci: remove the temporary key checks --- .github/workflows/claude-code-review.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 09fed34..10b3cc2 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,30 +58,6 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 - - name: TEMP check the workspace id (prints no secret) - if: env.HAS_CREDENTIALS == 'true' - env: - KEY: ${{ secrets.ANTHROPIC_API_KEY }} - WS: ${{ secrets.ANTHROPIC_WORKSPACE_ID }} - run: | - echo "id length: ${#WS}, key length: ${#KEY}" - [ "$WS" = "$KEY" ] && echo "id is the same as the key: yes" || echo "id is the same as the key: no" - for v in KEY WS; do - val="${!v}" - for pre in sk-ant-usr- sk-ant-api sk-ant-oat wrkspc_; do case "$val" in "$pre"*) echo "$v starts with $pre";; esac; done - done - case "$WS" in wrkspc_*) echo "starts with wrkspc_: yes" ;; *) echo "starts with wrkspc_: no" ;; esac - if printf '%s' "$WS" | grep -q '[[:space:]]'; then echo "has whitespace: yes"; else echo "has whitespace: no"; fi - if printf '%s' "$WS" | grep -Eq '^wrkspc_[A-Za-z0-9]+$'; then echo "shape ok: yes"; else echo "shape ok: no"; fi - for auth in x-api-key bearer; do - for ws in with without; do - args=(-H "anthropic-version: 2023-06-01") - if [ "$auth" = bearer ]; then args+=(-H "Authorization: Bearer $KEY"); else args+=(-H "x-api-key: $KEY"); fi - if [ "$ws" = with ]; then args+=(-H "anthropic-workspace-id: $WS"); fi - code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/models "${args[@]}") - echo "models via $auth, $ws workspace: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-160)" - done - done - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' From 760a2183b208632eb7b23cb164b92d0028719553 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:08:09 +1100 Subject: [PATCH 09/15] ci: TEMP one tiny API call --- .github/workflows/claude-code-review.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 10b3cc2..c5e8a68 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,6 +58,21 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 + - name: TEMP one tiny API call (prints no secret) + if: env.HAS_CREDENTIALS == 'true' + env: + KEY: ${{ secrets.ANTHROPIC_API_KEY }} + WS: ${{ secrets.ANTHROPIC_WORKSPACE_ID }} + run: | + for model in claude-haiku-5-5 claude-sonnet-5-5; do + for ws in with without; do + args=(-H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json") + if [ "$ws" = with ]; then args+=(-H "anthropic-workspace-id: $WS"); fi + code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/messages "${args[@]}" \ + -d "{\"model\":\"$model\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}]}") + echo "messages $model, $ws workspace: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-160)" + done + done - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' From e9bfd852c88672666c75cd183cf5dfd99ea681e6 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:09:16 +1100 Subject: [PATCH 10/15] ci: TEMP Claude Code with the key --- .github/workflows/claude-code-review.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index c5e8a68..a64dbe7 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,21 +58,19 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 - - name: TEMP one tiny API call (prints no secret) + - name: TEMP Claude Code with the key (prints no secret) if: env.HAS_CREDENTIALS == 'true' env: - KEY: ${{ secrets.ANTHROPIC_API_KEY }} - WS: ${{ secrets.ANTHROPIC_WORKSPACE_ID }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | + npm install -g --silent @anthropic-ai/claude-code > /dev/null 2>&1 + claude --version for model in claude-haiku-5-5 claude-sonnet-5-5; do - for ws in with without; do - args=(-H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json") - if [ "$ws" = with ]; then args+=(-H "anthropic-workspace-id: $WS"); fi - code=$(curl -s -o "$RUNNER_TEMP/out.json" -w '%{http_code}' https://api.anthropic.com/v1/messages "${args[@]}" \ - -d "{\"model\":\"$model\",\"max_tokens\":5,\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}]}") - echo "messages $model, $ws workspace: HTTP $code $(jq -c '.error // {ok: true}' "$RUNNER_TEMP/out.json" | cut -c1-160)" - done + claude -p "Reply with just: ok" --model "$model" --max-turns 1 --output-format json > "$RUNNER_TEMP/cc.json" 2> "$RUNNER_TEMP/cc.err" || true + echo "claude cli $model: $(jq -c '{is_error, result: (.result | tostring | .[0:150])}' "$RUNNER_TEMP/cc.json" 2>/dev/null || head -c 300 "$RUNNER_TEMP/cc.err")" done + claude -p "Reply with just: ok" --model claude-sonnet-5-5 --max-turns 1 --debug api > /dev/null 2> "$RUNNER_TEMP/dbg.txt" || true + grep -iE 'error|status|billing|credit|beta|context|fast|tier' "$RUNNER_TEMP/dbg.txt" | grep -viE 'key|token|authorization' | head -25 || true - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' From 739f60d764e791be81d6b9bc160a424bf15666c1 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:10:41 +1100 Subject: [PATCH 11/15] ci: update the Claude review action to v1.0.280 v1.0.248 bundles Claude Code 2.1.296, which answered every review with "Credit balance is too low" even though the same API key and workspace work for direct API calls and for Claude Code 2.1.327. v1.0.280 bundles 2.1.327. This also drops the temporary checks used to find that. --- .github/workflows/claude-code-review.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index a64dbe7..b76a94a 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -58,20 +58,7 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 - - name: TEMP Claude Code with the key (prints no secret) - if: env.HAS_CREDENTIALS == 'true' - env: - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - run: | - npm install -g --silent @anthropic-ai/claude-code > /dev/null 2>&1 - claude --version - for model in claude-haiku-5-5 claude-sonnet-5-5; do - claude -p "Reply with just: ok" --model "$model" --max-turns 1 --output-format json > "$RUNNER_TEMP/cc.json" 2> "$RUNNER_TEMP/cc.err" || true - echo "claude cli $model: $(jq -c '{is_error, result: (.result | tostring | .[0:150])}' "$RUNNER_TEMP/cc.json" 2>/dev/null || head -c 300 "$RUNNER_TEMP/cc.err")" - done - claude -p "Reply with just: ok" --model claude-sonnet-5-5 --max-turns 1 --debug api > /dev/null 2> "$RUNNER_TEMP/dbg.txt" || true - grep -iE 'error|status|billing|credit|beta|context|fast|tier' "$RUNNER_TEMP/dbg.txt" | grep -viE 'key|token|authorization' | head -25 || true - - uses: anthropics/claude-code-action@1d6de8cb0c237e7c15e9e1bdf973826ebae490cc # v1.0.248 + - uses: anthropics/claude-code-action@469588f42e6b1e94cd14ad09dccfeaec772ce0fd # v1.0.280 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' env: From 1683748028933f7dc85dce7ba2f40e829cc3bd1b Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:11:43 +1100 Subject: [PATCH 12/15] ci: TEMP try the review without the workspace header --- .github/workflows/claude-code-review.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index b76a94a..f93ae21 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -61,11 +61,6 @@ jobs: - uses: anthropics/claude-code-action@469588f42e6b1e94cd14ad09dccfeaec772ce0fd # v1.0.280 id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' - env: - # the workspace to bill, sent as a header the way Vivid's review sends it (the action's own - # anthropic_workspace_id input is for workload identity federation) - ANTHROPIC_CUSTOM_HEADERS: >- - ${{ secrets.ANTHROPIC_WORKSPACE_ID != '' && format('anthropic-workspace-id: {0}', secrets.ANTHROPIC_WORKSPACE_ID) || '' }} with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} From af3365c5454fe2846d52bd144ad000f78ac4fc5a Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:13:19 +1100 Subject: [PATCH 13/15] ci: TEMP full output for one review --- .github/workflows/claude-code-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index f93ae21..ca8c7ff 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -63,6 +63,7 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + show_full_output: true # TEMP github_token: ${{ secrets.GITHUB_TOKEN }} prompt: | You're reviewing pull request #${{ github.event.pull_request.number }} in ${{ github.repository }}. The PR branch is checked out in the working directory. From e9539837ebf0ddbc3482c8d47a3ff26173d73459 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:14:54 +1100 Subject: [PATCH 14/15] ci: run the Claude review with Claude Code directly With an API key, every claude-code-action run (v1.0.248 and v1.0.280) was refused on its first request with "Credit balance is too low" (400), while the same key works for direct API calls and for the Claude Code CLI in the same job. The review now runs Claude Code 2.1.327 itself with the same prompt, model, turn limit and read-only tools, and posts inline comments with gh api. It no longer uses the workspace header, which the key doesn't need. --- .github/workflows/claude-code-review.yml | 43 +++++++++++++----------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index ca8c7ff..2724f5f 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -4,9 +4,7 @@ # Reviews each pull request once with a single Claude Sonnet pass and posts inline comments plus a short summary. # Later pushes are skipped once the summary (marked ) exists. # Skips drafts, bots, fork PRs (GitHub withholds secrets from them) and Markdown-only changes. Uses the -# ANTHROPIC_API_KEY secret (a Claude API key, billed per review), plus ANTHROPIC_WORKSPACE_ID for a key linked to an -# account rather than one workspace (sk-ant-usr-...): without it the API bills no workspace and answers "Credit -# balance is too low". Without a key, the job does nothing. +# ANTHROPIC_API_KEY secret (a Claude API key, billed per review). Without it, the job does nothing. name: Claude Code Review on: @@ -58,36 +56,41 @@ jobs: if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' with: fetch-depth: 1 - - uses: anthropics/claude-code-action@469588f42e6b1e94cd14ad09dccfeaec772ce0fd # v1.0.280 + # Claude Code itself rather than claude-code-action: with an API key, the action's runs were refused with "Credit + # balance is too low" (400) on their first request, while the same key works for the plain CLI (November 2026). + - name: Review with Claude Code id: review if: env.HAS_CREDENTIALS == 'true' && steps.earlier.outputs.reviewed != 'true' - with: - anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - show_full_output: true # TEMP - github_token: ${{ secrets.GITHUB_TOKEN }} - prompt: | + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GH_TOKEN: ${{ github.token }} + PROMPT: | You're reviewing pull request #${{ github.event.pull_request.number }} in ${{ github.repository }}. The PR branch is checked out in the working directory. 1. Run `gh pr view ${{ github.event.pull_request.number }}` and `gh pr diff ${{ github.event.pull_request.number }}` to see what changed and why. 2. Read AGENTS.md and CONTRIBUTING.md, if they exist, for the project's rules. Open other files only when you need context to judge a change. 3. Look for real problems: bugs, crashes, regressions, broken edge cases, security issues, private details (keys, tokens, personal names or emails, server addresses, home-folder paths) and clear breaks of the project's rules. Skip style nitpicks and anything a linter or CI would catch. - 4. Post each real problem as an inline comment on the line it's about, with mcp__github_inline_comment__create_inline_comment. Say what's wrong and how to fix it in a sentence or two. + 4. Post each real problem as an inline comment on the line it's about, with exactly this command (one per problem, LINE being the line number in the new version of the file): + gh api --method POST repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments -f commit_id=${{ github.event.pull_request.head.sha }} -f side=RIGHT -f path=PATH -F line=LINE -f body="..." + Say what's wrong and how to fix it in a sentence or two. 5. Finish with one short summary comment using `gh pr comment ${{ github.event.pull_request.number }} --body "..."`. Start the body with the line `` (it marks the PR as reviewed). If nothing needs fixing, say so in one line. Keep it short and only flag things worth fixing. Write in Australian English without em dashes. - claude_args: >- - --model claude-sonnet-5-5 - --max-turns 25 - --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Read,Grep,Glob" - # The action hides Claude's output, so a failed review only says "is_error: true". Show the reason (a revoked or - # wrong key, no API credit left, an unknown model) from Claude's last result, which holds no secrets. + TOOLS: >- + Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment ${{ github.event.pull_request.number }}:*),Bash(gh api --method POST repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments:*),Read,Grep,Glob + run: | + npm install -g --no-fund --no-audit @anthropic-ai/claude-code@2.1.327 > /dev/null + claude -p "$PROMPT" --model claude-sonnet-5-5 --max-turns 25 --allowedTools "$TOOLS" --output-format json \ + > "$RUNNER_TEMP/claude-execution-output.json" + jq -r '"Claude: \(.num_turns) turns, about US$\(.total_cost_usd * 100 | round / 100)"' "$RUNNER_TEMP/claude-execution-output.json" + jq -e '.is_error | not' "$RUNNER_TEMP/claude-execution-output.json" > /dev/null + # A failed review's reason (a revoked or wrong key, no API credit left, an unknown model), from Claude's result, + # which holds no secrets. - name: Say why the review failed if: failure() && steps.review.conclusion == 'failure' - env: - LOG: ${{ steps.review.outputs.execution_file }} run: | - [ -f "$LOG" ] || LOG="$RUNNER_TEMP/claude-execution-output.json" - [ -f "$LOG" ] || { echo "::error::Claude left no output file to read."; exit 0; } + LOG="$RUNNER_TEMP/claude-execution-output.json" + [ -s "$LOG" ] || { echo "::error::Claude left no output to read."; exit 0; } jq -r '(if type == "array" then . else [.] end) | (map(select(.type == "assistant" and .error != null) | "Claude error: \(.error)") | unique[]), (map(select(.type == "result")) | last | "Claude said: \(.result // "nothing" | tostring | .[0:500])")' "$LOG" | From 60dd3f6ee7968379fb5e40cab61d0dcd2f8c491b Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:16:02 +1100 Subject: [PATCH 15/15] ci: read the CLI's single result when a review fails Claude Code's --output-format json writes one result object, so the failure step now prints its result alone (found by the review on #53). --- .github/workflows/claude-code-review.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 2724f5f..ec81917 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -91,7 +91,5 @@ jobs: run: | LOG="$RUNNER_TEMP/claude-execution-output.json" [ -s "$LOG" ] || { echo "::error::Claude left no output to read."; exit 0; } - jq -r '(if type == "array" then . else [.] end) - | (map(select(.type == "assistant" and .error != null) | "Claude error: \(.error)") | unique[]), - (map(select(.type == "result")) | last | "Claude said: \(.result // "nothing" | tostring | .[0:500])")' "$LOG" | - sed 's/^/::error::/' + # --output-format json writes one result object; its result holds the API's message on a failure + jq -r '"::error::Claude said: \(.result // "nothing" | tostring | .[0:500])"' "$LOG"