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
CLI Schema - enforcing a security policy for AI agents #12912
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.
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.
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:
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.
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.
Activity
github-actions commentedon Mar 12, 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.
williammartin commentedon Mar 12, 2026
Have cross linked this to #12522 where a relevant comment was also made #12522 (comment)
mindburnlabs commentedon Mar 21, 2026
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:
Schema layer (what you're requesting): a machine-readable representation of
ghcommands 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.Execution boundary layer: a broker that intercepts every
ghinvocation, 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
ghuse 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.feat: 網を単純コマンド単位の帰属判定に再設計する(gates 0.3.0)