The Codex message Not inside a trusted directory and --skip-git-repo-check was not specified. appears when codex exec starts outside a Git working tree, so the task stops before Codex can read files or run commands.
Current OpenAI Codex documentation treats this as the non-interactive repository safeguard for codex exec. That safeguard is separate from project trust for .codex/config.toml, which only controls whether project-scoped configuration layers load.
The safest fix is to launch codex exec from the repository that should own the task and keep the repository check enabled. Use --skip-git-repo-check only for intentional scratch directories, because it removes the check that helps prevent work in the wrong folder.
$ codex exec "Return OK." Not inside a trusted directory and --skip-git-repo-check was not specified.
That output confirms the run stopped at the repository safeguard before the task started.
$ git rev-parse --show-toplevel fatal: not a git repository (or any of the parent directories): .git
If git rev-parse prints a repository root instead, the failing shell is already inside a repo and the error came from a different launch location.
$ cd /home/user/projects/example-repo
Start the command from the repository itself. Current CLI behavior can still stop at the same safeguard when -C points to a repo but the launch directory is outside Git.
$ git rev-parse --show-toplevel /home/user/projects/example-repo
The printed path should be the repository root or a parent of the current working directory.
$ codex exec "Return OK." OK
The exact prompt can differ. The decisive success signal is that Codex starts normally instead of returning the trusted-directory error.