Skip to content

CLI Schema - enforcing a security policy for AI agents #12912

Open

Description

@dreddi

Describe the feature or problem you’d like to solve

I'd like to provide my sandboxed AI agent access to gh, but be able to enforce a security policy on which subcommands I allow, and which I disallow.

Proposed solution

I'd like the gh CLI schema to be easily machine-readable or CLI command lines to be convertible into 'request' objects, so I can write tooling that validates the commands we receive from the agent, and make a security decision before they are run.

Alternatives considered:

  • Enforcing security policy by proxying calls to gh and implementing validation of the command line using regex. This is fragile and easily gamed by a persistent agent loop.
  • Using the fine grained permissions provided by Github to enforce security policy: these are not fine grained enough to describe the security policy I want (e.g. allow pushing commits, but never force pushing or deleting branches).
  • github-mcp-server: It costs many tokens to keep this loaded due to the number of tools it provides, CLI tools are currently more context efficient. If that wasn't a problem, I'd implement a proxy in front of the MCP to parse the tool call requests, and apply an allow list before continuing.

How will it benefit CLI and its users?

This makes gh more useful for sandboxed full auto AI agents that don't have direct access to gh except through a broker. With these changes we can be more confident in granting the gh tool in a limited capacity, without the risk of catastrophic action being taken due to adversarial prompt injection, or simple misalignment.

Activity

  1. added
    enhancement
    on Mar 12, 2026
  2. github-actions commented on Mar 12, 2026

    @github-actions
    Contributor

    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 wanted Contributions 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.

  3. added
    needs-triage
    and removed
    needs-triage
    on Mar 12, 2026
  4. williammartin commented on Mar 12, 2026

    @williammartin
    Member

    Have cross linked this to #12522 where a relevant comment was also made #12522 (comment)

  5. mindburnlabs commented on Mar 21, 2026

    @mindburnlabs

    The broker pattern you're describing is exactly the right architecture, and the structural problem you've hit is real: regex over the CLI string is fragile, GitHub's token scopes are too coarse-grained, and the MCP proxy is too token-heavy for most use cases.

    The cleanest approach is to separate the concern into two layers:

    1. Schema layer (what you're requesting): a machine-readable representation of gh commands as structured request objects — including subcommand, flags, target ref, and operation type (read vs. write, safe vs. destructive). This lets a policy engine make decisions on structured data, not string patterns.

    2. Execution boundary layer: a broker that intercepts every gh invocation, deserializes it into that structured request, applies an allow/deny policy, and either proceeds or halts — fail-closed. The broker also emits a signed receipt per call so you have a proof graph of what the agent actually ran.

    This is the architecture HELM OSS implements for the general agent execution case: models propose tool calls, the execution kernel validates them against policy before dispatch, and every call is receipted. The pattern maps directly onto your gh use case as an adapter — the CLI schema you're asking for would feed directly into that validation layer.

    Worth looking at: https://github.com/Mindburn-Labs/helm-oss — the adapter pattern there is designed to be composable with any CLI tool, not just gh.

    Happy to discuss or contribute a gh-specific adapter/example if this is the direction the team wants to go.

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

    enhancementstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions