From 771afb3a912475dc1d1e40e4dab83e0222a3193f Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Thu, 19 Nov 2026 06:04:09 +0300 Subject: [PATCH 1/3] CI: Claude answers as claude[bot] on our own threads, keeps the job token on forks, runs Fable Split the job: `route` reads the pull request's head repository; `own` (issues and this repository's branches) uses the Claude GitHub App's token, so comments are signed claude[bot] and Claude can push a branch; `fork` keeps the read-only job token and every fork guard. Both run claude-fable-5-2. Hooks and `git tag` stay off in `own` too, since an issue's text can be an outsider's. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/claude.yml | 71 ++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index f0853a82d..92b9f2445 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -2,7 +2,16 @@ name: Claude # Answers `@claude` in an issue, a pull request comment, an inline review comment or a review body, # with the Claude Code GitHub Action (https://code.claude.com/docs/en/github-actions). Its main job is -# reviewing pull requests, including ones from outside contributors' forks. +# reviewing pull requests, including ones from outside contributors' forks. It runs Claude Fable 5.2. +# +# TWO JOBS. `route` decides whether the thread is a pull request from a fork, from GitHub's own record +# of the head repository, and nothing else; then exactly one of these runs: +# +# - `own`: an issue, or a pull request from a branch of this repository. Claude signs in to GitHub as +# the Claude GitHub App (comments are signed claude[bot]) and can push a branch and open a pull +# request. The text it reads can still be an outsider's (an issue anyone filed), so it keeps the +# guards that cost nothing here: hooks off, no `git tag`, and the `v*` tag ruleset on the repository. +# - `fork`: a pull request from a fork. The guards below. # # It signs in with the maintainer's Claude SUBSCRIPTION, not an API key: the repository secret # CLAUDE_CODE_OAUTH_TOKEN holds the long-lived token `claude setup-token` prints, and every run counts @@ -15,7 +24,7 @@ name: Claude # pull request text, every comment on it and, on a pull request, the contributor's whole tree. Mention # `@claude` on an outsider's thread only after reading what is there. # -# PULL REQUESTS FROM FORKS. Only a comment in the conversation (`issue_comment`) works there: it runs +# PULL REQUESTS FROM FORKS (the `fork` job). Only a comment in the conversation (`issue_comment`) works there: it runs # this file from the default branch with its secrets. GitHub gives a fork's review and inline review # comment events no secrets, so `@claude` in a review on a fork's pull request fails for want of a token. # The action checks out the pull request's HEAD and restores only `.claude/`, CLAUDE.md, AGENTS.md and a @@ -33,6 +42,7 @@ name: Claude # github-actions[bot], and it cannot push the `pr-N` branch the action would otherwise make of a fork. # No `id-token: write`: with a token passed in, the action does not need OIDC, and an OIDC token from # the default branch would satisfy this repository's Anthropic federation rule (issue-labels.yml). +# That is why forks get their own job (`fork`), with permissions no step can widen. # - Project hooks are off (`disableAllHooks`): the SessionEnd hook runs `tools/build-gc.sh`, which on a # fork is the contributor's copy. Every hook in `.claude/settings.json` is tooling for the maintainer's # Mac anyway. @@ -63,7 +73,7 @@ concurrency: cancel-in-progress: false jobs: - claude: + route: if: | (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || @@ -75,6 +85,60 @@ jobs: (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)) runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + pull-requests: read + outputs: + fork: ${{ steps.kind.outputs.fork }} + steps: + # A fork is a pull request whose head repository is not this one; a deleted fork (no head + # repository) counts as a fork. Only numbers and repository names reach the shell. + - name: Is this a pull request from a fork? + id: kind + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number || (github.event.issue.pull_request && github.event.issue.number) || '' }} + run: | + fork=false + if [ -n "$PR" ]; then + head=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" --jq '.head.repo.full_name // ""') + [ "$head" = "$GITHUB_REPOSITORY" ] || fork=true + fi + echo "pull request: ${PR:-none}, head: ${head:-n/a}, fork: $fork" + echo "fork=$fork" >> "$GITHUB_OUTPUT" + + own: + needs: route + if: needs.route.outputs.fork == 'false' + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: write # push a branch for an issue, or to this repository's pull request branch + pull-requests: write # open a pull request, inline review comments + issues: write # the progress comment + id-token: write # the action exchanges it for the Claude GitHub App's token + actions: read # lets Claude read a pull request's CI results + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 1 + persist-credentials: false + + - name: Run Claude Code + uses: anthropics/claude-code-action@f431adaf77e0fecf918431e75a2b5b45b85af002 # v1.0.283 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + claude_args: >- + --model claude-fable-5-2 + --settings '{"disableAllHooks":true}' + --disallowedTools "Bash(git tag:*)" "Bash(git push --tags:*)" + --allowedTools "mcp__github_inline_comment__create_inline_comment" + + fork: + needs: route + if: needs.route.outputs.fork == 'true' + runs-on: ubuntu-latest timeout-minutes: 60 permissions: contents: read @@ -109,6 +173,7 @@ jobs: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} claude_args: >- + --model claude-fable-5-2 --settings '{"disableAllHooks":true,"disableSkillShellExecution":true}' --disallowedTools "Skill" "Agent" "Task" "Bash(curl:*)" "Bash(wget:*)" "Bash(gh:*)" "Bash(git push:*)" "Bash(git tag:*)" "Bash(tools/:*)" "Bash(./tools/:*)" "Read(//proc/**)" From f9ea2c3c069b2fee0bf747670b6d8d76df74b20a Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Thu, 19 Nov 2026 06:04:48 +0300 Subject: [PATCH 2/3] CI: select Fable by its alias, not a pinned version Co-Authored-By: Claude Opus 5.5 --- .github/workflows/claude.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 92b9f2445..ca77974ee 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -2,7 +2,7 @@ name: Claude # Answers `@claude` in an issue, a pull request comment, an inline review comment or a review body, # with the Claude Code GitHub Action (https://code.claude.com/docs/en/github-actions). Its main job is -# reviewing pull requests, including ones from outside contributors' forks. It runs Claude Fable 5.2. +# reviewing pull requests, including ones from outside contributors' forks. It runs Claude Fable (the `fable` alias: the newest Fable the action's Claude Code knows). # # TWO JOBS. `route` decides whether the thread is a pull request from a fork, from GitHub's own record # of the head repository, and nothing else; then exactly one of these runs: @@ -130,7 +130,7 @@ jobs: with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} claude_args: >- - --model claude-fable-5-2 + --model fable --settings '{"disableAllHooks":true}' --disallowedTools "Bash(git tag:*)" "Bash(git push --tags:*)" --allowedTools "mcp__github_inline_comment__create_inline_comment" @@ -173,7 +173,7 @@ jobs: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} claude_args: >- - --model claude-fable-5-2 + --model fable --settings '{"disableAllHooks":true,"disableSkillShellExecution":true}' --disallowedTools "Skill" "Agent" "Task" "Bash(curl:*)" "Bash(wget:*)" "Bash(gh:*)" "Bash(git push:*)" "Bash(git tag:*)" "Bash(tools/:*)" "Bash(./tools/:*)" "Read(//proc/**)" From f4f57db560ca0ec6aa230f1d458ae59161fa6e40 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Thu, 19 Nov 2026 06:08:56 +0300 Subject: [PATCH 3/3] CI: Claude reviews inline and keeps its summary short and casual Co-Authored-By: Claude Opus 5.5 --- .github/workflows/claude.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index ca77974ee..a6ab8f7ff 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -2,7 +2,9 @@ name: Claude # Answers `@claude` in an issue, a pull request comment, an inline review comment or a review body, # with the Claude Code GitHub Action (https://code.claude.com/docs/en/github-actions). Its main job is -# reviewing pull requests, including ones from outside contributors' forks. It runs Claude Fable (the `fable` alias: the newest Fable the action's Claude Code knows). +# reviewing pull requests, including ones from outside contributors' forks. It runs Claude Fable (the +# `fable` alias: the newest Fable the action's Claude Code knows). `--append-system-prompt` sets the +# tone: findings as inline review comments, and a short, casual summary comment. # # TWO JOBS. `route` decides whether the thread is a pull request from a fork, from GitHub's own record # of the head repository, and nothing else; then exactly one of these runs: @@ -131,6 +133,7 @@ jobs: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} claude_args: >- --model fable + --append-system-prompt "Write like a teammate on GitHub: short, casual, plain words. Put each finding on the line it is about as an inline review comment, one or two sentences, with a suggestion block when the fix is small. Keep the summary comment to a few lines: a one-line verdict, then at most a few bullets for what is not tied to a line. No headings, no restating the PR, no list of files you read, no praise. If nothing needs changing, say so in one line." --settings '{"disableAllHooks":true}' --disallowedTools "Bash(git tag:*)" "Bash(git push --tags:*)" --allowedTools "mcp__github_inline_comment__create_inline_comment" @@ -174,6 +177,7 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} claude_args: >- --model fable + --append-system-prompt "Write like a teammate on GitHub: short, casual, plain words. Put each finding on the line it is about as an inline review comment, one or two sentences, with a suggestion block when the fix is small. Keep the summary comment to a few lines: a one-line verdict, then at most a few bullets for what is not tied to a line. No headings, no restating the PR, no list of files you read, no praise. If nothing needs changing, say so in one line." --settings '{"disableAllHooks":true,"disableSkillShellExecution":true}' --disallowedTools "Skill" "Agent" "Task" "Bash(curl:*)" "Bash(wget:*)" "Bash(gh:*)" "Bash(git push:*)" "Bash(git tag:*)" "Bash(tools/:*)" "Bash(./tools/:*)" "Read(//proc/**)"