GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ci: authenticate gh in claude-implement so the loop opens its PR by allxsmith · Pull Request #219 · allxsmith/bestax

Conversation

@allxsmith

@allxsmith allxsmith commented Jul 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

Description

Fixes the AI implement loop's inability to actually open a PR. On the first run that got far enough to reach the PR step (run #28758428702 on #188), the loop committed its branch but never created a PR — it only posted the fallback "Create PR" link, then marked the task done.

Root cause: step 5 of the prompt runs gh pr create in the agent's Bash sandbox, but the Run Claude step had no env: block — so no GH_TOKEN was present. The claude-code-action wires its GitHub App token into its own MCP tools (which is why commits worked), but not into the shell, so gh was unauthenticated and PR creation failed silently. This wasn't an allowlist gap (gh pr create is already allowed); it was missing auth.

Fix: add env: GH_TOKEN: ${{ secrets.AI_LOOP_PAT }} to the step.

Affected package(s):

  • bulma-ui (@allxsmith/bestax-bulma)
  • create-bestax (create-bestax)
  • docs (@allxsmith/bestax-docs)
  • Other: CI / GitHub Actions (.github/workflows/claude-implement.yml)

Related Issue(s)

Refs #188 (the run that surfaced the bug)

Type of Change

  • Build tooling

Why a PAT and not GITHUB_TOKEN

The loop's design (claude-pr-loop.yml) needs CI to run on the auto-created PR so it can converge to green. GitHub blocks PRs created with the automatic GITHUB_TOKEN from triggering workflows — so GITHUB_TOKEN would open a PR that CI never runs on, stalling the loop. A real account's PAT does not have that restriction. This mirrors how Bun's robobun machine account operates.

AI_LOOP_PAT is the bestaxbot machine account's PAT. Because allxsmith/bestax is owned by a personal account (not an org), a fine-grained token created by a collaborator bot cannot be scoped to it — so this uses a classic PAT with the repo scope (or just public_repo, since bestax is public). bestaxbot is a single-purpose account that only collaborates on this one repo, so the token's reach is effectively limited to bestax. (If bestax is ever moved into a GitHub org, this can switch to a fine-grained token for tighter scoping.)

Required setup before this takes effect (human steps)

  1. Create the bestaxbot GitHub machine account (distinct email; enable 2FA).
  2. Invite bestaxbot to allxsmith/bestax as a collaborator with Write access (needed to push the claude/* branch and open the PR with the ai-loop label), and accept the invite as bestaxbot.
  3. Signed in as bestaxbot, generate a classic PAT (public_repo, or repo if you want private-safe) and add it to the repo as secret AI_LOOP_PAT.

Until the secret exists, the step's GH_TOKEN is empty and behavior is unchanged (PR creation keeps failing as before) — so merging this is safe to do ahead of the account setup.

Checklist

  • Self-reviewed
  • YAML validated (yaml.safe_load); GH_TOKEN confirmed attached to the Run Claude (implement issue) step
  • No behavior change until AI_LOOP_PAT is set

Note on scope

This wires only the bestaxbot identity into gh pr create, so the PR is authored by bestaxbot (triggers CI + Pull Shark). Commits still come from the action's signed-commit MCP (i.e. the Claude app) — the same multi-identity split Robobun uses. If you later want commits also attributed to bestaxbot, that's a follow-up (passing the PAT as the action's github_token input); left out here to keep the change minimal and low-risk.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NVR5yWevceZEFbTJmpviiM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
ci: authenticate gh in claude-implement so the loop opens its PR
2ffaedd
The implement loop pushed its branch via the signed-commit MCP but never
opened a PR: `gh pr create` (step 5 of the prompt) ran in the Bash sandbox
with no GH_TOKEN, so gh was unauthenticated and the command failed
silently. The agent fell back to the auto-generated "Create PR" link and
marked the task done, leaving the work stranded on the branch.

Wire the bestaxbot machine account's fine-grained PAT (secret AI_LOOP_PAT,
scoped to this repo, Contents + Pull requests: write) as GH_TOKEN on the
Run Claude step. Using a real account's PAT rather than the automatic
GITHUB_TOKEN means the PR is authored by bestaxbot and therefore triggers
CI — which the claude-pr-loop convergence depends on (token-created PRs
from GITHUB_TOKEN do not trigger workflows).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NVR5yWevceZEFbTJmpviiM
@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a GH_TOKEN environment variable sourced from secrets.AI_LOOP_PAT to the "Run Claude (implement issue)" workflow step, with comments explaining its purpose for authenticated gh pr create calls and correct PR authorship.

Changes

Workflow Authentication

Layer / File(s) Summary
GH_TOKEN authentication for gh CLI
.github/workflows/claude-implement.yml
Adds an env block setting GH_TOKEN from secrets.AI_LOOP_PAT to the "Run Claude (implement issue)" step so gh pr create runs authenticated and PRs are authored by the designated account.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the workflow change to authenticate gh so the AI loop can create its PR.
Description check ✅ Passed The description follows the template closely, covering summary, affected package, issue, type, and checklist items.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-loop-pr-creation-token

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Preview Deployment

Preview URL: https://6f2d6edd.bestax.pages.dev

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Jul 6, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/claude-implement.yml:
- Around line 96-97: The workflow step is passing AI_LOOP_PAT through GH_TOKEN,
but Claude’s Bash subprocess should receive it via claude_env instead; update
the Claude invocation in the workflow so the token is exposed through the
supported environment input and not only step env. Also add the required Issues
write permission in the workflow permissions block so gh issue view and gh issue
comment can authenticate when the agent runs issue-related commands.
- Around line 88-97: The Claude step is running with a write-scoped GH token in
the same environment as untrusted issue content, so the token must be removed
from the agent runtime. Update the workflow around the step that uses Claude and
gh pr create so the agent does not inherit GH_TOKEN; instead, move the PR
creation into a separate non-agent step or otherwise isolate the token from
Claude’s process. Use the existing claude-implement job and the gh pr create
setup to locate the affected workflow block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f6147889-a6b2-45ad-9b22-1fb86bc80582

📥 Commits

Reviewing files that changed from the base of the PR and between 8a51fa9 and 2ffaedd.

📒 Files selected for processing (1)
  • .github/workflows/claude-implement.yml

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .github/workflows/claude-implement.yml
Comment on lines +88 to +97
# Authenticate the `gh` CLI inside the agent's Bash sandbox so step 5's
# `gh pr create` can actually open the PR. Without a token here, gh is
# unauthenticated and PR creation silently fails (the branch still gets
# pushed via the signed-commit MCP, but no PR is opened). AI_LOOP_PAT is
# the bestaxbot machine account's fine-grained PAT (scoped to this repo,
# Contents + Pull requests: write). Using a real account's PAT — rather
# than the automatic GITHUB_TOKEN — means the PR is authored by bestaxbot
# and therefore triggers CI, which the claude-pr-loop convergence needs.
env:
GH_TOKEN: ${{ secrets.AI_LOOP_PAT }}

@coderabbitai coderabbitai Bot Jul 6, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🌐 Web query:

Which Claude Code CLI version fixed the /proc/self/environ Read tool secret exposure disclosed by Microsoft Threat Intelligence, and is CLAUDE_CODE_SUBPROCESS_ENV_SCRUB enabled by default in anthropics/claude-code-action v1?

💡 Result:

The security vulnerability involving the unauthorized access of /proc/self/environ to expose sensitive environment variables was addressed in Claude Code CLI version 2.1.128, which mitigated the issue by blocking access to sensitive /proc filesystem paths [1]. Regarding the CLAUDE_CODE_SUBPROCESS_ENV_SCRUB environment variable, it is not enabled by default globally in anthropics/claude-code-action v1 [2][3]. Instead, it is configured to be automatically enabled (set to 1) only when the allowed_non_write_users input is configured in the GitHub Action [2][3]. When this input is set, the CLI (version 2.1.79 or later) performs a best-effort scrub of credentials from the environments of subprocesses it spawns [2][3]. Users can manually opt out of this behavior by setting CLAUDE_CODE_SUBPROCESS_ENV_SCRUB to 0 in their job or workflow environment configuration [2][4][5].

Citations:

  • 1: https://news.cloudpandas.com/post/ai-github-actions-secret-exposure-in-claude-code
  • 2: https://github.com/anthropics/claude-code-action/releases/tag/v1.0.77
  • 3: Auto-set subprocess env scrub when allowed_non_write_users is configured anthropics/claude-code-action#1093
  • 4: https://github.com/anthropics/claude-code-action/blob/main/docs/security.md
  • 5: anthropics/claude-code-action@ff9acae

🏁 Script executed:

sed -n '1,180p' .github/workflows/claude-implement.yml

Repository: allxsmith/bestax

Length of output: 8530


🏁 Script executed:

rg -n "allowed_non_write_users|CLAUDE_CODE_SUBPROCESS_ENV_SCRUB|AI_LOOP_PAT|claude-code-action@51c47629174b5dbca955cf93690fd39c8a41dadf|claude-code-action@.*# v1" .github docs CLAUDE.md README.md

Repository: allxsmith/bestax

Length of output: 1011


🌐 Web query:

anthropics/claude-code-action v1.0.77 Claude Code CLI version 2.1.128 /proc/self/environ allowed_non_write_users CLAUDE_CODE_SUBPROCESS_ENV_SCRUB

💡 Result:

The interaction between the anthropics/claude-code-action GitHub Action (v1.0.77+) and the Claude Code CLI (v2.1.79+) centers on enhancing security for workflows that handle potentially untrusted inputs [1][2]. Key technical details: 1. Automatic Environment Scrubbing: Starting with anthropics/claude-code-action version 1.0.77, any workflow that configures the allowed_non_write_users input will automatically have the environment variable CLAUDE_CODE_SUBPROCESS_ENV_SCRUB set to 1 [1][2]. 2. Mechanism: When CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 is active, the Claude Code CLI (v2.1.79+) performs a best-effort removal of sensitive credentials—specifically Anthropic API keys, cloud provider credentials, and GitHub Actions secrets—from the environment of any subprocesses it spawns, such as Bash tools, hooks, or MCP stdio servers [1][2]. The parent Claude process retains these credentials for its own API operations [1][2]. 3. Opt-out: Users can manually override this behavior by setting CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "0" in their workflow or job-level environment configuration, which takes precedence over the automatic setting [1][3]. 4. Security Context: The allowed_non_write_users feature is designed to allow workflows to operate with limited permissions (e.g., issue triage by non-write users), which intentionally bypasses standard security boundaries [4]. The automatic scrubbing was introduced as a hardening measure to mitigate risks when running these potentially exposed workflows [1][2][5]. 5. CLI Behavior: In the Claude Code CLI, this environment variable is part of a "hardening" check [6]. If set, the CLI may restrict certain features, such as downgrading --permission-mode auto to default if specific configuration requirements (like explicitly declared allowed tools) are not met [6].

Citations:

  • 1: https://github.com/anthropics/claude-code-action/releases/tag/v1.0.77
  • 2: Auto-set subprocess env scrub when allowed_non_write_users is configured anthropics/claude-code-action#1093
  • 3: anthropics/claude-code-action@ff9acae
  • 4: feat: add allowed_non_write_users input to bypass permission checks anthropics/claude-code-action#550
  • 5: https://www.microsoft.com/en-us/security/blog/2026/06/05/securing-ci-cd-in-agentic-world-claude-code-github-action-case/
  • 6: Misleading warning: '--allowed-tools' CLI flag and shell env do not satisfy CLAUDE_CODE_SUBPROCESS_ENV_SCRUB auto-mode gate anthropics/claude-code#60985

🌐 Web query:

anthropics/claude-code-action pinned v1 commit 51c47629174b5dbca955cf93690fd39c8a41dadf bundled Claude Code CLI version v2.1.128 release notes

💡 Result:

The anthropics/claude-code-action repository uses tags such as v1 or v1.0.x to version its GitHub Action [1][2]. While specific commits like 51c47629174b5dbca955cf93690fd39c8a41dadf are used for pinning dependencies or workflows, this specific commit hash does not appear to be a publicized or standard tag release [3][1]. The Claude Code Action v1 release is generally tracked via the v1 tag or specific patch versions (e.g., v1.0.162, v1.0.163) [3][1]. Claude Code CLI v2.1.128 was released on May 4, 2026 [4][5]. Its release notes include the following key changes [4][5]: - Slash commands and features: Bare /color (no args) now picks a random session color; /mcp now displays tool counts and flags servers with 0 tools. - Plugin support: --plugin-dir now accepts.zip archives in addition to directories. - Authentication and connectivity: --channels is now supported with console (API key) authentication, provided the org has enabled channelsEnabled: true. - Model picker updates: Duplicate Opus 4.7 entries were collapsed, and the current Opus is now labeled simply as "Opus." - Subprocess environment: Subprocesses (Bash, MCP, LSP, etc.) no longer inherit OTEL_* environment variables. - MCP improvements: workspace is now a reserved server name; re-announced tools on reconnect are summarized by server prefix. - Bug fixes: EnterWorktree now creates branches from local HEAD instead of origin/ (preventing dropped commits); auto mode error messages now provide hints like retry or /compact. - Headless improvements: --output-format stream-json now reports --plugin-dir load failures under init.plugin_errors.

Citations:

  • 1: https://github.com/anthropics/claude-code-action/releases
  • 2: feat: implement Claude Code GitHub Action v1.0 with auto-detection and slash commands anthropics/claude-code-action#421
  • 3: https://github.com/anthropics/claude-code-action
  • 4: https://github.com/anthropics/claude-code/releases/tag/v2.1.128
  • 5: https://newreleases.io/project/github/anthropics/claude-code/release/v2.1.128

🏁 Script executed:

sed -n '104,126p' .github/workflows/claude-implement.yml

Repository: allxsmith/bestax

Length of output: 1631


🌐 Web query:

anthropics/claude-code-action 51c47629174b5dbca955cf93690fd39c8a41dadf bundled Claude Code CLI version package release notes /proc/self/environ fix

💡 Result:

The vulnerability related to /proc/self/environ in the anthropics/claude-code-action was a critical security flaw identified and addressed in June 2026 [1][2][3]. Vulnerability Summary: Researchers discovered that the Claude Code GitHub Action could be exploited through prompt injection in untrusted inputs (such as GitHub issue bodies) [1][3]. Attackers were able to trick the Claude Code agent into reading the /proc/self/environ file on the CI runner [1][3]. Because this file contains process environment variables—which often include sensitive CI/CD credentials like GitHub Actions OIDC tokens—the exploit allowed attackers to extract these secrets [3]. By exfiltrating these tokens, an attacker could potentially hijack repositories, gaining write access to code, issues, and workflows [3]. Fix and Patch: The vulnerability was remediated in version v1.0.94 of the claude-code-action [2][3]. Security updates included hardening measures to prevent the agent from accessing sensitive system files like /proc/self/environ and strengthening the isolation of the agent's environment [3]. Users of the action were advised to update to version v1.0.94 or later immediately [3]. Regarding the commit hash (51c47629174b5dbca955cf93690fd39c8a41dadf): This specific hash refers to a commit within the anthropics/claude-code-action repository. While individual commit hashes are transient, the security remediation associated with the /proc/self/environ issue was solidified in the v1.0.94 release series. As of July 2026, the project has progressed significantly beyond these versions, with the action reaching GA (v1.0) status [4][5]. Organizations currently using the action should ensure they are on the latest stable v1.x release to benefit from all security hardening and feature updates [4][6].

Citations:

  • 1: https://flatt.tech/research/posts/poisoning-claude-code-one-github-issue-to-break-the-supply-chain/
  • 2: https://thehackernews.com/2026/06/claude-code-github-action-flaw-let-one.html
  • 3: https://theoutpost.ai/news-story/critical-flaw-in-anthropic-s-claude-code-let-attackers-hijack-public-repositories-with-a-single-issue-27004/
  • 4: https://github.com/anthropics/claude-code-action/releases
  • 5: https://github.com/anthropics/claude-code-action/releases/tag/v1
  • 6: https://code.claude.com/docs/en/github-actions.md

🌐 Web query:

"51c47629174b5dbca955cf93690fd39c8a41dadf" anthropics/claude-code-action release version

💡 Result:

The string "51c47629174b5dbca955cf93690fd39c8a41dadf" does not correspond to a version number or release identifier for the anthropics/claude-code-action repository [1][2]. It appears to be a truncated Git commit hash or an unrelated identifier [1][2]. The releases for the Claude Code GitHub Action use standard semantic versioning (e.g., v1.0, v1.0.163, v1.0.48) [1][2]. There is no record of this specific string being associated with a release version of this software [1][2].

Citations:

  • 1: https://github.com/anthropics/claude-code-action/releases
  • 2: https://github.com/anthropics/claude-code-action/releases/tag/v1.0.48

🏁 Script executed:

nl -ba .github/workflows/claude-implement.yml | sed -n '82,120p'

Repository: allxsmith/bestax

Length of output: 190


Keep the write-scoped PAT out of the Claude step

This job processes untrusted issue content while exposing GH_TOKEN: ${{ secrets.AI_LOOP_PAT }} in the same agent environment. allowed_non_write_users isn’t set here, so CLAUDE_CODE_SUBPROCESS_ENV_SCRUB won’t turn on automatically. Move gh pr create into a separate step that doesn’t run the agent, or otherwise keep the write token out of Claude’s runtime.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude-implement.yml around lines 88 - 97, The Claude step
is running with a write-scoped GH token in the same environment as untrusted
issue content, so the token must be removed from the agent runtime. Update the
workflow around the step that uses Claude and gh pr create so the agent does not
inherit GH_TOKEN; instead, move the PR creation into a separate non-agent step
or otherwise isolate the token from Claude’s process. Use the existing
claude-implement job and the gh pr create setup to locate the affected workflow
block.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .github/workflows/claude-implement.yml
Comment on lines +96 to +97
env:
GH_TOKEN: ${{ secrets.AI_LOOP_PAT }}

@coderabbitai coderabbitai Bot Jul 6, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does anthropics claude-code-action pass step-level env vars through to the Bash tool subprocess, or does it require the github_token input?

💡 Result:

Yes, anthropics/claude-code-action allows you to pass custom environment variables to Claude Code execution via the claude_env input [1][2][3]. These variables are forwarded to the Claude Code process and are typically available to the Bash tool subprocesses Claude spawns during its session [4]. Regarding your questions: 1. Environment Variables: You can use the claude_env input in your GitHub Actions workflow to define custom environment variables in YAML format [1][2][5]. These are then passed to the Claude Code execution environment [2]. 2. github_token Requirement: The github_token input is optional for claude-code-action [6][7]. The action defaults to using a GitHub App OIDC token if a github_token is not provided [8]. However, specific features or advanced configurations may require explicit permissions or token setup [9][8]. For example, to pass custom variables, your workflow configuration would look like this [1][2]: - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_env: | MY_VAR: my_value DEBUG: true Note that while environment variables defined via claude_env are generally inherited by Bash tool subprocesses, behavior can vary across other tools or plugins (e.g., PowerShell) depending on the specific implementation of the environment propagation [4].

Citations:

  • 1: https://github.com/anthropics/claude-code-base-action/
  • 2: Support for passing custom environment variables to Claude Code execution anthropics/claude-code-base-action#34
  • 3: https://github.com/anthropics/claude-code-action/blob/def1b3a94ee489d17f4959f366dd44e1434da02a/action.yml
  • 4: [FEATURE] CLAUDE_ENV_FILE should propagate to PowerShell tool and child plugins, not bash-only anthropics/claude-code#60697
  • 5: feat: add claude_env input for custom environment variables anthropics/claude-code-action#102
  • 6: https://code.claude.com/docs/en/github-actions
  • 7: https://github.com/anthropics/claude-code-action/blob/ff9acae5886d41a99ed4ec14b7dc147d55834722/action.yml
  • 8: https://github.com/anthropics/claude-code-action/blob/9a3c761f/CLAUDE.md
  • 9: https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md

🌐 Web query:

anthropics/claude-code-action GH_TOKEN step env inherited by Bash tool subprocess docs action.yml github_token claude_env

💡 Result:

In the anthropics/claude-code-action GitHub Action, the GH_TOKEN environment variable is not automatically inherited by the subprocesses spawned by the Claude agent, such as those running gh CLI commands [1]. This behavior has been identified as a limitation in the action's execution path, particularly when using the Agent SDK (introduced in version 1.0.24 and later), where subprocesses may fail to access or use the GH_TOKEN intended for cross-repository or specific GitHub API operations [1]. The official action inputs in action.yml include a github_token parameter, which is intended to provide the necessary credentials for API access [2][3]. However, users have reported that even when GH_TOKEN is explicitly set in the environment block of the action step, the internal execution path of the agent may not propagate this variable to its subprocesses, causing them to fall back to default OIDC tokens rather than the provided token [1]. For managing credentials within the action: 1. Use the github_token input in the action.yml configuration to provide the required authentication token [2][3]. 2. If encountering issues with subprocesses (e.g., gh pr create failing in external repositories), it is a known regression where the agent does not properly pass the environment context to the spawned subprocess [1]. 3. For debugging or custom environment needs, the action defines internal variables like CLAUDE_CODE_SUBPROCESS_ENV_SCRUB in action.yml [4], but these do not resolve the primary issue of automatic environment inheritance for authentication tokens [1]. To work around this, ensure the token is handled securely via GitHub secrets and passed through the official inputs rather than relying on global environment inheritance, as the action's architecture explicitly controls the environment passed to its internal Claude subprocesses [1][4].

Citations:

  • 1: Agent SDK breaks PR creation in external repositories (regression since v1.0.24) anthropics/claude-code-action#771
  • 2: https://code.claude.com/docs/en/github-actions
  • 3: https://code.claude.com/docs/en/github-actions.md
  • 4: https://github.com/anthropics/claude-code-action/blob/refs/heads/main/action.yml

🌐 Web query:

GitHub fine-grained personal access token issues permission gh issue view gh issue comment pull requests write contents write

💡 Result:

When using GitHub fine-grained personal access tokens (PATs) with the GitHub CLI (gh), specific permissions are required beyond those intuitively linked to a command. Issues arise because gh often performs underlying GraphQL queries that fetch additional repository metadata, such as the defaultBranchRef [1][2]. Key insights regarding your specific requirements: 1. Mandatory Metadata: Creating a fine-grained PAT with any repository-level permissions (such as Issues or Pull requests) will automatically require the Metadata permission (read-only) [2]. This is mandatory and usually added by GitHub automatically. 2. The "Contents" Permission Trap: Even for commands that appear to only affect issues or pull requests, the gh tool may require the Contents permission (Read-only) [1][2]. For example, gh issue create and some PR operations fail with a "Resource not accessible by personal access token (repository.defaultBranchRef)" error if Contents: Read is missing [1][2]. This occurs because the tool queries repository information (like the default branch) to complete the request [1]. 3. Recommended Permissions for Full Functionality: While individual commands vary, the GitHub CLI community generally recommends the following minimum fine-grained PAT scopes to ensure most gh features work without "Resource not accessible" errors [3]: - Actions: Read and write - Administration: Read and write - Contents: Read and write - Environments: Read and write - Issues: Read and write - Metadata: Read-only (Mandatory) - Pull requests: Read and write - Workflows: Read and write If you encounter permission errors despite having the relevant Issues or Pull requests write permissions, granting Contents: Read is the standard workaround to resolve metadata access issues [1][2]. For troubleshooting, if you are unsure which specific permissions a command requires, you can check the X-Accepted-GitHub-Permissions header returned by the REST API, though the CLI's GraphQL-based requests may not always provide clear guidance on missing scopes [4][2].

Citations:

  • 1: gh issue create fails with fine-grained PAT that has Issues:Write but not Contents:Read cli/cli#12798
  • 2: Detect missing fine grain permission scopes, notify user on steps to take to refresh scopes cli/cli#9403
  • 3: Document minimum required v2 fine grain PAT scopes in gh auth login cli/cli#9461
  • 4: https://docs.github.com/en/rest/authentication/permissions-required-for-fine-grained-personal-access-tokens?apiVersion=2022-11-28

🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/claude-implement.yml')
text = p.read_text()
for i, line in enumerate(text.splitlines(), 1):
    if 80 <= i <= 140:
        print(f"{i:4}: {line}")
PY

Repository: allxsmith/bestax

Length of output: 4135


Move AI_LOOP_PAT into Claude’s supported env input, and add Issues permission.

  • GH_TOKEN under the workflow step isn’t the supported path for Claude’s Bash subprocess; pass it via claude_env so gh pr create can authenticate.
  • The same token also needs Issues: write if the agent is going to run gh issue view / gh issue comment.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude-implement.yml around lines 96 - 97, The workflow
step is passing AI_LOOP_PAT through GH_TOKEN, but Claude’s Bash subprocess
should receive it via claude_env instead; update the Claude invocation in the
workflow so the token is exposed through the supported environment input and not
only step env. Also add the required Issues write permission in the workflow
permissions block so gh issue view and gh issue comment can authenticate when
the agent runs issue-related commands.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@allxsmith
allxsmith merged commit 3810ca4 into main Jul 6, 2026
20 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 7, 2026
ci: author implement-loop PRs as bestaxbot machine account #231
Merged
ci: sign bestaxbot commits (SSH) and run the fix agent as bestaxbot #234
Merged
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

  • npm package (@latest dist-tag)
  • GitHub release

Your semantic-release bot 📦🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the released label Jul 7, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 11, 2026
ci: auto-label AI-assisted PRs with claude-assisted (#272) #276
Merged
8 of 20 tasks
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.2.0 🎉

The release is available on:

  • npm package (@latest dist-tag)
  • GitHub release

Your semantic-release bot 📦🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

  • npm package (@latest dist-tag)
  • GitHub release

Your semantic-release bot 📦🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@allxsmith
allxsmith deleted the claude/fix-loop-pr-creation-token branch July 31, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

released

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@allxsmith @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.