Add a way to output the `--dry-run` flag as a JSON · Issue #11025 · cli/cli · GitHub
Skip to content

Add a way to output the --dry-run flag as a JSON #11025

Open

Description

@Furlanetto-Dev

Describe the feature or problem you’d like to solve

It would be great if I could run something like

gh pr create --dry-run --json

and get the output as a json.

This feature would help a lot when creating libraries that wrap the gh cli project.

Proposed solution

I've yet to look at the source code, but I guess that the json creation part has already been done (since I suppose that github uses JSON for its API)

Activity

  1. BagToad commented on May 26, 2025

    @BagToad
    Member

    👋 Hey @seujorgenochurras

    This feature would help a lot when creating libraries that wrap the gh cli project.

    Could you expand on this use case a bit please? 🙏 Do you have any links to public code where this feature might be helpful?

  2. Furlanetto-Dev commented on May 26, 2025

    @Furlanetto-Dev
    Author

    👋 Hey @seujorgenochurras

    This feature would help a lot when creating libraries that wrap the gh cli project.

    Could you expand on this use case a bit please? 🙏 Do you have any links to public code where this feature might be helpful?

    I'm creating an extension where I want to send my PR data to an AI so the user can tell the AI to do stuff such as changing the body of the PR, changing its title and so on.

    I could do a lot of things to solve this problem like running the git commands to get the info I need or letting gh create the pr as a draft and then using the API to get it as JSON and edit the PR as needed.

    But I believe that if the gh cli had this option to run dry and return as JSON, it would be easier.

    I also believe that if I wanted to create a library that wraps some of the gh cli functionality it would be easier to run every prompt as dry and getting the result as json.

  3. changed the title [-]Add a way to output the --dry-run flag as a JSON[/-] [+]Add a way to output the `--dry-run` flag as a JSON[/+] on May 27, 2025
  4. added
    gh-prrelating to the gh pr command
    needs-productAn issue that requires prioritization considerations
    on Jun 18, 2025
  5. andyfeller commented on Jun 18, 2025

    @andyfeller
    Contributor

    @seujorgenochurras : I love hearing stories like this, seeing how our community is building extensions! ❤

    I'm creating an extension where I want to send my PR data to an AI so the user can tell the AI to do stuff such as changing the body of the PR, changing its title and so on.

    I could do a lot of things to solve this problem like running the git commands to get the info I need or letting gh create the pr as a draft and then using the API to get it as JSON and edit the PR as needed.

    But I believe that if the gh cli had this option to run dry and return as JSON, it would be easier.

    I also believe that if I wanted to create a library that wraps some of the gh cli functionality it would be easier to run every prompt as dry and getting the result as json.

    Personally, I'm interested in exploring if/how gh might expose commands and extensions as tools and resources via MCP for other tools to use, which would be no small feat.

    Recently, the github/github-mcp-server project announced public preview of remote GitHub MCP server. I haven't explored how much PR information is exposed as resources and what tools are exposed for interacting with them, but this might be an option using something like mark3labs/mcp-go module.

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

    enhancementa request to improve CLIgh-prrelating to the gh pr commandneeds-productAn issue that requires prioritization considerationsneeds-triageneeds to be reviewed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions