ResearchAudio

Instrument 14 / Codex automation

Build a codex exec --json command with an explicit Git check.

Generate one inspectable command for JSONL automation, ephemeral runs, constrained sandboxes, structured output, and the trusted-directory check.

Compose a bounded run

Make the target and output explicit.

The safe default keeps the Git repository check, uses a read-only sandbox, streams JSONL events, and avoids persisting session files.

Execution controls

Select only the flags the consumer of this run needs.

Three separate boundaries

Git check.
Confirms the command targets a repository unless deliberately skipped.

Sandbox.
Controls filesystem and command authority; it is independent of the Git check.

Output contract.
JSONL events, a final-message file, and a response schema solve different automation needs.

Current CLI contract

What each generated flag changes.

--json prints execution events as newline-delimited JSON. Parse one object per line instead of expecting a single JSON document.

--ephemeral runs without persisting session files. It does not change model or sandbox behavior.

--skip-git-repo-check allows execution outside a Git repository. Use it only when the working directory is already explicit and controlled.

--output-schema points to a JSON Schema for the final response. --output-last-message writes the last agent message to a file.

Codex exec guide

Fix the trusted-directory error without hiding the target.

The best fix is usually to run inside the intended repository. The skip flag is for deliberate non-Git automation, not a blanket trust setting.

Inspect the current OpenAI Codex exec source → Need project-doc settings? Build config.toml → Read the full Codex CLI technical guide →

What does codex exec --json output?

It streams Codex execution events to standard output as JSONL: one JSON object per line. This is useful for CI, logging, and event-driven automation.

How do I fix Not inside a trusted directory in Codex CLI?

Run Codex from the intended Git repository whenever possible. For a deliberate workflow outside Git, add --skip-git-repo-check and make the target directory unambiguous.

Does --skip-git-repo-check disable the Codex sandbox?

No. The flag only bypasses the Git-repository requirement. The sandbox and approval controls remain separate.

How do Codex output schema and last-message files differ?

--output-schema constrains the final response shape. --output-last-message saves the final agent message. --json separately streams the full event sequence.

Automation without folklore

Get the next sourced Codex workflow.

ResearchAudio turns changing AI tooling into practical, inspectable decisions for engineers and builders.