Repository navigation
Open
Description
Description
This house believes that a lot of gh usage and growth is being driven by agentic software and over time, this is only likely to continue increasing. Since we do not have client side telemetry, it's not possible to say this with certainty, but internal signals, looking around at the current agentic environment, and direct requests leads me to this conclusion.
This issue serves as a starting point for this exploration. We have no agreed upon direction here, and the following list is just a personal brain dump of different ways we might approach answering the questions:
- How much
ghusage is driven by agents? - Is it worth investing in improving
ghfor agents? - What are the best opportunities for improving
ghfor agents?
Some ideas:
- Start a discussion on
cli/clifor users to leave feedback - Add client side telemetry to
gh, for example, inspecting environment variables likeCLAUDECODE - Add client side telemetry to
copilotCLI (or VS Code) when it tries to invokegh - Partner with third party agentic software providers to understand how we can make
ghbetter for them - Use agentic software to fuzzily explore the
ghinterface for opportunities (e.g. desire paths) - Produce evals for sets of expected first class workflows (e.g. create a PR, make sure the tests are passing)
- Explore how other CLIs are treating agents as first class consumers
- Check in on agentic communities (e.g. discords) and request feedback
- Look at how publicly available agentic system prompts use
gh(some caution needed here since we don't want this to cause a clean room issue withcopilot) - Explore cases in which agents prefer to use the GitHub MCP server over
gh
Reacted by Toby Padilla, Masahiro Wakame, Eldrick Wega, eitsupi, Mike Cantrell, Chris Romp, Dennis Schridde, David Kort, Sean Knight, Lucas JAHIER and 4 more
Reacted by Melissa Xie, Chris Romp, baseappnet, Jeff Schumacher and Manuel Fuchs
Reacted by Melissa Xie
Metadata
Metadata
Assignees
Labels
No labels
Activity
toby commentedon Jan 23, 2026
Might be worth experimenting with Skills, here's one from the community: https://github.com/github/awesome-copilot/tree/main/skills/gh-cli
babakks commentedon Jan 23, 2026
To add to the list, this is something that I've been thinking about for the past months:
I can imagine at times agetns will need to inspect the available commands that
ghprovides. I'm not talking about help docs, but a machine readable data structure (e.g. in JSON) to expose available commands and flags/options. Such a data structure can basically serve agents similar to OpenAPI/Swagger specs (often served over/swagger.jsonendpoint for API inspection).I'm not going into details now, though. But this can even be an innovation that we can make public/reusable for others to use.
williammartin commentedon Jan 24, 2026
Potentially something like https://fig.io/docs/getting-started
BagToad commentedon Feb 6, 2026
Frequently I have agents messing up complex multi-line output for things like opening a PR:
I don't have a proposed solution for this, but it's a pain point that keeps coming up. Maybe it's the model's fault for not properly escaping quotes all the time.
PabloLION commentedon Feb 8, 2026
Use case: agents need scoped file reading without
gh apiCoding agents (Claude Code, Copilot, etc.) frequently need to read single files from remote repos — checking issue templates, reading upstream docs, comparing implementations. Today the only
ghoption is:gh api repos/{owner}/{repo}/contents/PATHThe problem:
gh apiis a raw API passthrough. The same command that reads a file can also delete repos, modify org settings, or merge PRs. Agent permission systems (like Claude Code's) match commands by pattern — they cannot distinguish a read-onlygh apicall from a destructive one. This forces a choice:gh api— unsafe, gives agents unrestricted API accessgh apicall — constant interruptions for simple readsraw.githubusercontent.com— only works for public repos, bypassesghentirelyA scoped subcommand like
gh repo catorgh cpwould solve this. Permission systems could auto-approve it while keepinggh apirestricted.Prior art:
extension-ideamislav/gh-cp— extension by @mislavMohamedElashri/gh-cp— community versionSince
mislav/gh-cpalready exists and is maintained by a GitHub engineer, promoting it (or its functionality) to a core command seems low-effort and high-impact for agent workflows.williammartin commentedon Feb 16, 2026
Had an internal report that
copilotreally would have found sub-issue support useful.williammartin commentedon Feb 24, 2026
@meowgorithm suggested that we add
gh skillthat outputs a skill for usingghthat we own and eval.EvanBoyle commentedon Feb 26, 2026
Linking some feedback from @Jarred-Sumner via twitter: https://x.com/jarredsumner/status/2025306979812642974
ewega commentedon Feb 28, 2026
I like what the playwright CLI team did: https://github.com/microsoft/playwright-cli?tab=readme-ov-file#playwright-cli
williammartin commentedon Mar 5, 2026
Cross linking #12839
williammartin commentedon Mar 12, 2026
Cross linking #12912
maxbeizer commentedon Mar 15, 2026
Output Optimization for Agent Consumers
Most of the discussion here has focused on discoverability (schema, skills) and safety (fork defaults, permission both critical. I want to add another angle: output optimization for token efficiency)
Ben Rigby's recent post captures the pain pagination metadata gets thrown away, output is decoration-heavy, and agents pay for tokens they can't use. After digging through the codebase, here are concrete opportunities:
The Problem
--include+ parseLinkheaders to discover more pages exist\x1b[32mOPEN\x1b[0mwraps every colored even with--json#prefixes, "about 2 hours ago"--jsonrequires field enumeration--helpcallProposed:
--aiFlag (orGH_AI=1)A global flag that optimizes all command output for LLM/agent consumption:
1. Auto-include pagination metadata in response body
{ "_pagination": { "count": 30, "hasNextPage": true, "total": 247 }, "items": [ ... ] }This is the single highest-impact change. Agents shouldn't need to manage it's exactly the problem Ben spent a week debugging in the MCP server
2. Strip ANSI formatting unconditionally
Follow the existing
IOStreams.SetColorEnabled(false)path. The plumbing is already there.3. Compact default field sets
When
--aiis used without explicit--jsonfield selection, use curated minimal fields:number, title, state, author.login, baseRefName, headRefName, createdAt, urlnumber, title, state, author.login, labels, createdAt, urlAgents can still use
--ai --json field1,field2for explicit fields.4. Structured JSON help
{ "command": "gh pr list", "description": "List pull requests in a repository", "flags": { "--state": { "type": "enum", "values": ["open","closed","merged","all"], "default": "open" }, "--limit": { "type": "int", "default": 30 } }, "available_json_fields": ["number", "title", "state", "author", "..."] }This connects to @babakks's schema idea but scoped to per-command help rather than a full CLI schema.
5. Deterministic JSON errors
{ "error": true, "message": "Resource not found", "code": "NOT_FOUND" }No prose, no suggestions, no color-coded messages. Relates to @BagToad's point about agents struggling with complex output.
Estimated Impact
--ai(est.)gh pr list(30 PRs, TTY)gh pr list --json(all fields)gh pr list --helpOpen Questions
--aiis concise but--machineor--agentmight be clearer.--machinehas precedent in other CLIs.--aiautomatically fetch all pages up to--limitand return one response? Eliminates pagination entirely at cost of larger responses.--aishould compose with--json,--jq,-- not replace them.template--ai=v1) to allow evolution?This complements the schema/discoverability work discussed above. Schema tells agents what commands exist; output optimization ensures the responses are efficient to consume.
labudis commentedon Mar 16, 2026
Linking an initiative in the same theme with the focus of making Issues and Projects a first class experience for Copilot CLI/agent work: https://github.com/github/planning-tracking/issues/2548
BagToad commentedon Mar 16, 2026
Hey @maxbeizer 👋 Thanks for the thorough write-up - lots of good thinking here.
TL;DR - A couple of the ideas here are worth exploring (deterministic JSON errors, exposing
totalCountin--json), but several of the pain points described are already solved by existingghbehaviour that agents get by default, so I think there are some misunderstandings to clarify.What's already working for agents today
A few of the pain points in this comment assume agents see TTY output, but I don't think that is correct. When
ghoutput is piped (which is how I believe agents invoke it),ghautomatically switches to a machine-friendly mode:ANSI only appears if
GH_FORCE_TTY=1orCLICOLOR_FORCEis set - which would be agent misconfiguration, or perhaps an intentional choice, but I'm not sure why someone would choose to do that. Maybe there's a use-case we don't know about.So to clarify: the "~40% decoration" figure and "12-15 wasted bytes per element" appear to have been measured against TTY output, which agents don't receive. I'd encourage re-running those estimates against piped output to get accurate baselines.
What I think is worth exploring
Deterministic JSON errors. Today, errors are always plain text to stderr, even when
--jsonis active:$ gh api repos/cli/cli/pulls/999999 {"message":"Not Found","documentation_url":"...","status":"404"} # stdout (API body) gh: Not Found (HTTP 404) # stderr (prose)A structured error format when
--jsonmight be an improvement, but I don't think I understand the value off the extra JSON structure vs something simple like ensuringghalways prints the full help docs on a command failure when invoked by an agent.Exposing
totalCountin--jsonoutput - this is one of two pagination gaps. List commands auto-paginate via--limit, but the total count (e.g., "247 total PRs") is only shown in the TTY header. Including it in--jsonoutput would help agents know whether they've fetched everything. That said, wrapping the response in a{"_pagination": ..., "items": [...]}envelope would be a breaking change to the--jsoncontract - every consumer expecting an array would break, including--jqpipelines. I think we need to come up with some other ideas for this problem space; maybe we could forcibly include a_totalCountfield in the existing objects when--jsonis used by an agent.Nested field pagination in
--json- the other pagination gap isn't about list commands specifically. When you dogh pr view --json comments, the CLI internally paginates to fetch all comments (and reviews, statusCheckRollup, closingIssuesReferences). Butgh pr view --json filesor--json commitssilently truncates at 100 items - there's no preload pagination for those fields (filesfragment,commitsfragment, preload functions that exist). An agent viewing a large PR wouldn't know it's missing file changes. I think this really just alludes to broaderghreview process gaps.Structured JSON help - reasonable idea. This overlaps with the CLI schema discussion in #12912.
Concerns with the
--aiflag approachI think bundling five unrelated concerns (pagination, formatting, field defaults, help format, error format) into a single
--aiflag could be confusing. Each has different tradeoffs:NO_COLOR)--limit,--paginate), but nested field pagination has real gaps (files,commitstruncate silently at 100 items). Not sure what to do about that at the moment--json-aware rather than needing a separate flag. Even then, I'm not sure what value having a structured error would bring beyond just ensuring the full help docs are always printed on error when invoked by an agent. The full help docs include valuable things to agents like what fields are available for--json, which is often a point of confusion that isn't exposed to an agent right now unless they trigger a--helpflowThe token cost estimates in the table also seem to be based on TTY baselines, so the "savings" figures are likely overstated.
All that said, I want to like this idea of having a single "agent mode" flag that optimizes output for agents, but
ghalready has a comprehensive "automation output" design philosophy that I think we should look at a lot of this more from the angle of "what gaps currently exist in our automation/non-tty output?".maxbeizer commentedon Mar 16, 2026
Honestly, not surprised if this is indeed the case. As i was writing it and asking Copilot, that figure seemed suspiciously high.
This is a fair take. I think your point about five unrelated concerns rings true with me as well. Happy to discuss further if you'd like to chat about any of the points where improvements make sense
ChrisRomp commentedon Mar 23, 2026
Adding in that my agent uses GH CLI a lot to interact with CCR/review feedback, but ultimately has to call gh api with GraphQL calls. If there were tools in there to facilitate that it could be more deterministic.
williammartin commentedon May 12, 2026
@BagToad
Some agents (
copilot CLI,gemini) right now executeghwith a PTY attached, so they get the experience as if a human were typing at a terminal. Other agents (claude) execute without. Of course, sometimes agents know what they want and dogh <cmd> | <other cmd>in which case, the other command gets the piped form, and that would depend on what<other cmd>is doing with the stream.BagToad commentedon May 12, 2026
@williammartin I have had to recently tell my Copilot CLI to use
GH_FORCE_TTY=trueto get prompting to work when I want it to - maybe something is changing in that area?I've noticed some weird behavior in general where I get loading spinners but "prompting not possible" messages in Copilot CLI.
It's like interactivity is on but not on fully. I haven't looked into it deeply.
tolomea commentedon Jul 13, 2026
@PabloLION
A broader take would be a readonly slice of the api so something like
gh api-read