Home / Knowledge work / Using AI at work
Codex best practices
How to get good work out of OpenAI Codex: four-part prompts, plan mode, a short AGENTS.md, self-checks with /review, focused chats and skills.
Beginner · 7 min read · Updated December 3, 2026
Codex is OpenAI's coding agent. It runs in your terminal as the Codex CLI, inside your code editor, in the desktop app and as cloud tasks. OpenAI's best-practices guide asks you to treat it less like a one-off assistant and more like a teammate you set up once and improve over time. This lesson puts that guide into plain steps.
Write prompts with four parts
Every task prompt should cover:
- Goal: what to change or build.
- Context: the files, docs or error messages that matter. Paste the stack trace instead of describing it.
- Constraints: the standards and conventions to follow, and what to leave alone.
- Done when: what must be true at the end, such as a named test passing.
Here is one filled in:
Goal: Fix the CSV export so dates use the customer's time zone.
Context: The export lives in src/export/csv.ts. The bug report says Tokyo customers see yesterday's date.
Constraints: Don't change the public API. Follow the existing date helpers in src/lib/dates.ts.
Done when: A new test for a Tokyo customer passes and npm test passes.
Match the reasoning effort to the job. Use low effort for small, well-scoped tasks, medium or high for complex changes and debugging, and the highest setting for long, reasoning-heavy work.
Plan before hard tasks
For anything complex or fuzzy, switch on plan mode with /plan or Shift+Tab. Codex reads the code and proposes a plan before it edits anything, so you can correct the approach while it is still cheap. You can also ask Codex to interview you about the idea first. For long, multi-step work, OpenAI suggests keeping an execution plan in a PLANS.md file that Codex updates as it goes.
Keep AGENTS.md short and useful
AGENTS.md is a README for agents. Codex loads it automatically before it starts work. Run /init to scaffold one, then edit it to cover:
- How to build, test and lint
- The conventions and the "never do this" rules
- What "done" means in this repo
Keep it short. When Codex makes the same mistake twice, add a line. Our AGENTS.md guide covers where the files go and how Codex combines them.
Let it check its own work
Ask Codex to write or update tests and run the checks before it says it is finished. Then run /review, which reviews the changes against your main line of work, your uncommitted changes, a specific commit or your own instructions. Read the diff yourself before you accept it.
Start with the default approval and sandbox settings. Loosen them only for repos you trust or for a specific workflow you have tested.
Keep chats focused
Use one chat per piece of work, not one chat for the whole project. A chat that runs for days fills up with old context and gets worse over time.
/forksplits a chat only when the work really splits in two./resumereturns to a saved chat./compactsummarizes a long chat so it takes less context.
Turn repeated prompts into skills
When you type the same instructions again and again, package them as a skill: a folder with a SKILL.md file that says what the skill does and when to use it. Keep each skill to one job. Personal skills go in ~/.agents/skills, and team skills can live in .agents/skills inside the repo. Codex's built-in $skill-creator skill can scaffold one for you.
Only schedule a task to run on its own, from the desktop app's Scheduled page, after it works reliably when you run it by hand.
Practice checklist
- Write your next task prompt with all four parts
- Use
/planonce on a task you'd normally just start - Run
/initand trim the result to the lines Codex needs - End every task with tests plus
/review - Start a fresh chat for each new piece of work