Repository navigation
Conversation
## Short Summary (TL;DR) In Claude Code self-hosted runner sessions, `gh` is the machine's own CLI, either not signed in or signed in as the workspace owner, so the REST fallback from #15 never triggers there. This tells agents to check `gh` against the session's account and use the GitHub MCP tools otherwise, and makes the scripts say so instead of failing with gh's own sign-in advice. ## The Issue - For ddev/coder-ddev#246 `github-rest.md` said self-hosted runners provide a REST-only `gh`. In Claude Code 2.1.322 runner sessions the per-session shim exists but isn't on the Bash tool's `PATH`, so `gh` resolves to `/usr/bin/gh`. On a workspace nobody signed in, every `gh` command, `gh api` included, fails with "To get started with GitHub CLI, please run: gh auth login" and never prints "GitHub GraphQL is not available", so the skills' trigger for `github-rest.md` doesn't fire. On a workspace whose owner ran `gh auth login`, `gh` acts as that owner for every session, including sessions other claude.ai accounts start. The session's system prompt points at the GitHub MCP tools instead. ## How This PR Solves The Issue - `github-rest.md` gets a "Self-hosted runners" section: compare `gh api user` with the MCP `get_me` account, use the GitHub MCP tools when `gh` isn't signed in or is another account, and never run `gh auth login`, `gh auth switch` or set `GH_TOKEN`/`GITHUB_TOKEN` in a shared runner workspace. A table maps `pr-context.sh`, `mentions.sh`, `failed-job.sh` and the `gh pr`/`gh issue`/pending-review steps to MCP tools. The REST material stays, under "Cloud sessions: REST only". - The review, commit and ci-failure skills send runner sessions, and any session whose `gh` isn't signed in, to that file first. ci-failure's table no longer tells runner sessions to run `gh auth login`. - `pr-context.sh` and `mentions.sh` stop with a message naming the MCP tools and `github-rest.md` when `gh` is missing or exits with status 4, gh's "authentication required" status, instead of falling through to REST requests that fail the same way. Other GraphQL failures still fall back to REST. - `failed-job.sh` replaces its `gh auth status` preflight, which a REST-only `gh` may not support, with the same status-4 check on its first request, and gives the MCP tools as the runner alternative. On a Buildkite URL it skips the GitHub history when `gh` is missing or signed out, instead of failing after printing the build. ## Manual Testing Instructions With an empty gh config, so the machine's sign-in isn't touched: ```bash mkdir -p ~/tmp/ghcfg env -u GH_TOKEN -u GITHUB_TOKEN GH_CONFIG_DIR=~/tmp/ghcfg plugins/ddev/skills/review/pr-context.sh 15 ddev/agent-skills env -u GH_TOKEN -u GITHUB_TOKEN GH_CONFIG_DIR=~/tmp/ghcfg plugins/ddev/skills/ci-failure/failed-job.sh https://github.com/ddev/agent-skills/actions/runs/44103475708 ``` Each exits 1 with the MCP pointer. With a signed-in `gh`, both print as before, and a `gh` stub that fails `gh api graphql` with status 1 still gets the REST output. ## Automated Testing Overview `claude plugin validate .` and shellcheck 0.11.0 pass. I ran `pr-context.sh`, `mentions.sh` and `failed-job.sh` signed out, signed in, with no `gh` on `PATH`, and with GraphQL stubbed to fail. I didn't find a public Buildkite build to run the signed-out Buildkite path end to end. Cloud sessions weren't re-checked; the REST-only description of them is unchanged from #15. ## Release/Deployment Notes None; installs pick up the latest commit. Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3Cc2H99Bj4poRHA9pM9ph
|
Another session reworked the same files from a brief that conflicts with this PR in one place. The work is a local commit only, not pushed: Where they conflictA
Where they agree
Smaller differences
Options
Generated by Claude Code |
stasadev
left a comment
There was a problem hiding this comment.
The scripts work as described. Two things before merge: the account comparison (inline) and the README.
README.md:19 still says that in Claude Code self-hosted sessions gh passes on only gh api REST requests. That now contradicts github-rest.md.
Claude Code ran pr-context.sh, mentions.sh and failed-job.sh on this branch and on main: signed in, signed out, with no gh on PATH, and with gh api graphql stubbed to fail. Signed in, the output matches main. Signed out or without gh, each stops with the MCP pointer instead of falling through to REST, and the stub still gets REST. It also ran the signed-out Buildkite path on a failed build (ddev-windows-mutagen 6759): this branch prints the build and the "skipped" line, main exits 4 after the build. Every MCP tool and method in the table exists in github-mcp-server v2.3.0.
🤖 Reviewed with assistance from Claude Code
| it acts as that account for every session on the machine, including | ||
| sessions other people start. | ||
|
|
||
| Before using `gh` there, compare `gh api user --jq .login` with the |
There was a problem hiding this comment.
I'd go with your option 1 and drop the account comparison. On a personal runner where the owner signed gh in, which is how we use them, a mismatch with the claude.ai GitHub account sends the agent to the MCP tools. Those see only attached repositories and have nothing like mentions.sh, so reviews get worse in the common case. Keeping other people's sessions off a shared runner seems like a job for the runner setup (coder-ddev docs).
| # buildkite/<pipeline> to GitHub, so read the history from there. | ||
| gh_repo=$(jq -r '.pipeline.provider.url // "" | sub("^https://github.com/"; "")' "$out/build.json") | ||
| [ -n "$gh_repo" ] || return 0 | ||
| command -v gh > /dev/null || return 0 |
There was a problem hiding this comment.
Small thing: without gh this skips the history silently, while signed out it prints the "skipped" line. Maybe print the same line here?
|
With a little more time on this, I see that claude normally has a |
Short Summary (TL;DR)
In Claude Code self-hosted runner sessions,
ghis the machine's own CLI, either not signed in or signed in as the workspace owner, so the REST fallback from #15 never triggers there. This tells agents to checkghagainst the session's account and use the GitHub MCP tools otherwise, and makes the scripts say so instead of failing with gh's own sign-in advice.The Issue
github-rest.mdsaid self-hosted runners provide a REST-onlygh. In Claude Code 2.1.322 runner sessions the per-session shim exists but isn't on the Bash tool'sPATH, soghresolves to/usr/bin/gh. On a workspace nobody signed in, everyghcommand,gh apiincluded, fails with "To get started with GitHub CLI, please run: gh auth login" and never prints "GitHub GraphQL is not available", so the skills' trigger forgithub-rest.mddoesn't fire. On a workspace whose owner rangh auth login,ghacts as that owner for every session, including sessions other claude.ai accounts start. The session's system prompt points at the GitHub MCP tools instead.How This PR Solves The Issue
github-rest.mdgets a "Self-hosted runners" section: comparegh api userwith the MCPget_meaccount, use the GitHub MCP tools whenghisn't signed in or is another account, and never rungh auth login,gh auth switchor setGH_TOKEN/GITHUB_TOKENin a shared runner workspace. A table mapspr-context.sh,mentions.sh,failed-job.shand thegh pr/gh issue/pending-review steps to MCP tools. The REST material stays, under "Cloud sessions: REST only".ghisn't signed in, to that file first. ci-failure's table no longer tells runner sessions to rungh auth login.pr-context.shandmentions.shstop with a message naming the MCP tools andgithub-rest.mdwhenghis missing or exits with status 4, gh's "authentication required" status, instead of falling through to REST requests that fail the same way. Other GraphQL failures still fall back to REST.failed-job.shreplaces itsgh auth statuspreflight, which a REST-onlyghmay not support, with the same status-4 check on its first request, and gives the MCP tools as the runner alternative. On a Buildkite URL it skips the GitHub history whenghis missing or signed out, instead of failing after printing the build.Manual Testing Instructions
With an empty gh config, so the machine's sign-in isn't touched:
Each exits 1 with the MCP pointer. With a signed-in
gh, both print as before, and aghstub that failsgh api graphqlwith status 1 still gets the REST output.Automated Testing Overview
claude plugin validate .and shellcheck 0.11.0 pass. I ranpr-context.sh,mentions.shandfailed-job.shsigned out, signed in, with noghonPATH, and with GraphQL stubbed to fail. I didn't find a public Buildkite build to run the signed-out Buildkite path end to end. Cloud sessions weren't re-checked; the REST-only description of them is unchanged from #15.Release/Deployment Notes
None; installs pick up the latest commit.
Generated by Claude Code