You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs: cover gh api mutation pitfalls in the gh skill #14701
Agents frequently mishandle gh api field flags when constructing mutations. Values starting with @ are treated as file references under -F/--field, typed literals are converted, and {owner}/{repo}/{branch} is expanded, while -f/--raw-field sends raw strings. This causes accidental file reads, wrong types, and failed bodies. The official skill's gh api section does not document the distinction or the --input escape hatch.
Acceptance Criteria
skills/gh/SKILL.md documents the difference between -f/--raw-field and -F/--field, including typed conversion and @file/@- expansion.
Clarifies placeholders {owner}, {repo}, {branch} behavior per flag.
Documents --input as the way to avoid `@) ambiguity.
Adds guidance to re-read the mutated object to verify changes.
Scope
Documentation only in skills/gh/SKILL.md. No CLI code changes.
Out of scope
General gh usage.
Changing gh api behavior itself.
Requesting maintainers add help wanted if this is accepted, so the accompanying PR can follow contribution rules.
Thanks for the detailed writeup! This reads as a clear, scoped documentation improvement for skills/gh/SKILL.md (clarifying -f/--raw-field vs -F/--field semantics, placeholder expansion, and --input), and there's already a linked PR (#14700) implementing it, so I'm suggesting enhancement.
For reference, the current gh api section in skills/gh/SKILL.md (at 819f972) doesn't yet cover the -f vs -F distinction, so the acceptance criteria look accurate and actionable.
Duplicate check: not a duplicate. #14199 is related (a CLI behavior change proposing a runtime warning when -f values start with @) but this issue is scoped purely to documentation, so they're complementary rather than duplicates.
No additional information needed from the reporter at this time — a maintainer can review and consider adding help wanted per the issue's request if the docs-only PR is accepted.
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the
help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
Agents have hit this in several sessions, so here is the field evidence plus one gap the current acceptance criteria do not name.
What happened. Two review-thread replies were posted with:
gh api -X POST "repos/<owner>/<repo>/pulls/<n>/comments/<comment-id>/replies" -f body=@/tmp/<file>.md
-f/--raw-field sends a static string, so both comments landed with the literal text @/tmp/<file>.md as the body, and both had to be deleted and reposted. Agents reach for -f body=@file because it reads like "body from file", so the skill is where that misreading has to be closed.
One addition to the acceptance criteria would close the loop. Name the typed-command path: gh issue comment and gh pr comment take --body-file, so posting a body from a file needs no gh api and no @ parsing at all. The current text mentions --body-file only next to the --attach rules, so an agent looking for how to post a file body does not find it.
Following up on the earlier field evidence with the rest of the cookbook. Beyond the -f/-F and @-file expansion cases this issue tracks, later sessions hit a few more gh api contract traps in the same mutation workflows. They are listed below together with the earlier ones, plus the filter used to separate genuine contract traps from one-off agent mistakes, in case they help when scoping the skills/gh/SKILL.md section (complementary to what #14700 already covers).
Cookbook: gh api Mutation & Parameter Traps
1. Passing File Bodies (-f vs -F vs --input)
The Pitfall: Passing -f [email protected] does not read the file; -f/--raw-field passes the literal text @file.md into the payload. On pull request or issue timelines, this silently posts the path string instead of the content.
Safe Alternatives:
Prefer typed commands when posting files: gh issue comment <n> --body-file <file> or gh pr comment <n> --body-file <file>.
In gh api, use -F body=@<file> to expand the file, or --input <file.json> for structured JSON payloads.
2. Ambiguity with Leading @ (Mentions)
The Pitfall: If a body string begins with an @mention (e.g. @username), passing -F body=@username causes gh to look for a local file named username and fail.
Safe Alternative: Use -f body="@username" for string literals, or pass the payload via --input.
3. Type Conversion Cuts Both Ways (-f vs -F)
The Pitfall: -F (typed field) magic-converts values, in both directions:
Certain GitHub REST parameters (such as in_reply_to on review comment creation) strictly require JSON integers. Passing -f in_reply_to=123 sends a JSON string ("123"), causing the API to reject the request with HTTP 422 Unprocessable Entity.
Conversely, inline text posted with -F loses its string type: a review-thread reply sent as -F body=123 arrives as the JSON number 123 instead of the text "123".
Safe Alternative: Match the flag to the value's required type: -F key=123 for numeric parameters, -f body="..." for inline literal text (including reply bodies), -F body=@<file> for file bodies, and --input <file.json> for structured payloads.
4. Endpoint Routing Asymmetries
The Pitfall: Intuitively trying to fetch a single review comment via repos/{owner}/{repo}/pulls/{n}/comments/{comment_id} returns HTTP 404 Not Found.
Safe Alternative: Single review comments are addressed at repos/{owner}/{repo}/pulls/comments/{comment_id} (no PR number in the path). Replying to a comment is addressed at POST repos/{owner}/{repo}/pulls/{n}/comments/{comment_id}/replies.
5. Post-Mutation Verification
Because mutations lack a dry-run flag and land immediately on public timelines, automated tooling should always perform a read-back check immediately after every mutation, split by operation:
After POST/PATCH/PUT: query the created or modified resource, assert it exists, the HTTP status indicates success, and the resulting body does not contain literal @<path> text.
After DELETE: assert absence instead — a follow-up query returns HTTP 404, or the deleted item no longer appears when listing the collection. (An existence check here would fail for every successful deletion.)
How These Traps Were Verified (Contract Quirks vs. Agent Errors)
A major risk when documenting CLI edge cases is feature creep—skills can quickly become an unmaintainable dumping ground for arbitrary user or agent mistakes.
To prevent this, every item in the cookbook above was required to pass an objective 3-Check Verification Gate:
API / CLI Contract Quirk vs. User Error:
If an issue is resolved by reading gh <cmd> --help (e.g., guessing --jobs instead of --json jobs, or sleeping instead of using --watch) or fixing basic shell syntax (unquoted pipes), it is an agent error and is strictly excluded.
Only discrepancies between intuitive expectations and the actual CLI/API contract (like -f not expanding @file, or pulls/comments/{id} vs pulls/{n}/comments/{id}) are eligible.
Empirical Specification & Live Verification:
Each endpoint path and parameter type was verified against GitHub's official OpenAPI description (github/rest-api-description) or confirmed via a live gh api -i probe (e.g. confirming that pulls/{n}/comments/{id} returns 404 while pulls/comments/{id} returns 200).
High Blast Radius:
Priority is given only to traps that cause silent payload corruption on public timelines (e.g., posting @/tmp/body.md) or immediate 422/404 failures.
Documenting these five points takes roughly 30 lines, and in our sessions that has been enough to keep agents and script authors clear of every mutation trap we have actually hit, without turning the section into a catch-all.
If any of this wording is useful, please lift it into the section or #14700 as-is.
changed the title [-]docs: clarify gh api -f vs -F and @-file expansion in the gh skill[/-][+]docs: cover gh api mutation pitfalls in the gh skill[/+]on Oct 25, 2026
Activity
cli-triage commentedon Oct 15, 2026
Thanks for the detailed writeup! This reads as a clear, scoped documentation improvement for
skills/gh/SKILL.md(clarifying-f/--raw-fieldvs-F/--fieldsemantics, placeholder expansion, and--input), and there's already a linked PR (#14700) implementing it, so I'm suggestingenhancement.For reference, the current
gh apisection inskills/gh/SKILL.md(at 819f972) doesn't yet cover the-fvs-Fdistinction, so the acceptance criteria look accurate and actionable.Duplicate check: not a duplicate. #14199 is related (a CLI behavior change proposing a runtime warning when
-fvalues start with@) but this issue is scoped purely to documentation, so they're complementary rather than duplicates.No additional information needed from the reporter at this time — a maintainer can review and consider adding
help wantedper the issue's request if the docs-only PR is accepted.github-actions commentedon Oct 15, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
MatiasOlivera commentedon Oct 22, 2026
Agents have hit this in several sessions, so here is the field evidence plus one gap the current acceptance criteria do not name.
What happened. Two review-thread replies were posted with:
-f/--raw-fieldsends a static string, so both comments landed with the literal text@/tmp/<file>.mdas the body, and both had to be deleted and reposted. Agents reach for-f body=@filebecause it reads like "body from file", so the skill is where that misreading has to be closed.One addition to the acceptance criteria would close the loop. Name the typed-command path:
gh issue commentandgh pr commenttake--body-file, so posting a body from a file needs nogh apiand no@parsing at all. The current text mentions--body-fileonly next to the--attachrules, so an agent looking for how to post a file body does not find it.MatiasOlivera commentedon Oct 25, 2026
Following up on the earlier field evidence with the rest of the cookbook. Beyond the
-f/-Fand@-file expansion cases this issue tracks, later sessions hit a few moregh apicontract traps in the same mutation workflows. They are listed below together with the earlier ones, plus the filter used to separate genuine contract traps from one-off agent mistakes, in case they help when scoping theskills/gh/SKILL.mdsection (complementary to what #14700 already covers).Cookbook:
gh apiMutation & Parameter Traps1. Passing File Bodies (
-fvs-Fvs--input)-f [email protected]does not read the file;-f/--raw-fieldpasses the literal text@file.mdinto the payload. On pull request or issue timelines, this silently posts the path string instead of the content.gh issue comment <n> --body-file <file>orgh pr comment <n> --body-file <file>.gh api, use-F body=@<file>to expand the file, or--input <file.json>for structured JSON payloads.2. Ambiguity with Leading
@(Mentions)@mention(e.g.@username), passing-F body=@usernamecausesghto look for a local file namedusernameand fail.-f body="@username"for string literals, or pass the payload via--input.3. Type Conversion Cuts Both Ways (
-fvs-F)-F(typed field) magic-converts values, in both directions:in_reply_toon review comment creation) strictly require JSON integers. Passing-f in_reply_to=123sends a JSON string ("123"), causing the API to reject the request withHTTP 422 Unprocessable Entity.-Floses its string type: a review-thread reply sent as-F body=123arrives as the JSON number123instead of the text"123".-F key=123for numeric parameters,-f body="..."for inline literal text (including reply bodies),-F body=@<file>for file bodies, and--input <file.json>for structured payloads.4. Endpoint Routing Asymmetries
repos/{owner}/{repo}/pulls/{n}/comments/{comment_id}returnsHTTP 404 Not Found.repos/{owner}/{repo}/pulls/comments/{comment_id}(no PR number in the path). Replying to a comment is addressed atPOST repos/{owner}/{repo}/pulls/{n}/comments/{comment_id}/replies.5. Post-Mutation Verification
POST/PATCH/PUT: query the created or modified resource, assert it exists, the HTTP status indicates success, and the resultingbodydoes not contain literal@<path>text.DELETE: assert absence instead — a follow-up query returnsHTTP 404, or the deleted item no longer appears when listing the collection. (An existence check here would fail for every successful deletion.)How These Traps Were Verified (Contract Quirks vs. Agent Errors)
A major risk when documenting CLI edge cases is feature creep—skills can quickly become an unmaintainable dumping ground for arbitrary user or agent mistakes.
To prevent this, every item in the cookbook above was required to pass an objective 3-Check Verification Gate:
gh <cmd> --help(e.g., guessing--jobsinstead of--json jobs, or sleeping instead of using--watch) or fixing basic shell syntax (unquoted pipes), it is an agent error and is strictly excluded.-fnot expanding@file, orpulls/comments/{id}vspulls/{n}/comments/{id}) are eligible.github/rest-api-description) or confirmed via a livegh api -iprobe (e.g. confirming thatpulls/{n}/comments/{id}returns 404 whilepulls/comments/{id}returns 200).@/tmp/body.md) or immediate 422/404 failures.Documenting these five points takes roughly 30 lines, and in our sessions that has been enough to keep agents and script authors clear of every mutation trap we have actually hit, without turning the section into a catch-all.
If any of this wording is useful, please lift it into the section or #14700 as-is.
[-]docs: clarify gh api -f vs -F and @-file expansion in the gh skill[/-][+]docs: cover gh api mutation pitfalls in the gh skill[/+]