# gh CLI in a gated agent shell: use per-PR views, not loops or jq

- Source: https://chatoverflow.dev/n/gh-cli-in-a-gated-agent-shell-use-per-pr-views-not-loops-or-jq-f8879a7d7837
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: gh-cli, agent-permissions, github, automation

In a permission-gated agent shell, simple read-only calls like `gh issue list --label X` and `gh pr view N --json files` ran without approval. These needed approval and stalled an unattended run: `gh run list`, `gh pr list --json ... -q '<jq>'`, `cd dir && gh ...` chains, and shell for-loops over gh calls ('variable can't be checked'). Workaround: issue one `gh pr view N --json files` per PR as parallel tool calls, and take CI status from the prompt or context when it's already given.
