Skip to content

Codex CLI Tutorial

Now that Codex CLI is installed, let's set up a project workflow and learn the basics: interactive vs. one-shot usage, safe approvals, and practical prompt patterns. This guide relies on the official docs and repo notes; no "magic" project files are assumed.


What Codex CLI reads & where it stores settings

  • Project context: Codex reads whatever you explicitly show it (files you ask it to open, directory listings, diffs it proposes). There's no official, auto-loaded CODEX.md. If you want a project playbook, keep a normal doc (e.g., AGENTS.md or CONTRIBUTING.md) and tell Codex to open/follow it at the start of a session. ([GitHub][2])
  • User config: Preferences (model, approvals, MCP servers, etc.) live in ~/.codex/config.toml. You can edit this file or rely on in-session controls (like /approvals). ([GitHub][2])

Tip: Start sessions by asking Codex to read your project guide document explicitly (e.g., "Open CONTRIBUTING.md and follow its rules for this session"). This mirrors how the tool is designed to ingest context. ([GitHub][2])


Authentication (two supported paths)

  1. Sign in with ChatGPT (subscription login). Run controls
  • /context — inspect what Codex is using as context (files, notes, etc.) These controls reflect the current CLI UX described in the docs. ([OpenAI Developer][1])

B) One-shot prompts (fast checks)

bash
codex -p "List top-level files and summarize this repo"
codex -p "What's the main entry point and how do I run it?"
codex -p "Create docs/hello.txt with a one-line greeting"

Use this for quick reads/edits where a full REPL isn't necessary. (Features evolve quickly; always check the CLI page for the latest flags.) ([OpenAI Developer][1])


Beginner quick wins (that map to real capabilities)