Skip to content

This page was translated from the Korean original with AI and may contain errors.

Chapter 7. Using It in the Terminal — Checking Your Organizer with One Line of codex exec ​

Optional Read this when you need it. You can skip it and still follow the later chapters.

One-line summary: Codex CLI is Codex for the terminal. It reads AGENTS.md and skills from the folder where you run it. codex exec "task" runs once and exits, and it is read-only by default. It is similar to Claude Code's claude -p, except for this difference.

This chapter is based on the official Codex docs checked on November 1, 2026, and the results of running Codex CLI in the macOS terminal.[1] If you are new to the terminal, you can skip this chapter. We explained what the terminal is in Claude Code Chapter 10.

Installing and Getting Started ​

Here are the install commands from the official docs.[2]

bash
# macOS, Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh
powershell
# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

Here is the command broken into pieces.

  • curl -fsSL URL: Downloads the install script (a file that lists the installation steps) at that address. -fsSL is four options written together: "stop if there is an error, hide the progress display, still show errors, and follow the address if it has moved."
  • | (pipe): Passes the result of the command before it to the command after it.
  • sh: Runs the script it received.
  • Windows works the same way. irm downloads it, and iex runs it. -ExecutionPolicy ByPass lifts the script-running restriction just this once.

Before running the install command, make sure it matches the official docs (learn.chatgpt.com) character for character. That is because this command downloads a script from the internet and runs it right away.

Once the installation finishes, move to your organizer folder and type codex. On your first run, choose Sign in with ChatGPT.[3]

bash
cd ~/hello-ai-practice/organizer
codex

In the terminal, Codex treats the folder where you started it as the project for that chat.[4] cd replaces what you did with Choose project in the app.

Quick check

What must you check before running the Codex CLI install command in the terminal?

codex exec — Ask Once and Finish ​

codex exec runs once and finishes without opening the chat screen.[5] We asked it the same question from Claude Code Chapter 10.

bash
cd ~/hello-ai-practice/organizer
codex exec "Show me the list of files in the notes folder, and tell me in one line per file which template (from templates) each file used. Do not edit any files. Reply briefly as a table only."

Only the answer came out cleanly (full output: Chapter 7 codex exec output.txt).

notes fileTemplate used
study-2026-10-28-prompt-lecture.mdtemplates/study-notes.md
weekly-review-2026-10-26.mdtemplates/weekly-review.md
minutes-2026-10-27-weekly.mdtemplates/minutes.md

Source: Hands-on results from this guide (2026-11-01). Progress logs were discarded separately, leaving only the final answer.

codex exec sends progress updates and the final answer down different paths.[6]

  • Progress: Goes to the side channel on screen (stderr, standard error).
  • Final answer: Goes only to standard output (stdout, standard out).

This difference is useful when you want the result in a file. For example, try typing codex exec "…" > result.md. > is a symbol that means "put the standard output in this file instead of on the screen." Then only the progress passes by on the screen, and only the final answer is saved in result.md. If a file with the same name already exists, > erases its contents and writes it anew. So pick a new name you have not used before.

codex exec is read-only by default. To let it edit files, add --sandbox workspace-write.[7] We also ran the exercises in Chapters 2, 3, and 5 of this guide with this option.

bash
codex exec --sandbox workspace-write '$weekly-review'

codex exec works by setting permissions in advance before running.[8] In the Chapter 5 exercise of this guide, when writing to the .agents folder was blocked, Codex could not ask for permission and simply stopped. For tasks that need permission prompts, it is easier to use the app or interactive codex.

There are also risky options that turn off both the sandbox and approvals, but do not use them for organizing notes.

Options from older posts and risky options (click to expand)

The --full-auto option you might see in older posts is no longer supported.[9] There is also an option like --dangerously-bypass-approvals-and-sandbox that turns off both the sandbox and approvals[10], but you do not need it for organizing notes.

Quick check

You tried to have codex exec edit a file, but nothing changed. What is the most likely reason?

Commands Inside Interactive codex ​

When you open interactive mode with codex, you use commands that start with /.

CommandWhat it does
/permissionsChange permissions (the permissions menu in the app)
/importImport settings from Claude Code or Cursor
/resumeContinue a saved chat
/statusView chat details and remaining limits
/skillsView the list of skills

Source: Codex official docs[11][12][13][14][15]

To continue a chat from outside after closing interactive mode, type codex resume.[13:1]

/permissions and /import are terminal commands. In the app, use the permissions menu below the input box (Chapter 4) and the Import menu in Settings (Chapter 3).

Quick check

On the interactive Codex CLI screen, which command shows your session details and remaining usage limit?

Try It Yourself ​

  1. Check that the install command above matches the official docs, then install it (if you already have it, run codex --version).
  2. Move to your organizer folder and run the read-only codex exec question above.
  3. Open interactive mode with codex and type /status.
  4. Type $ or run /skills to check that the skill name from Chapter 5 appears.[15:1]

Up next: In Chapter 8, we will cover cost, data, and safety, and see how Codex handles a note with hidden instructions inside.

Summary ​

  • In the terminal, Codex treats the folder where you run it as the project and reads AGENTS.md and skills from that folder.
  • Check that the install command matches the official docs before running it.
  • codex exec runs once and finishes, and it is read-only by default. To allow edits, add --sandbox workspace-write.
  • codex exec runs with permissions set in advance. Use the app or interactive mode for tasks that need approval prompts.

Glossary ​

TermOne-line meaning
Codex CLICodex used in the terminal
codex execA mode that runs once and finishes
stdout / stderrStandard output / the side channel where progress and errors go

Finished this chapter?

Progress is saved only in this browser. See your progress on the full table of contents.

Next chapter: Chapter 8. Cost, Data, Safety, and Choosing Your Tool

References (15)
  1. The version this guide ran was Codex CLI 0.166.0. ↩︎

  2. Codex official docs, "Codex CLI". "curl -fsSL chatgpt.com | sh" / "powershell -ExecutionPolicy ByPass -c "irm chatgpt.com | iex"" learn.chatgpt.com (checked on 2026-11-01) ↩︎

  3. Codex official docs, "Codex CLI". "Open a project directory and run codex. The first time you run Codex, choose Sign in with ChatGPT or another available sign-in method." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  4. Codex official docs, "Projects and chats". "Codex CLI treats the directory where you start it as the project for the chat." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  5. Codex official docs, "Non-interactive mode". "Non-interactive mode lets you run Codex from scripts (for example, continuous integration (CI) jobs) without opening the interactive TUI." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  6. Codex official docs, "Non-interactive mode". "While codex exec runs, Codex streams progress to stderr and prints only the final agent message to stdout." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  7. Codex official docs, "Non-interactive mode". "By default, codex exec runs in a read-only sandbox." / "Allow edits: codex exec --sandbox workspace-write "<task>"" learn.chatgpt.com (checked on 2026-11-01) ↩︎

  8. Codex official docs, "Non-interactive mode". "Run with explicit, pre-set sandbox and approval settings." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  9. Codex official docs, "Non-interactive mode". "--full-auto is no longer supported." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  10. Codex official docs, "Agent approvals & security". "--dangerously-bypass-approvals-and-sandbox (alias: --yolo)" learn.chatgpt.com (checked on 2026-11-01) ↩︎

  11. Codex official docs, "Permissions". "In the CLI, enter /permissions." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  12. Codex official docs, "Import from another agent". "Start a local Codex CLI session and type /import." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  13. Codex official docs, "Projects and chats". "Use /resume while Codex is open, or run codex resume, to continue a saved chat." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  14. Codex official docs, "Pricing". "If you want to see your remaining limits during an active Codex CLI session, you can use /status." learn.chatgpt.com (checked on 2026-11-01) ↩︎

  15. Codex official docs, "Build skills". "In Codex CLI or the IDE extension, run /skills or type $ to mention a skill." learn.chatgpt.com (checked on 2026-11-01) ↩︎