Skip to content

Use configured rules for VSCode extensions #9164

Closed

Description

@amit-mittal

What version of the VS Code extension are you using?

0.4.58

What subscription do you have?

Enterprise

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 24.4.0 arm64 arm

What issue are you seeing?

I have a rules file configured in my repo's rules folder as well as under $CODEX_HOME/rules, but none of them are being considered by the VSCode extension in the agent mode and it is still prompting me for the approved commands.

What steps can reproduce the bug?

  1. Create ~/.codex/rules/gh.rules or <repo-root>/.codex/rules/gh.rules with
prefix_rule(
    # The prefix to match.
    pattern = ["gh", "pr", "view"],

    # The action to take when Codex requests to run a matching command.
    decision = "approve",

    # Optional rationale for why this rule exists.
    justification = "Viewing PRs is allowed with approval",

    # `match` and `not_match` are optional "inline unit tests" where you can
    # provide examples of commands that should (or should not) match this rule.
    match = [
        "gh pr view 7888",
        "gh pr view --repo openai/codex",
        "gh pr view 7888 --json title,body,comments",
    ],
    not_match = [
        # Does not match because the `pattern` must be an exact prefix.
        "gh pr --repo openai/codex view 7888",
    ],
)
  1. Invoke this command from the extension, but still it will be prompted for approval.

What is the expected behavior?

Not prompt and automatically run the command

Additional information

No response

Activity

  1. added
    extension
    on Jan 13, 2026
  2. added
    bug
    sandbox
    on Jan 13, 2026
  3. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. etraut-openai commented on Jan 13, 2026

    @etraut-openai
    Contributor

    Rules need to be installed in the $CODEX_HOME/rules directory. If they're in your workspace directory, they will be ignored. Default sandbox policies allow the agent to write to your workspace, so supporting sandbox policy rules in that location is a security problem.

    You mentioned that you've tried placing the rules in your $CODEX_HOME/rules directory and they didn't work. Did you restart the extension after installing them?

    You can use the codex execpolicy check CLI command to test your rules.

  5. amit-mittal commented on Jan 13, 2026

    @amit-mittal
    Author

    Thanks @etraut-openai! I had restarted the extension, but looks like restarting the VS Code itself finally fixed it for me.

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

    bugextensionsandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions