Skip to content

Codex Usage for Beginners

Last updated:2026-08-12· 15 min read

🚀 Quick access

  • ChatGPT Domestic:Open entry↗
  • Mirror site:Open mirror↗
  • Official ChatGPT:chatgpt.com ↗

Codex Usage for Beginners

Last updated: 2026-08-12

Introduction

This guide assumes you completed Codex Install & Setup and want to turn agent programming from “trying it out” into a daily habit.

Codex is OpenAI’s coding agent for CLI, IDE extensions, or Codex Web. Below focuses on CLI; prompts work the same in IDE. Commands and subcommands follow the current Codex CLI reference and ChatGPT release.

Week one for beginners: suggested pace

DayTask typeGoal
Day 1Read-onlyHave Codex explain an unfamiliar module—no file writes
Days 2–3Test fixFix one failing test; human-review the diff
Days 4–5Small refactorLimit to one directory; keep behavior unchanged
Days 6–7Real bugfixTrack first-pass rate and lines you edited manually

Do not start with “rewrite the auth module”—tasks you can verify in 30 minutes build trust.

Session start: write an executable brief

Output quality depends on clear task boundaries. Each session, cover four items:

ElementWhat to include
GoalOne sentence plus failure stack or file paths
EnvironmentLanguage version, package manager, test framework
ConstraintsDirectories off limits, no new dependencies
AcceptanceConcrete test command or lint rule

Workflow 1: fix a failing test

The `coupon discount` case in `tests/checkout.test.ts` is failing.
Please: 1) read the full stack trace and related source; 2) find root cause; 3) propose a minimal patch;
4) explain how to verify locally with `pnpm test checkout`.
Do not change files unrelated to coupon; do not guess env vars I did not provide.

Rhythm:

  1. Start codex at project root.
  2. Keep default approval policy and confirm each file edit and test command.
  3. After the model proposes a patch, run tests locally; on failure paste full stderr and ask for “fixes based on logs only.”

Workflow 2: small-scope refactor

Refactoring requires unchanged behavior. Green the relevant tests before changing structure.

Unify all date formatting in `src/orders/` to ISO8601 strings.
Requirements:
1) modify only files under `src/orders/`;
2) keep exported function signatures unchanged;
3) list affected tests and give `pnpm test orders`;
4) one logical change per commit for easier review.
PhaseYour job
BeforeConfirm related tests are green
DuringLimit directory scope; reject unrelated diffs
AfterRun tests + lint + typecheck; human diff review

Workflow 3: understand an unfamiliar module

I'm a new developer. In ~400 words explain `packages/auth/`—responsibilities,
entry files, public API, and main dependencies; name 3 files I should read first.
Do not modify any files; mark uncertain points as "needs verification."

Use the output as onboarding notes, then drill into single files. Pair with the evidence–hypothesis–verify structure in the DeepSeek coding guide for faster reading.

CLI, IDE, and cloud: which form?

FormBest forNotes
CLITerminal users, codex exec scriptingRestrict permissions in CI
IDE extensionInline edits, visual diffsShares config.toml with CLI
Codex WebNo local env, light tasksRepo access and sandbox may differ from local

Common combo: IDE inline completion for single functions, Codex for cross-file tasks and tests. Like Claude Code, Codex excels at “read repo + run commands” loops.

Non-interactive mode: codex exec

To embed Codex in scripts or CI, use non-interactive mode (non-interactive docs). Principles:

  • Use read-only or minimal write sandbox in CI.
  • Never auto-merge to main without human review in pipelines.
  • Keep API keys separate from ChatGPT login; secrets via env or a secret manager.

Prompt habits: make the agent auditable

Bad habitBetter
“Fix the bug”Attach stack trace, repro steps, expected vs actual
“Refactor this”Specify directory, forbidden changes, acceptance test command
“You decide”List must-haves and must-nots

Ask the model to label uncertainty and “plan before execute” to cut silent wrong fixes.

Working with Claude Code / Copilot

  • Copilot / Cursor inline: faster for single-file, line-level edits.
  • Codex: more systematic for cross-file work, tests, architecture explanation.
  • Claude Code: Anthropic’s agent counterpart—compare workflows in the Claude Code guide.

You need not pick one—inline completion for functions, Codex for integration tests and doc updates is a common efficient mix.

Regional access and model backends

By default Codex uses OpenAI models and ChatGPT accounts. To switch the backend to DeepSeek for cost or Chinese comment quality, see Configure DeepSeek in Codex.

For browser-only trials, try the DeepSeek V4 domestic entry or AI Chat Studio mirror—agent workflows still require local API and config setup.

Frequently asked questions

What size for the first task?

Prefer tasks verifiable in 30 minutes: one failing test, single-file bug, read-only module explanation.

Codex changed many unrelated files?

Run git checkout -- immediately, tighten directory constraints in the prompt, and check whether approval_policy was set to never. Use sandbox_mode = "read-only" for exploration if needed.

Command execution failed—how to debug?

Paste full terminal output (including exit code); ask “do not guess PATH or env—infer from logs only.” Reproduce the same command locally to separate environment vs patch issues.

Can Codex run on repos with secrets?

Only if you confirm .env and similar files are not indexed or uploaded; check company AI policy first. Never put API keys in prompts or Git.

How is this different from ChatGPT web for code?

Web ChatGPT cannot run tests or multi-file patches on your repo; Codex targets a repo-grounded dev loop. Complex architecture still needs human review before merge.

Official resources

Next reading

Action path

Today: complete a read-only “understand module” task in a practice repo. This week: fix a real bug and log first-pass rate and manual edit lines. Long term: add the three workflow prompts to team wiki and set command allowlists and approval policy for Codex.

Related