Allow user to create rules with improved Starlark support

Open 💬 3 comments Opened Mar 19, 2026 by hktonylee
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What variant of Codex are you using?

CLI

What feature would you like to see?

Currently the rules only support prefix_rule which is very limiting because it only matches the whole literal. There were multiple issues before and the solution would be to improve the rules engine (say, https://github.com/openai/codex/issues/11298, https://github.com/openai/codex/issues/8537, https://github.com/openai/codex/issues/13175 and probably more)

Personally, I am using codex to handle some ops command calls. And in lot of cases (>80% of the time), the commands are just differed from each other a little bit. Let's say, cat xxx | head -5 and cat xxx | head -6. However, due to how the prefix_rule is implemented, codex will ask for approval for each of these variants.

<img width="1239" height="203" alt="Image" src="https://github.com/user-attachments/assets/eb397e1c-90d6-43dc-bd2b-85d0737dfb3e" />

( I need to approve for different file and message each time :-( )

For projects that requires mixed use of kubectl and bash, it is very typical for user to review and approve 5-10 very similar commands for each message that the user sends. The non-stop approval steps are actually not safe (or dangerous) because people will get tired and approve something that should not be approved.

Since the rules are using Starlark syntax. I would propose to create another kind of rule, called general_rule(), which accepts a custom Starlark function to approve / reject. For example,

def my_rules(args):
  return args[0] == "super-cli"

def is_inline_shell_script(func):
  def _inner(args):
    return args[0] in ("bash", "zsh") and args[1] == "-c" and func(args[2:])
  return _inner

general_rule(predicate=my_rules, decision="allow")
general_rule(predicate=is_inline_shell_script(my_rules), decision="allow")

This can allow user to leverage the community (or AI) to build better rule handling system. Let's say, people can implement rules to handle && and || shell conditions - by implementing a shell script parser and intersection of nested rules.

Additional information

_No response_

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 5 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #13502

Powered by Codex Action

ehendrix23 · 4 months ago

Just in further support, I regulary have it wanting to run items like:

"/bin/zsh -lc \"QT_QPA_PLATFORM=offscreen uv run pytest -q tests/unit/codex.py\"" 

But the only way for me currently to auto-approve running of uv run pytest like that is a rule allowing "/bin/zsh -lc".

alexander-zuev · 1 month ago

Please support positional wildcards in rules. Monorepos need to allow pnpm --filter <any-package> test|build|lint without also allowing deploy or migration scripts, e.g. ["pnpm", "--filter", ANY, one_of("test", "build", "lint")].