Skip to content

feat(gh): gh issue create, edit, close and reopen run gh #5226

Done

Description

@dan-petty

Problem or Motivation

The owner asked on 2026-11-12 that a devops command that runs a CLI tool take the names of the tool and pass its arguments through (#5223, ADR 0026). The issue commands that write do not use the names of gh:

  • devops gh issue edit has --clear-milestone, which gh names --remove-milestone. It has -s/--state, but gh has no --state: gh uses issue close and issue reopen. It has no -F/--body-file, --add-assignee or --remove-assignee.
  • devops gh issue close needs --reason with completed|not-planned, and it takes --comment-file. gh takes -r/--reason with completed, not planned or duplicate (default completed), and -c/--comment <text>.
  • devops gh issue create has no -F/--body-file (3 failures in the feat(cli): track gh-parity names and usage-error capture #4833 study), -a/--assignee or -p/--project.
  • devops gh issue reopen does not exist.
  • Product text and documents name forms that gh does not have: src/devops_cli/roadmap/stores/store.py:111 tells the user to run devops gh issue edit {number} --state open, and docs/roadmap/intake.md:43 shows devops gh issue close <number> --reason not-planned.

The edit command reads the labels and the milestone number over REST and sends one PATCH (github/issues.py). gh does the same work by name.

Proposed Solution & Architectural Design

  • gh issue create, edit, close and reopen become write entries of the registry of feat(cli): tool commands pass unknown arguments to the tool #5223. Each write runs gh once.
  • issue close owns -r/--reason and refuses -r duplicate and --duplicate-of with exit 2, because a person closes duplicates (fix(roadmap): intake files and places a candidate that the model judges a duplicate, and names the possible original, instead of dropping or closing it #2223). Click parses each form, so -rduplicate and --reason=duplicate are refused too.
  • The close comment comes from -c <text>, as in gh. An agent gives a long comment as -c "$(cat <file>)". This replaces the rule of feat(gh): devops gh issues close records the close reason and a comment #2575 that the comment comes only from a file. docs/SDLC.md:75, docs/roadmap/intake.md:43 and the spec gh-issues-close change with it.
  • The error text of the roadmap store names devops gh issue reopen <n> (roadmap/stores/store.py:111).
  • When the issue is already closed, gh writes nothing and exits 0 with a warning on stderr (gh pkg/cmd/issue/close/close.go). ADR 0026 and the spec record this. A reason change of a closed issue uses devops gh api -X PATCH repos/<owner>/<repo>/issues/<n> -f state_reason=not_planned. devops sends no read before gh: gh already checks the state, and its warning reaches the caller unchanged.
  • Premise check: run with GH_DEBUG=api and record these facts:
    • gh issue close <pr number> refuses a pull request.
    • gh posts the -c comment before the close.
    • A close of a closed issue writes nothing.
    • When the close mutation gets a rate-limit refusal after the comment, devops does not run gh again, so the comment is posted once (process-stub test).
      If one of the first three is false, keep that rule with one REST read before gh, and record it in the proposal.
  • The commands stop calling the REST PATCH, the milestone lookup, the label merge and the milestone retry. A function with no other caller goes. The functions that the Service calls keep their paths.
  • Add ("issue", "edit"), ("issue", "close") and ("issue", "reopen") to CONST_GH_GRAPHQL_PORCELAIN_COMMANDS. Each write costs 1 GraphQL point and 5 points of the secondary limit.
  • No REST fallback for a write. On a rate-limit refusal, the command exits with the code of gh and prints the reset-time line.
  • The MCP rows gh issue create, edit and close are not read-only. Their allowlists hold no -F/--body-file, --recover, -e/--editor, -w/--web or -p/--project.

Target Subsystem

SDLC, Git & PR Governance (devops gh issue, src/devops_cli/github/issues.py, src/devops_cli/roadmap/stores/store.py).

Existing Tool Considered

The gh commands issue create, edit, close and reopen. They find milestones by title and labels by name, and they post the close comment. Nothing is built.

Acceptance Criteria

  • devops gh issue edit <n> --remove-milestone --add-label x --dry-run prints gh issue edit <n> --remove-milestone --add-label x and sends 0 requests.
  • devops gh issue close <n> -r 'not planned' -c 'Superseded by #<m>.' runs gh once (process stub). -r duplicate, -rduplicate and --reason=duplicate exit 2 before a request.
  • devops gh issue reopen <n> runs gh issue reopen <n>.
  • devops gh issue create -t '<title>' -F body.md -l type/bug --dry-run prints the argv.
  • MCP refuses a call of gh_issue_create with -F.
  • A test: the already-closed message of the roadmap store names devops gh issue reopen.
  • A fixture document with devops gh issue close 1 --reason not-planned fails devops docs check. devops docs check passes on the repository.

Dependencies

Merge first: #4848 (commands/gh.py, github/issues.py). Open the pull request after the pull request of #4852 merges, because both change the generated command reference.

Source: #4833

Alternatives check of 2026-11-29: in-use.
The repository already uses this tool.
Tool: cli/cli (https://github.com/cli/cli), MIT, last activity 2026-11-27, maintained.
Reason: The searches found GitHub CLI, whose issue create, edit, close and reopen commands already perform these writes with the requested flags; the remaining work is the devops pass-through wrapper, policy and tests.

Covers:

  • Create with body file, assignee, label, milestone and project
  • Edit labels, assignees, body file and remove milestone
  • Close with reason and comment, and reopen

Lacks:

  • No devops duplicate-reason refusal or dry-run preview
  • No pass-through registry, MCP allowlists or docs check
  • No GraphQL rate-limit classification for writes

Proposed design

Problem statement

The four devops gh issue write commands use flag names and state forms that gh does not have. create lacks -F/--body-file and -a/--assignee, edit takes --state and --clear-milestone, close takes --comment-file and --reason not-planned, and reopen is missing. Product text shows the old forms. The change runs gh once per write with the gh flags. It updates the docs check and the documents, and keeps the devops duplicate refusal. It builds no GitHub client.

Acceptance criteria

Requirement: Create passes gh flags

The devops gh issue create command SHALL pass -t/--title, -F/--body-file, -a/--assignee, -l/--label, -m/--milestone and -p/--project to one gh issue create call.

Scenario: Create dry-run argv

  • WHEN A test runs devops gh issue create -t 'A title' -F body.md -a octocat -l type/bug -m v1 -p Roadmap --dry-run with the process stub.
  • THEN The output is gh issue create -t 'A title' -F body.md -a octocat -l type/bug -m v1 -p Roadmap and the stub records no gh call.

Requirement: Create runs gh once

The devops gh issue create command SHALL run one gh issue create call and MUST send no REST request.

Scenario: Create with a body file

  • WHEN A test runs devops gh issue create -t 'A title' -F body.md -l type/bug with a process stub that returns an issue URL.
  • THEN The stub records one gh issue create -t 'A title' -F body.md -l type/bug call and the command sends no REST request.

Requirement: Edit passes gh names

The devops gh issue edit command SHALL run gh issue edit <n> once with the given --remove-milestone, --add-label, --add-assignee, --remove-assignee and -F/--body-file values.

Scenario: Edit dry-run argv

  • WHEN A test runs devops gh issue edit 7 --remove-milestone --add-label x --add-assignee octocat --remove-assignee hubot -F body.md --dry-run with the process stub.
  • THEN The output is gh issue edit 7 --remove-milestone --add-label x --add-assignee octocat --remove-assignee hubot -F body.md and the stub records no gh call and no REST request.

Requirement: Edit rejects removed flags

The devops gh issue edit command MUST NOT accept -s/--state or --clear-milestone.

Scenario: Edit rejects the removed flags

  • WHEN A test runs devops gh issue edit 7 --state open, devops gh issue edit 7 -s open and devops gh issue edit 7 --clear-milestone.
  • THEN Each run exits 2 with a usage error and the process stub records no gh call.

Requirement: Close refuses duplicate

The devops gh issue close command MUST refuse -r duplicate, -rduplicate, --reason=duplicate and --duplicate-of <n> with exit 2 before it runs gh.

Scenario: Duplicate reason forms

  • WHEN A test runs devops gh issue close 7 with -r duplicate, -rduplicate, --reason=duplicate and --duplicate-of 8.
  • THEN Each run exits 2 and the process stub records no gh call.

Requirement: Close runs gh with reason and comment

The devops gh issue close command SHALL run one gh call with -r and -c and MUST send no REST request before gh.

Scenario: Close not planned

  • WHEN A test runs devops gh issue close 7 -r 'not planned' -c 'Superseded by #8.' with the process stub.
  • THEN The stub records one gh issue close 7 -r 'not planned' -c 'Superseded by #8.' call and no REST request.

Requirement: Close defaults to completed

The devops gh issue close command SHALL pass -r completed when -r/--reason is not given.

Scenario: Close with no reason

  • WHEN A test runs devops gh issue close 7 with the process stub.
  • THEN The stub records one gh issue close 7 -r completed call and no REST request.

Requirement: Close rejects the old comment file

The devops gh issue close command MUST NOT accept --comment-file.

Scenario: Close rejects the comment file

  • WHEN A test runs devops gh issue close 7 --comment-file body.md.
  • THEN The run exits 2 with a usage error and the process stub records no gh call.

Requirement: Reopen runs gh

The devops gh issue reopen command SHALL run one gh issue reopen <n> call and MUST pass -c/--comment when given.

Scenario: Reopen with a comment

  • WHEN A test runs devops gh issue reopen 7 -c 'Reopening.' with the process stub.
  • THEN The stub records one gh issue reopen 7 -c 'Reopening.' call and no REST request.

Requirement: Close passes the gh exit code and error

The devops gh issue close command MUST pass the exit code and the standard error of gh through unchanged.

Scenario: Already closed issue

  • WHEN A test runs devops gh issue close 7 -r completed with a process stub that returns exit 0 and a warning on stderr.
  • THEN The command exits 0 and prints the warning unchanged, and the stub records one gh call.

Requirement: Rate-limit refusal keeps one comment

When the close mutation gets a rate-limit refusal after the comment, the command MUST NOT run gh again and MUST exit with the code of gh.

Scenario: Close rate limit after comment

  • WHEN A process-stub test makes gh issue close post the comment and then return a rate-limit refusal.
  • THEN The command exits with the code of gh and prints the reset-time line, and the stub records one gh call.

Requirement: Close passes the pull-request refusal

The devops gh issue close command MUST pass the gh refusal for a pull request and MUST NOT close a pull request.

Scenario: Close a pull request number

  • WHEN A test runs devops gh issue close 7 with a process stub that returns the gh error for a pull request.
  • THEN The command exits with the code of gh and prints the gh error unchanged, and the stub records one gh call.

Requirement: Store error names reopen

The already-closed message of the roadmap store MUST name devops gh issue reopen <n>.

Scenario: Roadmap store close refusal

  • WHEN A test closes an item whose state already changed and reads the error message.
  • THEN The message contains devops gh issue reopen 7 and holds no --state open form.

Requirement: Docs check reports an invalid choice

The docs command resolver MUST report a finding when a hand-written devops argv gives a value outside an option's choices.

Scenario: Invalid close reason

  • WHEN A test resolves devops gh issue close 1 --reason not-planned against the changed command tree.
  • THEN The finding names --reason and not-planned, and devops gh issue close 1 -r 'not planned' returns no finding.

Requirement: Repository docs pass the check

The repository documents SHALL show the gh close form and SHALL hold no --comment-file or --reason not-planned form.

Scenario: Repository docs check

  • WHEN The change updates docs/SDLC.md, docs/roadmap/intake.md and .agents/skills/devops-roadmap/SKILL.md and runs uv run devops docs check.
  • THEN The command exits 0 with no finding.

Requirement: GraphQL porcelain entries

CONST_GH_GRAPHQL_PORCELAIN_COMMANDS MUST hold ('issue', 'edit'), ('issue', 'close') and ('issue', 'reopen').

Scenario: Porcelain lookup

  • WHEN A test imports CONST_GH_GRAPHQL_PORCELAIN_COMMANDS.
  • THEN The constant holds each of the three tuples.

Requirement: MCP write rows are narrowed

The three MCP write rows MUST stay not read-only and MUST omit body_file, project, recover, editor and web from their schemas.

Scenario: MCP create with a body file

  • WHEN A test calls gh_issue_create with body_file='body.md'.
  • THEN The call returns an error, the process stub records no gh call, and the three schemas hold none of the omitted parameters.

Requirement: MCP close path removes the comment file

PATH_CONFINEMENTS MUST NOT name gh_issue_close.comment_file.

Scenario: MCP path-confinement audit

  • WHEN A test runs the path-confinement audit.
  • THEN The audit passes and PATH_CONFINEMENTS holds no gh_issue_close.comment_file entry.

Requirement: Write paths send no REST request

The four write commands MUST NOT call the REST PATCH, the milestone lookup, the label merge or the milestone retry.

Scenario: Write paths use no REST session

  • WHEN A test runs the four writes with the process stub and a GitHub session that raises on any request. The create stub returns the gh milestone error.
  • THEN The create command records one gh call and exits with the gh error. Each other command records one gh call. No command raises a session error.

Existing Tool Considered

The alternatives check of 2026-11-19 in the issue body gives cli/cli (gh), MIT, maintained, the verdict in-use. The block lists what the tool covers and lacks. The change uses gh for the four writes. It adds the devops duplicate refusal, the dry-run, the registry entry and the MCP allowlist that the block lists as lacking. It builds no GitHub client.

Key questions

  • Do the four devops gh issue writes run gh through the pass-through registry?: Yes. Each write builds the gh argv from its options and runs gh once through a write entry of REGISTRY in src/devops_cli/core/passthrough.py. No REST PATCH, milestone lookup, label merge or milestone retry runs before gh. (best practice) [sources: docs/adr/0037-tool-commands-mirror-and-pass-through-options.md:30, src/devops_cli/core/passthrough.py:117]
    • Chosen: Run gh once per command through the registry. ADR 0037 says a tool command takes the tool's names and options and passes the arguments through.
    • Rejected: Keep the REST PATCH. It uses flag names and state forms that gh does not have.
    • Rejected: Build a new GitHub API client. gh covers the four writes and is maintained.
  • Which close reason and comment forms does devops gh issue close accept?: -r/--reason takes completed (the default) and not planned. duplicate and --duplicate-of <n> exit 2 before gh. -c/--comment <text> carries the comment. --comment-file goes. A long comment uses -c "$(cat <file>)". (best practice) [sources: docs/SDLC.md:75, docs/roadmap/intake.md, src/devops_cli/commands/gh.py]
    • Chosen: Use the gh reason and comment forms and refuse duplicate. It matches gh, and the intake report leaves a possible duplicate to a person.
    • Rejected: Accept duplicate. A person decides a duplicate.
    • Rejected: Keep --comment-file. gh has no --comment-file, and -c "$(cat <file>)" covers a long comment.
  • How does a reason change of a closed issue work?: It uses two writes: devops gh issue reopen <n>, then devops gh issue close <n> -r 'not planned'. A PATCH of state_reason alone does not change the reason. The store refuses such a close and names reopen. (best practice) [sources: src/devops_cli/roadmap/stores/store.py:111, openspec/specs/gh-issues-close/spec.md:19, docs/adr/0037-tool-commands-mirror-and-pass-through-options.md:30]
    • Chosen: Reopen, then close with the reason. It changes the state and the reason. A failed second write leaves the issue open and visible.
    • Rejected: PATCH state_reason on the closed issue. GitHub ignores the reason unless the state changes.
    • Rejected: PATCH state and state_reason in one request. Sending the same closed state is no state change, so the reason stays ignored.
  • Should the write commands count as GraphQL porcelain?: Yes. Add ('issue', 'edit'), ('issue', 'close') and ('issue', 'reopen') to CONST_GH_GRAPHQL_PORCELAIN_COMMANDS. The rate limiter reads this set to classify the GraphQL point cost. (best practice) [sources: src/devops_cli/config/constants.py:3319, src/devops_cli/github/rate_limiter.py]
    • Chosen: Add the three tuples. The rate limiter reads this set to classify the GraphQL point cost.
    • Rejected: Leave the set unchanged. The writes would use the wrong rate-limit class.
  • Should MCP expose the write flags?: Keep the three rows not read-only. Deny body_file, project, recover, editor and web in _PATH_PARAM_RESTRICTIONS. Remove gh_issue_close.comment_file from PATH_CONFINEMENTS. (best practice) [sources: src/devops_cli/ai/mcp/generator.py:41, src/devops_cli/ai/mcp/path_confinement.py:23]
    • Chosen: Narrow the allowlists. An MCP caller can write, but cannot open an editor, a browser, a project or a recovery flow.
    • Rejected: Keep the rows read-only. The commands write, and the table already marks them not read-only.
    • Rejected: Allow every gh flag. It gives an MCP caller interactive and project access and publishes a file path.
  • Which gh behavior does the close path rely on?: The close path relies on gh to refuse a pull request, to post the -c comment before the close, and to write nothing and warn on an already-closed issue. The change runs the issue's GH_DEBUG=api premise check on a pull-request number, an open issue and a closed issue. It records the request log in the change folder. If a premise fails, the close path adds one REST read before gh and the change records it. (best practice) [sources: docs/adr/0037-tool-commands-mirror-and-pass-through-options.md:30, openspec/specs/gh-issues-close/spec.md:19]
    • Chosen: Rely on gh and run the premise check. ADR 0037 passes the tool's behavior through, and the premise check shows any false assumption.
    • Rejected: Add one REST read before close. It costs a request and duplicates gh unless the premise check shows that a premise is false.
    • Rejected: Build a devops check. It is a second copy of a check that gh already makes.
  • Does devops docs check report an invalid choice in a document?: No today. CommandReferenceDefect holds unknown command, unknown option, unexpected argument and missing required only. The change adds a finding for an invalid choice, its message and the mapping for a bad parameter. The old --reason not-planned form then fails the check. (best practice) [sources: src/devops_cli/core/command_resolver.py:56, src/devops_cli/docs/markdown_argv_collector.py]
    • Chosen: Add a finding for an invalid choice. The issue requires the old --reason not-planned form to fail the docs check. The check catches every other invalid choice too.
    • Rejected: Keep the check as it is. An invalid enum value passes the check, so a document keeps a form that the command refuses at run time.
    • Rejected: Make --reason a free string. The check cannot see the value, so the old form still passes.
  • Which documents show the removed forms?: docs/SDLC.md, docs/roadmap/intake.md and .agents/skills/devops-roadmap/SKILL.md with its tracked .claude and .kilocode copies. The skill file falls in the hand-written class, which the docs check resolves. [sources: docs/SDLC.md:75, docs/roadmap/intake.md, .agents/skills/devops-roadmap/SKILL.md, src/devops_cli/docs/markdown_argv_collector.py]
  • Does devops gh issue create accept -F/--body-file now?: No. The command declares --title, -b/--body, -m/--milestone, -l/--label and -R/--repo only. create_issue_args builds --title and --body. A run with --body-file stops with No such option: --body-file (Possible options: --body). [sources: src/devops_cli/commands/gh.py, src/devops_cli/github/issues.py]
  • Which dependencies remain?: feat(gh): gh issue view, list and status run gh #4848 only. The change of feat(pr): pr create, edit, close and ready pass gh arguments #4852 is archived, and pr_edit confines body_file. feat(cli): tool commands pass unknown arguments to the tool #5223 is the parent tracker, and an open tracker holds back no item. [sources: openspec/changes/archive/2026-11-25-4852-pr-body-file/proposal.md, src/devops_cli/ai/mcp/path_confinement.py, AGENTS.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4848

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/gh
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 90a3d2a 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, src/devops_cli/github/issues.py, docs/commands/gh.md.

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

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (6)

    Tools considered:

    Searches run:

    • gh CLI issue close --reason --comment --duplicate-of manual, results: 5
    • open source command line tool create edit close GitHub issues alternative to gh, results: 5
    • gh issue edit --remove-milestone --add-assignee flags, results: 5
    • cli.github.com manual gh_issue_close, results: 5
    • GitHub CLI cli/cli issue create edit close reopen, results: 5
    • "gh issue create" body-file assignee project flags documentation, results: 5

    Sources:

  7. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

  9. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor

    Evidence of 2026-11-26: devops gh issue create -R dan-petty/acp --title ... --body-file <file> stopped with No such option: --body-file (Possible options: --body). gh issue create has --body-file. The issue was then created with devops gh api repos/dan-petty/acp/issues -X POST -F body=@<file>.

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

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies and Watched files in the section Proposed design of the body.

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-29 05:10 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/mediumpriority/p2-mediumscope/ghsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions