Skip to content

feat(gh): gh issue view, list and status run gh #4848

Open

Description

@dan-petty

Problem or Motivation

devops gh issues view has only --repo, and devops gh issues list has no search. Agents typed gh's flags: --search on issues list and devops gh search 44 times (Claude 19, other tools 25 in 23 sessions), --comments on issues view and gh issues comments 30 times, --json on issues view and list 15 times, and --body-file on issues create 3 times. The fallback is large: in the Claude logs alone, devops gh api sent 2,197 GET issues/:n/comments in 27 sessions and 1,984 GET search/issues in 32 sessions.

Tracker #4833, child 7. 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

After the rename, give devops gh issue view --comments/-c (reads issues/:n/comments through the paced REST session, all pages), --json <fields> with gh's field names (number, title, body, state, stateReason, labels, assignees, milestone, author, comments, createdAt, updatedAt, closedAt, url) and --jq/-q. Give devops gh issue list --search/-S (GitHub search syntax through search/issues, with the repository and is:issue added), --json and --jq. Give devops gh issue create --body-file/-F with the helper of item pr-body-file. These commands read through the REST session, not gh, so --jq needs a jq engine: use the maintained jq package on PyPI (BSD-2-Clause bindings to libjq) after a premise check of its wheels and license; write no filter code. Every flag goes into the dry-run request plan.

Target Subsystem

SDLC, Git & PR Governance (devops gh issue).

Existing Tool Considered

gh's flag names and the GitHub REST search API. For --jq on commands that read through the REST session: the maintained jq package on PyPI (BSD-2-Clause bindings to libjq), after a premise check of its wheels and license. No filter code is written.

Acceptance Criteria

devops gh issue view <n> --comments prints each comment with author and date. devops gh issue view <n> --json title,labels prints JSON with only those keys, and --jq .title prints the title. An unknown field exits 2 and names the valid fields. devops gh issue list --search 'label:type/bug' --json number prints a JSON array of open issues of this repository only. devops gh issue create --body-file f.md --dry-run lists the request with the file text. --dry-run sends 0 requests for each flag.

Dependencies

Merge first: #4835, child 8 of #4833.

Source: #4833

Alternatives check of 2026-11-21: in-use.
The repository already uses this tool.
Tool: cli/cli (https://github.com/cli/cli), MIT, last activity 2026-11-20, maintained.
Reason: Searches found no alternative tool: gh itself carries --comments, --json/--jq, --search/-S and --body-file/-F, so passing each flag through covers the whole need, and the repository already runs gh for GitHub reads.

Covers:

  • --comments reads every comment page on issue view
  • --json and --jq with gh's field names on view and list
  • --search/-S runs search/issues scoped to the repository
  • --body-file/-F on issue create, read by gh itself
  • gh issue status lists the viewer's issues

Lacks:

  • No devops dry-run argv plan or exit-code mapping
  • Each call is a process whose errors arrive as text
  • No MCP read-only allowlist or -L cap of 100
  • No label counts; those move to devops gh issue triage

Proposed design

Problem statement

Agents type gh's flags on devops gh issue view, list, status and create, and the commands refuse them. The fallback sends many REST requests. This change passes each argument to gh, prints gh's output and exit code, and keeps the label counts in devops gh issue triage.

Acceptance criteria

Requirement: View delegates to gh

devops gh issue view SHALL pass its number, --comments/-c, --json, --jq/-q, and --repo arguments to gh issue view and SHALL print gh's stdout, stderr, and exit code unchanged.

Scenario: View with comments

  • WHEN A stub gh records its argv, prints alice: looks good, and exits 0 for devops gh issue view 42 --comments.
  • THEN The command prints alice: looks good, exits 0, and the recorded argv holds gh issue view 42 --comments.

Requirement: JSON and jq go to gh

devops gh issue view MUST give --json, --jq/-q, and --template to gh issue view with no local JSON parsing or filter.

Scenario: JSON title with jq

  • WHEN A stub gh records its argv and prints x for devops gh issue view 42 --json title --jq .title.
  • THEN The command prints x, exits 0, and the recorded argv holds --json title --jq .title.

Requirement: Unknown JSON field

devops gh issue view SHALL exit with the exit code that gh issue view returns and SHALL print gh's error text unchanged when gh refuses an unknown --json field.

Scenario: Unknown field

  • WHEN The stub gh exits 1 with Unknown JSON field: "nosuchfield" and the valid field list.
  • THEN The command exits 1 and prints that text with the field list.

Requirement: List search

devops gh issue list SHALL pass --search/-S, --state, --json, --jq/-q, -L/--limit, and --repo to gh issue list and SHALL print gh's stdout, stderr, and exit code unchanged.

Scenario: Search with JSON

  • WHEN A stub gh prints [{"number":7}] for devops gh issue list --search 'label:type/bug' --json number.
  • THEN The command prints the array, exits 0, and the recorded argv holds the same search text.

Requirement: Create body file

devops gh issue create SHALL pass --body-file/-F and its other arguments to gh issue create and SHALL print gh's stdout, stderr, and exit code unchanged.

Scenario: Create with body file

  • WHEN A stub gh records the argv and prints a URL for devops gh issue create --title T --body-file f.md.
  • THEN The command prints the URL, exits 0, and the recorded argv holds --body-file followed by f.md.

Requirement: Status pass-through

devops gh issue status SHALL run gh issue status with its arguments and SHALL print gh's stdout, stderr, and exit code unchanged.

Scenario: Status pass-through

  • WHEN A stub gh prints the viewer's issue list for devops gh issue status.
  • THEN The command prints that text, exits 0, and the recorded argv holds gh issue status.

Requirement: Triage keeps the counts

devops gh issue triage SHALL print the open-issue counts by priority, type, and milestone, and the taxonomy audit.

Scenario: Counts by label

  • WHEN The stubbed store holds three open issues with type/bug and one with priority/p1.
  • THEN The output holds the count 3 for type/bug and 1 for priority/p1, with the audit lines.

Requirement: MCP triage resource and tool

The MCP resource resource://gh/issue/triage and the job-role tool gh_issue_triage MUST return the label counts.

Scenario: Job roles list the triage tool

  • WHEN A test lists the tools of each job role and reads the resource resource://gh/issue/triage.
  • THEN Each role holds gh_issue_triage and no gh_issue_status, and the resource returns the counts.

Requirement: Registry names triage

The roadmap tool registry MUST name gh_issue_triage in place of gh_issue_status.

Scenario: Registry lookup

  • WHEN A test calls tool_names for each job role.
  • THEN Each tuple holds gh_issue_triage and no gh_issue_status.

Requirement: MCP tools read only

The MCP tools gh_issue_view and gh_issue_list MUST publish read flags only, MUST refuse -w/--web, and gh_issue_list MUST refuse a limit above 100.

Scenario: Web flag and oversized limit refused

  • WHEN A caller asks gh_issue_view for --web, or gh_issue_list for -L 200.
  • THEN The tool refuses the call, names the allowed flags, and runs no gh process.

Requirement: Dry run prints argv

--dry-run MUST print the gh argv of each new view, list, status, and create form and MUST run no process.

Scenario: Dry run of list and create

  • WHEN The user runs devops gh issue list --search 'x' --dry-run and devops gh issue create --body-file f.md --dry-run.
  • THEN The first prints a gh issue list argv with --search x, the second prints a gh issue create argv with --body-file f.md, and no process starts.

Requirement: REST helpers leave the commands

The devops gh issue view, list, and status commands MUST invoke gh and MUST not call get_repository_issue, get_repository_issues, issues_list_requests, or issues_status_requests.

Scenario: No REST helper call

  • WHEN A test replaces the four helpers with functions that raise, runs each command with a stub gh, and the stub exits 0.
  • THEN Each command exits 0 and prints the stub output.

Requirement: Spec delta holds the pass-through

The change's gh-issues-view spec delta SHALL add the gh pass-through requirement and SHALL remove the pull-request refusal requirement.

Scenario: Delta validates

  • WHEN uv run devops openspec check validates the change.
  • THEN The command exits 0 and reports the gh-issues-view delta as valid.

Existing Tool Considered

cli/cli (gh) - alternatives verdict in-use; the repository already uses this tool. The alternatives check in the issue body records what gh covers and lacks. This change passes each argument to gh, prints the gh argv on --dry-run, adds the MCP read-only allowlist and -L cap of 100, passes gh's errors and exit codes, and keeps the label counts in devops gh issue triage.

Key questions

  • How do devops gh issue view, list, status and create get the new flags?: They pass each argument to the matching gh issue ... command and print gh's stdout, stderr and exit code unchanged. gh already carries the flags, so the project adds no local flag or filter code. (best practice) [sources: src/devops_cli/commands/gh.py, src/devops_cli/github/issues.py]
    • Chosen: Pass arguments to gh. gh covers the flags and the repository already uses gh for GitHub reads, so no flag logic stays in the project.
    • Rejected: Build the flags on the REST session with jq. It builds and keeps code that gh already covers.
  • What handles --jq on view and list?: gh runs --jq/-q itself. The pass-through adds no jq engine and no new dependency. (best practice) [sources: src/devops_cli/commands/gh.py]
    • Chosen: Use gh's own --jq. gh owns the filter and its error text, so no dependency joins the project.
    • Rejected: Add the jq PyPI package. It duplicates gh and adds a dependency that the pass-through does not need.
  • Where do the label counts that devops gh issue status prints today go?: devops gh issue triage prints the counts by priority, type, and milestone next to its taxonomy audit. (best practice) [sources: src/devops_cli/commands/gh.py, src/devops_cli/github/issues.py, src/devops_cli/roadmap/tools.py]
    • Chosen: devops gh issue triage. It already holds the taxonomy audit, so the counts join one command.
    • Rejected: Keep the counts in issue status. The name would not match gh's issue status, which lists the viewer's issues.
    • Rejected: A new devops gh issue counts. It adds a verb for a job that triage already does.
  • How do the MCP resource and job-role tool keep the counts?: The resource becomes resource://gh/issue/triage and the tool becomes gh_issue_triage; each runs devops gh issue triage. (best practice) [sources: src/devops_cli/ai/mcp/roles.py, src/devops_cli/roadmap/tools.py]
    • Chosen: Rename both to triage. One name for one job, and the counts keep a resource and a tool.
    • Rejected: Keep gh_issue_status and add triage. It gives two tools for one job.
    • Rejected: Keep the counts under the status name. The name would not match gh's issue status.
  • What limit does the MCP gh_issue_list tool give -L?: At most 100. The tool refuses a higher limit. (best practice) [sources: src/devops_cli/config/defaults.py]
    • Chosen: Cap -L at 100. One call then has a bounded page count, and 100 is the REST page size that the project already uses.
    • Rejected: No cap on -L. An unbounded page count costs the GraphQL budget.
  • Which command reads the file for --body-file on issue create?: gh issue create reads the file itself when the pass-through gives it --body-file/-F; the project adds no file reader. (best practice) [sources: src/devops_cli/commands/gh.py]
    • Chosen: Pass --body-file/-F to gh. gh reads the file and the project keeps no copy of the file logic.
    • Rejected: Read the file in devops and send the body. It builds code that gh already has and makes the dry run read a file it does not need.

Fit

Fits in one pull request.

Suspected block

A person must remove one edge of the dependency cycle #4848 -> #5232 -> #5228 -> #5227 -> #4855 -> #5226 -> #4848 before this item can start.

Dependencies

#4835

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/gh
    status/new
    value/medium
    effort/medium
    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/gh. The (gh) scope of the title gives the scope.
    • Priority: P2-Medium. Agent logs show 44+ mis-typed flag attempts, but a working fallback via gh api exists.
    • Value: Medium. It removes a repeated agent friction path and cuts roughly 4,000 redundant REST calls per session.
    • Effort: Medium. Five flags across three subcommands plus a jq engine integration and search-syntax parsing.
    • Related: feat(github): implement native devops cli functionality for gh operations and pr governance #181, which asks for a different change. Both add native devops gh CLI commands, but #181 covers PR operations while the candidate adds issue view, list, and create flags.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Seen again on 2026-11-12: uv run devops gh issues view 4688 --comments failed with "No such option: --comments". The agent read the comments through devops gh api repos/<owner>/<repo>/issues/4688/comments instead.

  6. added
    owner/agent
    and removed
    owner/agent
    on Nov 12, 2026
  7. 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])).

  8. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Re-scope (owner direction of 2026-11-12). New title: feat(gh): gh issue view, list 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 no longer builds gh's --json fields, --search and --comments over REST with the jq package. devops gh issue view, issue list and issue status become entries of the registry of #5223 for gh issue view, gh issue list and gh issue status. gh then gives each flag, each --json field, --jq, --template and the error for an unknown field.

    Evidence

    • Loki, 7 days to 2026-11-12: 109 of 159 usage errors are on devops gh issue view (--json 98, --comments 10, --jq 1), and 9 are gh issue list --search. Together they are 118 (74 %).
    • GraphQL: one gh issue view --json call is 1 point of 5,000 an hour. In 7 days, the highest hour of the agents had 1,333 GraphQL requests, and pr threads and the project reads reported at most 659 points in one hour. So the peak was between 27 % and about 40 % of the budget, with 0 GraphQL throttle waits.
    • The REST search budget of 30 a minute had 23 waits. gh issue list --search uses GraphQL search, so it takes load off REST search.
    • devops gh issue status prints counts by label. gh issue status lists the issues of the user. This is the same name with another meaning, and it gives no usage error.
    • Two Service consumers read the counts: the MCP resource resource://gh/issue/status (ai/mcp/server.py:197-203) and the job-role tool gh_issue_status (roadmap/tools.py, ai/mcp/roles.py). All three job roles hold that tool.

    Proposed Solution & Architectural Design

    • devops gh issue view|list|status <gh args> run gh issue view|list|status <gh args> through the runner of feat(cli): tool commands pass unknown arguments to the tool #5223. issue list owns -L/--limit for its cost.
    • The commands stop calling the REST read of issue view (github/issues.py) and the REST fallback of issue list. A function with no other caller goes. There is no 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.
    • The counts of the old issue status move to devops gh issue triage, next to its label audit. gh has no issue triage.
    • resource://gh/issue/status becomes resource://gh/issue/triage and runs devops gh issue triage. In roles.py and roadmap/tools.py, gh_issue_triage replaces gh_issue_status, with the purpose of the counts. gh_issue_status leaves the job roles, because under the App identity the issues of the viewer have no meaning.
    • Add ("issue", "status") to CONST_GH_GRAPHQL_PORCELAIN_COMMANDS. The MCP rows gh issue view and gh issue list stay read-only. Their allowlists hold the read flags of gh for each verb, with no -w/--web and with -L at most 100.
    • Change the spec gh-issues-view to the gh pass-through, and remove its requirement that refuses a pull request number.
    • Premise check, recorded in the proposal:
      • Run gh issue view <n>, gh issue view <n> --comments and gh issue view <pr number> with the devcontainer token. gh decides what happens with a pull request number.
      • Record the GraphQL use of the App identity. Job roadmap-service sent 1,113 GraphQL requests in the 7 days to 2026-11-12. Prometheus holds no devops_cli_* series of the mcp-server in that time. Find out if the server made no GitHub call or sends no metric. If it sends no metric, file a bug before this pull request merges.

    Acceptance Criteria

    • devops gh issue view <n> --json title,labels --jq .title prints the title.
    • devops gh issue view <n> --comments prints the comment view of gh.
    • devops gh issue view <n> --json nosuchfield exits 1 with the field list of gh.
    • devops gh issue list --search 'label:type/bug' --json number prints a JSON array.
    • devops gh issue status prints the output of gh. devops gh issue triage prints the label counts and the audit.
    • A test: the MCP resource resource://gh/issue/triage and the job-role tool gh_issue_triage return the counts.
    • When a stub gives a GraphQL rate-limit error, the command exits 1 and prints the reset-time line.
    • --dry-run with each form prints the gh argv and sends 0 requests.

    Dependencies

    Merge first: #5223. #4852 is no longer a dependency, because gh reads --body-file itself. Open the pull request after the pull request of #5223 merges, and not while another open pull request changes commands/gh.py.

  9. changed the title [-]feat(gh): add --comments, --search and --json to gh issue[/-] [+]feat(gh): gh issue view, list and status run gh[/+] on Nov 12, 2026
  10. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    One more occurrence on 2026-11-13: a reviewer agent ran uv run devops gh issue view 2530 --json title,body,state,labels --jq ... and got No such option: --json. The agent used devops gh api repos/<owner>/<repo>/issues/2530 --jq ... as the fallback.

  11. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Another case on 2026-11-13: a delivery agent ran uv run devops gh issue list --search "<query>" --state open --limit 8 to find a matching issue. Error: No such option: --search. The agent used devops gh api "search/issues?q=..." instead.

  12. 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 issue view.

    $ uv run devops gh issue view 5434 --json title,body,labels,state --jq ...
    No such option: --json
    

    The fallback was devops gh issue view 5434 (full text) and devops gh api repos/.../issues/5434/comments --jq ....

  13. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Evidence 2026-11-13: uv run devops gh issue list --search '<text> in:title,body' --state all --limit 8 failed with No such option: --search. The agent used devops gh api 'search/issues?q=repo:<owner>/<repo>+<text>' in its place.

  14. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    One more case of a missing gh flag (2026-11-13, review of PR #5563): devops gh pr list --search "4559 in:title" --limit 5 exits 2 with No such option: --search. gh has gh pr list --search/-S. devops gh issue list --search gives the same error, which this item already covers. The fallback was devops gh api "search/issues?q=...".

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

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches returned no alternative library, and the facts of the gh CLI repository show an open, maintained tool whose issue view, issue list and issue create commands already provide every flag this re-scoped issue asks for (--json, --jq/--template, --comments, --search/-S, --body-file/-F). The new scope is exactly to pass the arguments through to gh, so only the devops-side registry, dry-run and triage work remains.

    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 issue view gives --json with gh's field names, --jq/--template and --comments
    • gh issue list gives --search/-S with GitHub search syntax, --json, --jq and -L/--limit
    • gh issue create gives --body-file/-F and reads the file itself
    • gh reports the valid field names when --json names an unknown field
    • gh issue status exists as a verb

    Lacks:

    • Each call is a separate process, and gh's errors arrive as text
    • No --dry-run request plan; printing the gh argv and sending 0 requests still needs the pass-through registry of feat(cli): tool commands pass unknown arguments to the tool #5223
    • gh issue status lists the viewer's issues, not the label counts, so the counts, resource://gh/issue/triage and the job-role tool still need devops gh issue triage
    • gh is not a Python library: the devops-side registry entries, MCP allowlists and spec change remain project work

    Tools considered:

    Searches run:

    • gh issue view flags --json --jq --comments GitHub CLI manual, results: 5
    • gh issue list --search flag GitHub CLI manual, results: 5
    • cli.github.com manual gh issue view, results: 5
    • GitHub CLI gh issue list search option documentation, results: 5
    • GitHub CLI, results: 5
    • gh issue view, results: 5
    • cli/cli gh issue view json jq template, results: 5
    • gh issue view --comments --json --jq, results: 5
    • GitHub command line tool for issues and pull requests, 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.

  16. 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/gh.py.

  17. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 9f40f15 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.

  18. dan-petty commented on Nov 17, 2026

    @dan-petty
    OwnerAuthor

    Evidence of 2026-11-17: uv run devops gh issue view 5078 --comments stops with "No such option: --comments". gh issue view has --comments. A builder brief used the option. The agent read the comments with uv run devops gh api repos/dan-petty/devops-cli/issues/5078/comments instead.

  19. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at ba041d8 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.

  20. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  21. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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/mediumpriority/p2-mediumscope/ghsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions