Repository navigation
Description
Problem or Motivation
No devops command posts a comment. devops pr comment and devops gh pr comment failed 42 times (Claude 41 in 9 sessions, other tools 1), and devops gh issues comment failed 1 time. 39 of the 40 pr comment failures went on with devops gh api -X POST. In the Claude logs, devops gh api posted 959 issue comments in 29 sessions, with the body in a shell argument or in the -F body=@file form that agents must look up.
Tracker #4833, child 9. 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
Add devops pr comment <number> and devops gh issue comment <number>, as gh has them, with --body/-b, --body-file/-F (helper of item pr-body-file) and --repo/-R. Each sends one POST repos/:owner/:repo/issues/:n/comments through the paced devops gh session and prints the URL of the comment. --dry-run lists the request and sends nothing. Register the MCP tools only for the roles that may write (ai/mcp/roles.py) and the dry-run class (#3296). devops pr threads reply does not change.
Target Subsystem
SDLC, Git & PR Governance (devops pr and devops gh issue).
Existing Tool Considered
gh's pr comment and issue comment names and flags. The GitHub REST endpoint POST repos/:owner/:repo/issues/:n/comments through the paced devops gh session.
Acceptance Criteria
devops pr comment 1 --body-file c.md --dry-run lists 1 POST and sends 0 requests. A test with the session stub posts 1 comment and prints its URL, for both commands. --body with --body-file exits 2. The MCP tool listing holds the two tools only in the write roles.
Dependencies
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: The gh manual shows gh pr comment with -b/--body, -F/--body-file and inherited -R/--repo, and gh issue comment is the same command for issues, so the item only needs to wrap an existing, already-used tool.
Covers:
- Comment on a pull request or an issue
- Body from text or from a file
- Another repository through -R/--repo
- Prints the URL of the new comment
Lacks:
- Dry-run request plan that sends nothing
- Text-only MCP tools gated to the write role
- Exit 2 when both body flags are given
Proposed design
Problem statement
No devops command posts a comment. devops pr comment, devops gh pr comment and devops gh issue comment do not exist. The logs record 42 failed pr comment or gh pr comment calls and 1 failed gh issues comment call, and 39 of the 40 pr comment failures went on with devops gh api -X POST, with the body in a shell argument or in a file flag that agents must look up. The reply of 2026-11-26 shows the same failure on devops gh pr comment 92 -R dan-petty/devtools --body-file <file>. This item adds the comment commands as wrappers around gh pr comment and gh issue comment: one body source, one gh run, the comment URL on stdout, a dry run that prints the POST request and the gh command, and a text-only MCP tool in the write role.
Acceptance criteria
Requirement: gh command names and flags
The comment commands SHALL use gh's names and flags: devops pr comment and devops gh issue comment, with --body/-b, --body-file/-F, --repo/-R and --dry-run, and the command SHALL also be reachable as devops gh pr comment through the existing mount of the pr app.
Scenario: Help lists the gh names and flags
- WHEN A test runs
devops pr comment --help,devops gh pr comment --helpanddevops gh issue comment --helpwith CliRunner. - THEN Each command exits 0, and its output lists
--body,--body-file,--repoand--dry-run, with the short flags-b,-Fand-R.
Requirement: Body flags forwarded to gh
Each comment command SHALL forward --body and --body-file to gh in their long forms, and SHALL exit 2 with a bad-parameter error that names both flags when both are given.
Scenario: Two body sources are refused
- WHEN A test runs each comment command with
1 --body text --body-file c.md. - THEN Each command exits 2, prints an error that names
--bodyand--body-file, and the process stub records no gh invocation.
Requirement: Missing body source
Each comment command SHALL exit 2 when neither --body nor --body-file is given, because gh prompts for the comment text when no flag supplies a body.
Scenario: No body source is refused
- WHEN A test runs each comment command with
1only. - THEN Each command exits 2, prints an error that names
--bodyand--body-file, and the stub records no gh invocation.
Requirement: Body file path reaches gh unchanged
Each comment command SHALL pass the --body-file path to gh unchanged, so the command reads no file itself, a dry run included.
Scenario: A dry run with a missing body file reads no file
- WHEN A test runs
devops pr comment 1 --body-file missing.md --dry-runin a directory wheremissing.mddoes not exist, with the process stub. - THEN The command exits 0 and prints
gh pr comment 1 --body-file missing.md, and the stub records no gh invocation.
Requirement: Dry run lists one comment request
Each comment command SHALL print one POST repos/<owner>/<repo>/issues/<number>/comments request and its gh command, and SHALL run no gh, when --dry-run is set.
Scenario: The dry run prints the request and runs no gh
- WHEN A test runs each comment command with
1 --body-file c.md -R octo/repo --dry-runand the process stub, and the plan is rendered withdescribed=True. - THEN Each output holds
POST repos/octo/repo/issues/1/commentsand the gh commandgh pr comment 1 --body-file c.md --repo octo/repoorgh issue comment 1 --body-file c.md --repo octo/repo, and the stub records no gh invocation.
Requirement: Request-plan dry-run class
Each comment command SHALL declare the request-plan dry-run class.
Scenario: The dry-run ratchet passes
- WHEN
uv run pytest tests/invariants/test_dry_run_class_ratchet.py -n 0runs after the commands are added. - THEN The test passes, and
tests/fixtures/dry_run_gaps.jsonholds neither thepr commentpath nor thegh issue commentpath.
Requirement: Comment URL from gh
Each comment command SHALL run gh one time with max_retries=0 and SHALL print the URL that gh returns on stdout.
Scenario: A posted comment prints its URL
- WHEN A test runs each command with
1 --body text -R octo/repo, and the process stub returnshttps://github.com/octo/repo/pull/1#issuecomment-2for the pr commands andhttps://github.com/octo/repo/issues/1#issuecomment-3for the issue command. - THEN Each command prints its URL, and the stub records one gh invocation.
Requirement: Repo flag
Each comment command SHALL accept -R/--repo and SHALL pass --repo <owner/repo> to gh.
Scenario: Another repository is selected
- WHEN A test runs each command with
1 --body text -R octo/repo. - THEN The stub records
gh pr comment 1 --body text --repo octo/repofor the two pr paths andgh issue comment 1 --body text --repo octo/repofor the issue path.
Requirement: No second POST on a rate limit
A gh failure that names secondary rate limit SHALL NOT cause a second gh invocation.
Scenario: A rate-limit refusal is not retried
- WHEN The process stub fails with
secondary rate limitfor each comment command. - THEN The stub records one gh invocation for each command, and each command exits non-zero with the failure text.
Requirement: MCP comment tools publish text only
The MCP tools pr_comment and gh_issue_comment SHALL publish number, body, repo and dry_run only, with body required, and SHALL refuse a body_file argument before they run the command.
Scenario: A body-file parameter is refused
- WHEN An MCP caller sends
{"number": 1, "body": "text", "body_file": "/etc/hostname"}topr_commentand togh_issue_comment. - THEN Each call returns an error of kind
HALLUCINATED_PARAM, each tool schema holdsnumber,body,repoanddry_runand nobody_fileproperty, and the dispatcher runs no command.
Requirement: MCP write-role listing
The two tools SHALL be rows of CONST_MCP_EXPOSURE_TABLE with read_only false, and the MCP tool listing SHALL include them only in the write role ops.
Scenario: A job role lacks the comment tools
- WHEN A test calls
tools_for_rolefor the write roleopsand for each job role. - THEN The
opslisting holds both tools, each job role listing holds neither, and thepr commentandgh issue commentrows ofCONST_MCP_EXPOSURE_TABLEholdFalseforread_only.
Requirement: Generated docs hold the new commands
The generated command and tool docs SHALL list the new comment commands and tools.
Scenario: The generated docs match the commands
- WHEN
uv run devops docs generate --checkruns afteruv run devops docs generate --sync-readme. - THEN The check exits 0, which shows
docs/commands/pr.md,docs/commands/gh.md,docs/CLI_REFERENCE.mdanddocs/MCP_TOOLS.mdholddevops pr comment,devops gh issue comment,pr_commentandgh_issue_comment.
Existing Tool Considered
cli/cli (gh), MIT, last activity 2026-11-24, maintained, verdict in-use: the alternatives check of 2026-11-24 in the issue body records in its block what gh lacks. This item wraps gh pr comment and gh issue comment through the paced run_gh session and builds no comment mechanism, no body-file reader and no URL builder.
Key questions
- Do the comment commands run gh, or send the REST POST themselves?: Run gh through
run_gh. gh holds the commands, the flags, the body-file read, the repository selection and the comment URL.devops pralready wraps gh pr subcommands in_run_gh_pr_command, and that helper captures gh's output and drops it, so the comment command printsres.stdoutitself. (best practice) [sources: AGENTS.md:13, src/devops_cli/commands/pr.py:126, src/devops_cli/commands/gh.py:143, https://cli.github.com/manual/gh_pr_comment]- Chosen: Run gh through
run_gh. gh has the commands, the flags, the body-file read and the URL output, and the project already wraps gh pr subcommands. - Rejected: Send the REST POST in the command. It rebuilds the body-file read and the URL output that gh holds, and it needs the pr-body-file helper.
- Chosen: Run gh through
- Which command paths does the item add?:
devops pr commentanddevops gh issue comment, in gh's singular nouns.devops gh pr commentcomes with the first at no extra code, becausesrc/devops_cli/commands/gh.py:143mounts thedevops prapp atdevops gh pr, so the new command appears at both paths. The reply of 2026-11-26 shows an agent that typed thedevops gh pr commentform, and the issue counts failures of both pr names. (best practice) [sources: src/devops_cli/commands/gh.py:143, openspec/specs/gh-command-names/spec.md:9, CONTRIBUTING.md:213, https://cli.github.com/manual/gh_pr_comment]- Chosen: Two command definitions,
pr commentin pr.py andissue commentin gh.py. Theprapp is already mounted atdevops gh pr, so one definition serves both pr paths, and the issue group holds the issue command. - Rejected: Only
devops pr commentanddevops gh issue comment, with nodevops gh prform. The issue counts failures of thegh pr commentform, and the mount makes the third path free. - Rejected: A second handler for
devops gh pr commentin gh.py. The mount already exposes the command; a second handler would drift from the first. - Rejected: Plural
issuesgroup. gh writesissue, and the naming spec makes a plural group a usage error.
- Chosen: Two command definitions,
- How does a comment command avoid a second POST after a rate-limit refusal?: Pass
max_retries=0torun_gh. The default is 2, the loop runsmax_retries + 1times, and at the last attempt_handle_attempt_backoffholds the wait and returns False, so the command makes one attempt and reports the refusal. ADR 0006 records the same rule for the session: it does not send a lost write again. (best practice) [sources: src/devops_cli/github/rate_limiter.py:1898, src/devops_cli/github/rate_limiter.py:1849, src/devops_cli/github/rate_limiter.py:1805, docs/adr/0006-github-session-requests-go-through-gidgethub.md:17]- Chosen: Pass
max_retries=0. One gh invocation for each comment. A rate-limit refusal is reported and never retried. - Rejected: Keep the default retry count. A retry sends the same gh command again, so a write that GitHub applied before its answer was lost can post two comments.
- Chosen: Pass
- How do the comment commands take the body, and what happens when the body flags conflict or are missing?: Forward
--bodyand--body-fileto gh in their long forms, with--body-filea plain path (str | None, nottyper.FileText), so gh reads the file and a dry run reads no file and never waits on stdin. Exit 2 when both flags are given, as_resolve_body_inputrefuses them, and when neither is given, because gh then prompts for the comment text. (best practice) [sources: https://cli.github.com/manual/gh_pr_comment, src/devops_cli/commands/pr.py:1022, src/devops_cli/commands/pr.py:1024, openspec/changes/archive/2026-11-25-4852-pr-body-file/design.md:6]- Chosen: Forward both flags and exit 2 on a conflict or on no body. gh reads the file and reports its own error for a missing one, and the dry run reads no file because the path is passed through.
- Rejected: Read the file with
typer.FileTextand forward--body <text>.typer.FileTextwith_resolve_body_inputreads the file, or stdin for-, before the dry-run branch, so a dry run would read a file and--body-file - --dry-runwould block on stdin. - Rejected: Pass a missing body through to gh. gh then prompts for the comment text, and an agent that runs the command waits at the prompt.
- Does the session pace a comment as a write?: Yes.
is_write_gh_commandreads gh's group and verb and counts every verb that is not a read verb as a write, andcommentis not inCONST_GH_READ_VERBS, sorun_ghpaces the comment withmutation_min_interval. [sources: src/devops_cli/github/request_classifier.py:102, src/devops_cli/github/request_classifier.py:108, src/devops_cli/config/constants.py:3105] - Which parameters do the MCP comment tools publish?: Publish
number,body,repoanddry_runonly, and makebodyrequired. A_PATH_PARAM_RESTRICTIONSentry for("pr", "comment")and for("gh", "issue", "comment")drops every other option in_introspect_command_parameters, andnumberis an integer id of at least 1. Abody_fileargument fails the closed schema and maps toHALLUCINATED_PARAMbefore the dispatcher runs a command. (best practice) [sources: SECURITY.md:32, src/devops_cli/ai/mcp/generator.py:24, src/devops_cli/ai/mcp/generator.py:40, src/devops_cli/ai/mcp/generator.py:298, src/devops_cli/ai/mcp/generator.py:310, ARCHITECTURE.md:181, src/devops_cli/config/constants.py:545]- Chosen: Publish
number,body,repoanddry_run. A remote caller sends text only. It cannot name a local file or open an editor. - Rejected: Publish the full gh flag set. It exposes
--body-file,--editor,--web,--edit-lastand--create-if-noneto a remote caller.
- Chosen: Publish
- Which MCP roles hold the two comment tools?: The write role
opsonly.tools_for_rolereturns the whole catalogue forops, and for a job role it keeps only a tool that the role table names and that is read-only. Both comment commands write. (best practice) [sources: src/devops_cli/ai/mcp/roles.py:56, src/devops_cli/ai/mcp/roles.py:64, src/devops_cli/config/constants.py:302]- Chosen: The
opsrole only.opsis the write role. A job role keeps read-only tools only, so it gets no tool that posts. - Rejected: Every role. A read-only job role would hold a tool that writes to GitHub.
- Chosen: The
- Which dry-run class do the comment commands declare?:
request-plan. The spec puts each external-request command ofdevops prin that class and requires the command to print its planned requests, and ARCHITECTURE.md says a dry run prints the requests that a real run would send. The ratchet keeps each classified command out oftests/fixtures/dry_run_gaps.json. (best practice) [sources: openspec/specs/command-dry-run-class/spec.md:9, openspec/specs/command-dry-run-class/spec.md:98, openspec/specs/command-dry-run-class/spec.md:23, ARCHITECTURE.md:170, tests/invariants/test_dry_run_class_ratchet.py]- Chosen:
request-plan. The command sends an external request and has a dry run that prints the request and the gh command. - Rejected:
no-external-request. The command sends a POST. The class is for a command with no external request.
- Chosen:
- Which read-only mark do the two exposure-table rows carry?:
Falsefor both. The tool listing is generated fromCONST_MCP_EXPOSURE_TABLE, whose rows hold the command path, the timeout and the read-only mark, andtools_for_rolekeeps a job role's tool only when its read-only hint is true. A comment writes to GitHub, so the mark is false. (best practice) [sources: src/devops_cli/config/constants.py:298, src/devops_cli/config/constants.py:306, src/devops_cli/ai/mcp/roles.py:44, src/devops_cli/ai/mcp/roles.py:64]- Chosen:
read_onlyfalse. The command posts a comment, so no job role may hold its tool. - Rejected:
read_onlytrue. A read-only mark would put a writing tool in a job role, and the read-only write-option test fails on a read-only tool whose option writes.
- Chosen:
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(pr)scope of the title gives the scope.42 recorded agent failures show recurring friction, but no user is blocked and a workaround exists via 'devops gh api'.Agents fail 42 times without this command and must fall back to raw API calls with shell-argument bodies.Two new subcommands, flag parsing, dry-run, MCP role registration, and stub-based tests are required.Both add native devops CLI commands for GitHub PR operations, but #181 is the closed umbrella for the full suite while the candidate adds only the comment subcommands.devops-cli-service commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(pr)scope of the title gives the scope.The change removes frequent friction, but it is not critical and has merge dependencies.Agents tried a comment command 42 times and fell back to the gh api.Two commands need shared flags, a dry run, role-based MCP tools and tests.Both items concern an issue comment. 1658 changes the close command to record the reason and a comment. The candidate adds standalone comment commands.dan-petty commentedon Nov 12, 2026
Seen again on 2026-11-12:
devops gh pr comment 4966 --body-file <file>failed with "No such command 'comment'". The work-around wasdevops gh api repos/<owner>/<repo>/issues/<pr>/comments -X POST -F body=@<file>.dan-petty commentedon Nov 12, 2026
Re-scope (owner direction of 2026-11-12). New title:
feat(pr): pr comment and gh issue comment run gh.New scope
devops pr commentanddevops gh issue commentbecome write entries (#5223, ADR 0026) forgh pr commentandgh issue comment. This item builds no REST POST and no body-file helper. gh reads-b,-F/--body-fileand-(stdin) itself. gh also gives--edit-last,--delete-lastand--create-if-none.Evidence
pr commentfailed 42 times in 10 sessions.devops gh apiposted 959 comments in 29 sessions, with the-F body=@fileform.addComment. It costs 1 point, plus 5 points of the secondary limit of 2,000 a minute. 959 comments in 50 days is less than 1 an hour.Proposed Solution & Architectural Design
("pr", "comment")and("issue", "comment")toCONST_GH_GRAPHQL_PORCELAIN_COMMANDS.-b/--body,--edit-last,--create-if-noneand-R/--repo, and no-F/--body-file,-e/--editoror-w/--web. So an MCP caller gives the body as text and cannot send a local file.tools_for_rolekeeps the two tools out of the read-only roles.devops pr threads replydoes not change.Acceptance Criteria
devops pr comment 1 --body-file c.md --dry-runprintsgh pr comment 1 --body-file c.mdand sends 0 requests.secondary rate limit, gh still runs once.args["1", "-F", "/etc/hostname"]and["1", "-F/etc/hostname"]before a request.Dependencies
Merge first: #5223, #4852 (
commands/pr.py) and #5226 (commands/gh.py).[-]feat(pr): add pr comment and gh issue comment[/-][+]feat(pr): pr comment and gh issue comment run gh[/+]14 remaining items
devops-cli-service commentedon Nov 25, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
dan-petty commentedon Nov 26, 2026
Evidence of 2026-11-26:
devops gh pr comment 92 -R dan-petty/devtools --body-file <file>stopped and nameddevops gh api repos/{owner}/{repo}/issues/<n>/comments -X POST -F body=@<file>as the way. Six pull request comments of one session used that API form.devops-cli-service commentedon Nov 26, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.238.0 (#7615)
devops-cli-service commentedon Nov 28, 2026
Released in v0.238.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.238.0
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 18:38 UTC