Skip to content

feat(pr): pr view, list, checks, diff and status run gh #4842

Done

Description

@dan-petty

Problem or Motivation

devops pr view has only --repo and --dry-run, and devops pr list has only --state, --limit and --repo. devops gh pr is the same app. Agents typed gh's flags: --json on pr view and pr list 123 times (Claude 48, other tools 75 in 53 sessions), --head and --base on pr list 41 times, --comments on pr view 12 times and --search on pr list 9 times. devops pr status failed 27 times in 20 sessions. After the failures agents used devops gh api: 1,695 GET pulls/:n and 779 GET pulls in the Claude logs.

Tracker #4833, child 6. The owner asked on 2026-11-11 to fix the devops gh issue name and to record such errors for a later analysis of missing flags, features and aliases. The counts come from a study of Claude Code, Kilo, Antigravity and Loki records from 2026-09-23 to 2026-11-11.

Proposed Solution & Architectural Design

Both commands already pass their arguments to gh pr view and gh pr list through run_gh (github/pr_plans.py), so add gh's flags with gh's names and pass them on. pr view: --json <fields>, --jq/-q, --comments/-c. pr list: --json <fields>, --jq/-q, --search/-S, --head/-H, --base/-B. Add devops pr status as a pass-through to gh pr status with --json, --jq and --repo. --json takes gh's field list, and gh names the valid fields when one is wrong. Each flag goes into the dry-run request plan. The boolean --json of other commands does not change.

Target Subsystem

SDLC, Git & PR Governance (devops pr, src/devops_cli/github/pr_plans.py).

Existing Tool Considered

gh itself. devops pr view and pr list already pass their arguments to gh through run_gh, so the work is flag pass-through with gh's names; nothing new is built.

Acceptance Criteria

devops pr view <n> --json number,title --jq .title prints the title. devops pr list --head <branch> --json number prints a JSON array. devops pr list --search is:draft --base main passes both to gh. devops pr view <n> --comments prints the comments. devops pr status exits 0 on a branch with a pull request. --dry-run with each flag lists the gh argv with that flag and runs nothing. devops gh pr view <n> --json title works too. Tests in pr_plans cover each flag.

Dependencies

None. An agent can start it now.

Source: #4833

Alternatives check of 2026-11-24: in-use.
The repository already uses this tool.
Tool: cli/cli (https://github.com/cli/cli), MIT, last activity 2026-11-24, maintained.
Reason: Searches and the cli/cli facts confirm gh already implements pr view, pr list and pr status with --json, --jq, --comments, --search, --head, --base and --repo; only the project's flag forwarding is missing.

Covers:

  • pr view with --json, --jq and --comments
  • pr list with --json, --jq, --search, --head and --base
  • pr status with --json, --jq and --repo

Lacks:

  • The devops pr wiring and dry-run argv plans
  • The new devops pr status command and devops gh pr path
  • A raw-output branch that skips the current table fallback

Proposed design

Problem statement

Add the named gh flags to devops pr view and pr list, and add devops pr status as a pass-through to gh pr status. The devops pr commands reject these flags today. The rejected flags are --json and --comments on pr view, and --json, --head, --base and --search on pr list. devops pr status also fails because the command does not exist. The change prints the planned gh argv on --dry-run and exposes the commands at the devops gh pr path.

Acceptance criteria

Requirement: PR view forwards JSON and jq

The system SHALL pass --json and --jq from devops pr view to gh pr view.

Scenario: PR view forwards JSON and jq

  • WHEN A user runs devops pr view 12 --json number,title --jq .title with a gh process stub.
  • THEN The command passes gh pr view 12 --json number,title --jq .title to the stub and prints the stub output.

Requirement: PR view forwards comments

The system SHALL pass --comments from devops pr view to gh pr view.

Scenario: PR view forwards comments

  • WHEN A user runs devops pr view 12 --comments with a gh process stub.
  • THEN The command passes gh pr view 12 --comments to the stub and prints the comments.

Requirement: PR list forwards head and JSON

The system SHALL pass --head and --json from devops pr list to gh pr list.

Scenario: PR list forwards head and JSON

  • WHEN A user runs devops pr list --head feature --json number with a gh process stub that prints a JSON array.
  • THEN The command passes gh pr list --head feature --json number to the stub and prints the JSON array with no table.

Requirement: PR list forwards search and base

The system SHALL pass --search and --base from devops pr list to gh pr list.

Scenario: PR list forwards search and base

  • WHEN A user runs devops pr list --search is:draft --base main with a gh process stub.
  • THEN The command passes gh pr list --search is:draft --base main to the stub and renders the table from the stub output.

Requirement: PR list forwards jq

The system SHALL pass --json and --jq from devops pr list to gh pr list.

Scenario: PR list forwards jq

  • WHEN A user runs devops pr list --json number --jq .[].number with a gh process stub.
  • THEN The command passes gh pr list --json number --jq .[].number to the stub and prints the stub output.

Requirement: PR status exits zero on a branch with a pull request

The system SHALL add devops pr status as a pass-through to gh pr status with --json, --jq and --repo.

Scenario: PR status exits zero on a branch with a pull request

  • WHEN A user runs devops pr status on a branch with a pull request and the gh stub exits 0.
  • THEN The command passes gh pr status to the stub and exits 0.

Requirement: PR status forwards JSON and repo

The system SHALL pass --json, --jq and --repo from devops pr status to gh pr status.

Scenario: PR status forwards JSON and repo

  • WHEN A user runs devops pr status --json number --repo owner/repo with a gh process stub.
  • THEN The command passes gh pr status --json number --repo owner/repo to the stub and prints the stub output.

Requirement: GH path forwards PR view JSON

The system SHALL expose pr view, pr list and pr status at both the devops pr and devops gh pr paths.

Scenario: GH path forwards PR view JSON

  • WHEN A user runs devops gh pr view 12 --json title with a gh process stub.
  • THEN The command passes gh pr view 12 --json title to the stub and prints the stub output.

Requirement: Dry run prints the gh argv

Each changed or new pr command SHALL print the planned gh argv with --dry-run and send zero requests.

Scenario: Dry run prints the gh argv

  • WHEN A user runs devops pr view 12 --json title --dry-run.
  • THEN The command prints the planned gh pr view 12 --json title argv and sends no request.

Requirement: Raw output failure prints the gh error

The system SHALL print the error of gh and exit with its code when a run with --json or --jq fails, and SHALL NOT print a table.

Scenario: Raw output failure prints the gh error

  • WHEN A user runs devops pr list --json number and the gh stub exits 1 with a rate-limit error.
  • THEN The command prints the stub's error and exits 1, and prints no table.

Requirement: Tests cover each new flag

The change SHALL add tests in tests/commands/test_pr_dry_run.py for each new flag and for pr status.

Scenario: Tests cover each new flag

  • WHEN The test suite runs tests/commands/test_pr_dry_run.py.
  • THEN Each new flag and pr status has a passing argv test.

Existing Tool Considered

cli/cli (gh, https://github.com/cli/cli, MIT, maintained) covers pr view, pr list and pr status with --json, --jq, --comments, --search, --head, --base and --repo. It lacks the devops wiring that this change adds: the new devops pr status command, the flag forwarding in pr_plans.py and commands/pr.py, the dry-run argv plans, and the devops gh pr path. The check also names MCP allowlists and a --watch refusal for pr checks. The issue body does not ask for them, so this proposal leaves them out. The repository already runs gh through run_gh, so the change builds no wrapper.

Key questions

  • Which pr commands already build a gh argv and run it through run_gh?: pr view, pr list, pr checks and pr diff build a gh argv in pr_plans.py and run it through run_gh. pr status has no command. pr checks reads a fixed --json list and renders a verdict table; pr diff passes --color. [sources: src/devops_cli/github/pr_plans.py, src/devops_cli/commands/pr.py, src/devops_cli/github/check_verdict.py]
  • How should the new flags reach gh?: Extend the existing argument builders and plan_pr_* functions in pr_plans.py, and call them from commands/pr.py. The commands already use run_gh and PlannedRequest, so one argv builder serves the real run and the dry run. (best practice) [sources: src/devops_cli/github/pr_plans.py, src/devops_cli/commands/pr.py, src/devops_cli/github/rate_limiter.py]
    • Chosen: Extend the existing pr_plans builders. The commands already use run_gh and PlannedRequest; one argv builder serves the run and the plan.
    • Rejected: Build a separate gh pass-through wrapper. gh already implements the commands and flags; a wrapper adds code and drifts from gh's flags.
    • Rejected: Parse each flag in the command module. It duplicates the argv builder and leaves the dry-run plan to guess the request.
  • What should devops pr list print when --json or --jq is given?: Print the stdout of gh pr list unchanged. Without --json or --jq, keep the current table. The current command always parses a fixed --json list and renders a table, so a user-supplied --json needs a raw-output branch. (best practice) [sources: src/devops_cli/commands/pr.py, src/devops_cli/github/pr_plans.py]
    • Chosen: Raw output on --json or --jq. The acceptance criteria require a JSON array and a jq result; a table cannot be either.
    • Rejected: Always render the table. A table is not the JSON array that the user asked for.
    • Rejected: Always print raw output. It removes the default table that users get with no flag.
  • Should a failed gh run on the --json or --jq path use the REST fallback?: No. Print gh's error and exit with its code. Keep the existing fallback only on the table path. A fallback table would violate the raw-output contract. (best practice) [sources: src/devops_cli/commands/pr.py, src/devops_cli/github/check_verdict.py]
    • Chosen: Skip the fallback on the raw path. The fallback prints a table, which is not the JSON or jq output the user asked for.
    • Rejected: Keep the fallback on every path. A rate-limited --json run would print a table and hide the failure.
    • Rejected: Remove every fallback. That changes the no-flag table behavior beyond this issue.
  • How should --json field names be validated?: Pass the field list to gh unchanged. pr_view_payload_args and pr_checks_args already pass fixed field lists, and gh reports an invalid field. The command adds no local allowlist. (best practice) [sources: src/devops_cli/github/pr_plans.py, src/devops_cli/github/check_verdict.py]
    • Chosen: Pass the field list through. gh owns the field list and names a wrong field; a local list would drift.
    • Rejected: Validate against a local allowlist. It duplicates gh's schema and needs a change for each new gh field.
  • Do devops pr checks and devops pr diff need new flags in this change?: No. pr checks already runs gh pr checks --json name,state,bucket,workflow,link and renders the verdict table. pr diff already runs gh pr diff with --color. The measured failures name pr view, pr list and pr status, and the body's criteria name only those. The change leaves both commands as they are. (best practice) [sources: src/devops_cli/github/check_verdict.py, src/devops_cli/github/pr_plans.py, src/devops_cli/commands/pr.py]
    • Chosen: Leave pr checks and pr diff as they are. Both already run gh; changing pr checks to raw output would remove the verdict table and its exit code.
    • Rejected: Make pr checks a raw pass-through. It changes the verdict table and exit code that pr check-readiness and the docs rely on, and the body does not ask for it.
    • Rejected: Add --name-only to pr diff. The body and the measured failures do not name it; it is a separate flag request.
  • How should the commands work at the devops gh pr path?: Expose the same command functions under the gh group, so both paths build the same gh argv. The issue states that devops gh pr is the same app, and its criteria require devops gh pr view 12 --json title to work. (best practice) [sources: src/devops_cli/commands/pr.py, src/devops_cli/commands/gh.py]
    • Chosen: Share the command functions between the two groups. One argv builder serves both paths, and the issue requires the devops gh pr path.
    • Rejected: Add a separate gh pr implementation. It duplicates the command and the dry-run plan.
    • Rejected: Expose only devops pr. The issue's acceptance criteria require devops gh pr view.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/pr
    status/new
    value/high
    effort/low
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/pr. The (pr) scope of the title gives the scope.
    • Priority: P2-Medium. Agents fail 123 times on flag typos and 27 times on pr status, but no data is lost and no build is blocked.
    • Value: High. High-frequency agent failures (123 flag typos, 27 status failures, 41 head/base misses) are resolved by this change.
    • Effort: Low. The body states the work is flag pass-through to gh with no new logic, and an agent can start it now.
    • Related: feat(github): implement native devops cli functionality for gh operations and pr governance #181, which asks for a different change. Both extend devops pr governance, but #181 adds pr ready, diff, and close while the candidate adds gh flag pass-through to pr view and pr list and a new pr status command.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Live data, 2026-11-12. The OTLP records cli_usage_error (service devops-cli, Loki) hold 159 usage errors in the last 7 days. All 159 come from agents (usage_caller=agent, usage_agent_tool=claude_code) on the development container. The Service and its Job pods recorded none. Releases 0.118.0 to 0.121.1.

    Command path Kind Name Count Item
    gh issue view unknown_option --json 98 #4848
    gh pr view unknown_option --json 25 #4842
    gh issue view unknown_option --comments 10 #4848
    gh issue list unknown_option --search 9 #4848
    openspec unknown_command validate 3 -
    gh pr list unknown_option --json 2 #4842
    pr view unknown_option --json 2 #4842
    ci unknown_option --list 2 -
    others (1 each) gh pr create --head, gh issue view --jq, ci list, --format at the root, gh pr list --head, pr list --head, gh pr ready --undo, infra onboard --format 8 #4842, #4848

    --json on a view or list command is 127 of 159 (80 %). #4848 covers 118 records (74 %) and #4842 covers 31 (20 %). The order agrees with the transcript study of this tracker (--json 138, --search 53, --comments 42, --head/--base 41). The query: sum by (usage_command_path, usage_kind, usage_name, usage_caller) (count_over_time({service_name="devops-cli"} |= "cli_usage_error" [7d])).

  6. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Re-scope (owner direction of 2026-11-12). New title: feat(pr): pr view, list, checks, diff and status run gh.

    New scope

    The owner asked that a devops command that runs a CLI tool take the names of the tool and pass its arguments through (#5223, ADR 0026). This item adds no flag by hand. devops pr view, pr list, pr checks and pr diff become entries of the registry of #5223, and devops pr status is new. The key of each entry is the tool path gh pr <verb>. devops gh pr and devops pr are one app at two paths (an exception of ADR 0026), so each command works at both paths.

    Evidence

    Proposed Solution & Architectural Design

    • The prefixes are gh pr view, gh pr list, gh pr checks, gh pr diff and gh pr status, all read entries. pr list owns -L/--limit for its cost.
    • pr checks prints the view of gh and exits with the code of gh, which is 8 when a check is pending. It refuses --watch, -i/--interval and --fail-fast with exit 2 and names devops pr monitor, the paced watch. The required-check verdict stays in devops pr check-readiness and devops pr monitor. Premise check: list each document, skill or prompt that runs devops pr checks for the verdict, and change it to devops pr check-readiness.
    • The REST fallbacks of these commands go (for example _render_pr_view_fallback). On a GraphQL rate-limit refusal, the command prints gh's error and the reset-time line of feat(cli): tool commands pass unknown arguments to the tool #5223.
    • Add ("pr", "status") to CONST_GH_GRAPHQL_PORCELAIN_COMMANDS. Add a read-only MCP row ("pr", "status"), but not to the job roles: under the App identity, the pull requests of the viewer have no meaning. The rows of the four other commands get the allowlists of their gh read flags, with no -w/--web and with -L at most 100.
    • Premise check: record the GraphQL use of the App identity, as in feat(gh): gh issue view, list and status run gh #4848.

    Acceptance Criteria

    • devops pr view <n> --json number,title --jq .title prints the title. devops gh pr view <n> --json title also works.
    • devops pr list --head <branch> --json number prints a JSON array. devops pr list --search is:draft --base main gives both flags to gh.
    • devops pr view <n> --comments prints the comments.
    • devops pr status exits 0 on a branch with a pull request.
    • devops pr checks <n> --required exits with the code of gh. devops pr checks <n> --watch exits 2, names devops pr monitor and runs no gh (process stub).
    • devops pr diff <n> --name-only prints the file names.
    • --dry-run with each command prints the gh argv and sends 0 requests.

    Dependencies

    Merge first: #5223. Open the pull request after the pull request of #4848 merges, because both change the generated command reference. Do not open it while another open pull request changes commands/pr.py. Open items that change that file: #4708, #4782, #5112, #5144, #5178 and #2530.

  7. changed the title [-]feat(pr): add pr status and the gh json and filter flags[/-] [+]feat(pr): pr view, list, checks, diff and status run gh[/+] on Nov 12, 2026
  8. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Another occurrence on 2026-11-13 (review of #5434): an agent typed gh's flag on devops gh pr list.

    $ uv run devops gh pr list --search 'is:merged' --limit 2
    No such option: --search
    
  9. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches turned up no separate wrapper library, but the issue's own subject, the GitHub CLI (gh), already implements every command and flag the item asks to expose: pr view, pr list, pr checks, pr diff and pr status with --json, --jq, --comments, --search, --head and --base. The issue states the project already shells out to gh through run_gh, so this is flag pass-through to an existing, maintained tool rather than a new build.

    The repository already uses this tool.

    Tool: cli/cli (https://github.com/cli/cli)

    • License: MIT
    • Last activity: 2026-11-13
    • Maintained: yes

    Covers:

    • gh pr view takes --json <fields>, --jq/-q and --comments/-c
    • gh pr list takes --json, --jq, --search/-S, --head/-H and --base/-B
    • gh pr checks and gh pr diff exist and print gh's own output and exit codes
    • gh pr status reports the pull requests of the current branch
    • the project already passes pr view and pr list arguments to gh through run_gh, so the flags can be forwarded as they are

    Lacks:

    • the devops-level wiring: the new devops pr status command and the entries at both the devops pr and devops gh pr paths
    • the dry-run request plan that lists the gh argv for each command
    • the MCP allowlists per command and the refusal of --watch, -i/--interval and --fail-fast for pr checks
    • the required-check verdict, which stays in devops pr check-readiness and devops pr monitor
    • the pass-through registry of feat(cli): tool commands pass unknown arguments to the tool #5223 / ADR 0026, which must land before these entries exist

    Tools considered:

    Searches run:

    • gh pr status command GitHub CLI --json --jq, results: 5
    • gh pr view --json --jq --comments flags GitHub CLI manual, results: 5
    • "gh pr status" documentation, results: 5
    • cli.github.com manual gh pr view, results: 5
    • GitHub CLI pull request status json output gh, results: 5
    • gh pr list --search --head --base options, results: 5
    • cli/cli pkg/cmd/pr/status status.go, results: 5
    • github cli gh pr checks exit code 8 pending, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

  10. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 72e062d while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/commands/pr.py, docs/CLI_REFERENCE.md.

  11. added
    status/ready
    and removed
    status/new
    on Nov 15, 2026
  12. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 6786f1a (see proposed design in issue body).

  13. added
    status/in-progress
    and removed
    status/ready
    on Nov 25, 2026
  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 25, 2026
  15. removed
    status/in-review
    on Nov 25, 2026
  16. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor
  17. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 06:46 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/prsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions