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 ↗

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
| Day | Task type | Goal |
|---|---|---|
| Day 1 | Read-only | Have Codex explain an unfamiliar module—no file writes |
| Days 2–3 | Test fix | Fix one failing test; human-review the diff |
| Days 4–5 | Small refactor | Limit to one directory; keep behavior unchanged |
| Days 6–7 | Real bugfix | Track 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:
| Element | What to include |
|---|---|
| Goal | One sentence plus failure stack or file paths |
| Environment | Language version, package manager, test framework |
| Constraints | Directories off limits, no new dependencies |
| Acceptance | Concrete 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:
- Start
codexat project root. - Keep default approval policy and confirm each file edit and test command.
- 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.
| Phase | Your job |
|---|---|
| Before | Confirm related tests are green |
| During | Limit directory scope; reject unrelated diffs |
| After | Run 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?
| Form | Best for | Notes |
|---|---|---|
| CLI | Terminal users, codex exec scripting | Restrict permissions in CI |
| IDE extension | Inline edits, visual diffs | Shares config.toml with CLI |
| Codex Web | No local env, light tasks | Repo 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 habit | Better |
|---|---|
| “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
- Codex Install & Setup
- Configure DeepSeek in Codex
- DeepSeek coding guide
- GPT-5.6 prompts and agent workflows
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
Codex Install & Setup
What OpenAI Codex is, how to download and install the CLI or IDE extension, sign in, and configure config.toml basics—including sandbox permissions and regional access notes.
Configure DeepSeek in Codex
Set DeepSeek as the Codex CLI model backend: API base URL, keys, model_providers config, model choice, and wire_api troubleshooting.