Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Codex CLI lets you inspect, edit, and run code from a terminal. Install it using the current instructions for your operating system, open a repository and run codex for interactive work, or use codex exec for non-interactive scripts and CI. Start automation with the documented read-only sandbox and grant write access only when the job needs to change files.

What Codex CLI does

Codex CLI is a terminal workflow for working in a local repository: it can inspect code, make changes, run commands, and automate repeatable tasks. OpenAI’s Codex CLI guide covers installation, sign-in, and a first task, with links to the command reference, configuration, and automation guidance.

There are two main ways to use it. Run codex to work interactively in a project directory; run codex exec when a shell script or pipeline should provide a task and receive output without an interactive session.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Codex CLI and start a session

Installation depends on your operating system and package manager. The official quickstart presents options for macOS and Linux, Windows, npm, and Homebrew. For the displayed macOS/Linux standalone-installer path, it gives this command:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Use the matching tab and instructions on the official Codex CLI page for your environment. Installation commands and package instructions can change, so do not assume the macOS/Linux command applies to Windows or to every installation method.

  1. Open a terminal in the repository you want to work in.
  2. Run codex. On first use, the CLI prompts you to sign in using ChatGPT or another available method.
  3. Describe a bounded task, such as explaining part of the project, debugging a specific issue, or making one focused change.
  4. Review the proposed or completed work. Keep Git checkpoints before and after a task so you can inspect or revert changes.

Choose the right command for the job

Need Command or mode What it is for
Explore or change a repository through an interactive terminal session codex Starts the project-based interactive workflow.
Run a repeatable task in a shell, pipeline, pre-merge check, or scheduled job codex exec "task prompt" Runs non-interactively; progress is sent to stderr and the final response to stdout.
Check a CLI installation or environment problem codex doctor Diagnoses areas including installation, configuration, authentication, runtime, Git, and terminal setup.
Return to an earlier interactive session codex resume Resumes an interactive session.
Continue a non-interactive session codex exec resume --last or codex exec resume <session-id> Resumes the last execution or the specified session.

For exact syntax and available options, use the Codex CLI command reference. The resume form can take a session ID instead of --last when a workflow needs to continue a particular run.

Use codex exec in a script or CI job

The basic form is codex exec "task prompt". Give it a narrow, reviewable instruction: for example, ask it to inspect a change and report likely regressions, rather than issuing a vague request to improve the entire repository. In shell workflows, stdout can be captured, redirected, or piped to another tool; progress messages go to stderr. Add --ephemeral when the job should not persist session rollout files.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select the least access the task needs

The documented default sandbox for codex exec is read-only. If the job must edit files, explicitly use --sandbox workspace-write. The broader danger-full-access setting should be reserved for controlled environments, such as an isolated runner or container, where the job’s access is deliberately bounded. Choose permissions based on the task rather than making broad access the default.

Capture output for downstream tools

  • Plain final response: use stdout when a human or simple shell step can consume the result.
  • Event stream: codex exec --json emits JSON Lines. Events include thread and turn starts or completions, items, and errors; parse the event types your workflow needs.
  • Final response in a file: -o or --output-last-message writes the final message to a file.
  • Schema-constrained final response: use --output-schema when the final message must conform to a schema. Validate the output and handle command failures in your script rather than treating structured output as proof of success.

These options serve different needs: JSONL is an event stream, while the output-file and schema options concern the final response. Consult the official non-interactive mode guide for current option syntax and behavior.

Plan CI integration around credentials, permissions, and outputs

  1. Install for the runner. Follow the official installation instructions that match the runner’s operating system and package setup.
  2. Provide authentication securely. Follow the guide’s current CI authentication instructions and your CI provider’s secret-management mechanism. Do not put credentials in source code or expose them in logs.
  3. Keep the prompt and scope narrow. Specify the files, change, or check the job should address, and use the sandbox level required for that work.
  4. Choose how the job consumes results. Use stdout for a straightforward result, JSONL for event-aware automation, or a final output file or schema-constrained response when the workflow needs those formats.
  5. Handle failure and review. Make the surrounding job check command success and validate any output before using it to drive later steps.

OpenAI announced a GitHub Action for CI/CD on October 6, 2025, in its post, “Codex is now generally available.” That announcement establishes that OpenAI released an Action; it does not establish its current maintenance, Marketplace status, or terms. The same post describes installing and running codex exec in shell-based workflows, so the Action is not a prerequisite for using the CLI in CI.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Where the usage figures come from

In its October 6, 2025 announcement, OpenAI reported that more than 40 trillion GPT-5-Codex tokens had been served in three weeks, daily Codex usage had grown by more than 10 times since early August, and OpenAI engineers were merging 70% more pull requests each week. These are OpenAI-reported figures from that announcement, not independent benchmarks or current usage measurements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.