Claude Codeが「gh run view」を実行できない
問題
- Claude CodeにGitHub ActionsのCI状況を確認をしてもらうために「gh run view」を実行するとエラーが発生する。
● Bash(gh run view 1111111111)
⎿ Error: failed to get annotations: HTTP 403: Resource not accessible by personal access token (https://api.github.com/repos/username/projectname/check-runs/1111111111/annotations)
原因
- Fine-grained personal access tokensで作成したトークンに対し、gh run viewの実行権限の付与が不可(2025年8月26日時点)
gh run viewが含まれるChecksAPIを制御できるトークン形式に、Fine-grained personal access tokensが含まれることがドキュメントに記載されている。
Fine-grained access tokens for "Create a check run"
This endpoint works with the following fine-grained token types:
・GitHub App user access tokens
・GitHub App installation access tokens
・Fine-grained personal access tokens
The fine-grained token must have the following permission set:
・"Checks" repository permissions (write)
しかし、何かしらの問題があったため、実際には選択できないようにされている。
I apologize for any inconvenience here, but at the moment, it isn't possible to assign Checks permissions to a Fine-grained PAT —only GitHub Apps can access this API. We had that functionality initially, but due to some edge cases we disabled it.
https://github.com/orgs/community/discussions/129512
解決方法
- 「workflow」にチェックを入れたPersonal access tokens (classic)を作成する。
権限を付与した場合(ターミナルで実行)
XXXXXX@YYYYYY:~/user/projectname$ gh run view 1111111111
✓ develop Frontend CI · 1111111111
Triggered via push about 1 hour ago
JOBS
✓ test (18.x) in 1m38s (ID ZZZZZZZZZZZ)
For more information about a job, try: gh run view --job=<job-id>
View this run on GitHub: https://github.com/username/projectname/actions/runs/1111111111
Discussion