When to use non-interactive mode
codex exec fits repeatable analysis, controlled generation, and CI checks. Inputs should be stable, outputs machine-consumable, and permissions stricter than in a human-driven session.
codex exec "Review the current diff. Return only actionable findings with severity, file, and line. Do not edit files."
Design observable automation
- Pin the working directory and repository revision.
- Declare the output format and success criteria.
- Keep secret-free logs and propagate failure codes.
- Add time, cost, and retry limits.
Do not publish directly
In CI, begin by producing a reviewable report or patch. Merges, deployments, and external comments require clear rules and a service identity with minimal permissions.
Exercise
Create a local script that reviews the diff and stores a report. Test it with one good change and one defective change. Confirm that failure is visible and the working tree remains untouched.
Lesson deliverable
What you will build
Practical evidence for "Automate tasks with codex exec" applied to a real or training repository.
Why it matters
The goal is to turn the lesson into a verifiable action, not just reading.
Starter repository or files
A small Git repository with Git, README, and one known validation command.
Steps
- 1. Inspect Git status before starting.
- 2. Ask Codex to work with limited scope.
- 3. Run the verification command.
- 4. Review the diff or produced evidence.
- 5. Record what is verified and what remains open.
Copy-ready Codex request
Apply the lesson "Automate tasks with codex exec" in this repository. Work in small changes, cite concrete files, run one verification, and finish with evidence and risks.
Expected result
A reviewable output: map, plan, diff, test, or report depending on the lesson.
Verification command
git status --short && git diff --stat
Manual check
Check that the result matches the requested scope and Codex did not touch unrelated files.
Mini exercise
Repeat the practice in another folder of the same repository, changing only one constraint.
Show solution
Keep the same goal, add one explicit constraint, and compare whether the final evidence improves.
Evidence to save
Save the prompt, commands run, relevant output, and git diff --stat.