Codex: Start With Goal, Context, and Mode
Codex is available on several surfaces, but the engineering contract stays common: goal, relevant context, constraints, and Done when. For an ambiguous change, plan first, then allow writes.
The surfaces solve different tasks, and that's worth accounting for when choosing.
Surface · Practical use · Context
- CLI - Work in the terminal, scripts, and non-interactive runs; The current checkout, instructions, and configured tools
- IDE extension - Changing code next to the editor; The open project and selected files
- ChatGPT desktop app - Several chats, local projects, worktrees, and a visual workflow; The project, chat, and connected capabilities
- Cloud - A task in an isolated cloud environment; A configured repository and environment
The first practical prompt shows the frame in action - a focused bug fix with explicit Context, Constraints, and Done when.
Goal: Fix the discount calculation: 20 must mean 20%, not a multiplier of 20.
Context: src/discount.js, tests/discount.test.js. Reproduce the test first.
Constraints: don't change the public signature, don't add dependencies, write only to src/discount.js.
Done when: the focused test and npm run check finished with code 0; show the diff and exit codes.The official Codex guidance frames this as Goal, Context, Constraints, and Done when. For a complex or ambiguous task, Plan mode is used to agree the approach before the change; repeatable repository rules move into AGENTS.md, and workflows into a skill. A short daily loop is six steps: open a trusted checkout and check git status, give the contract and ask for research, check files and commands in the plan, allow the minimal patch in the workspace, ask for the focused test and final diff, run a separate /review.
A surface doesn't change rights automatically. Local, cloud, and app environments have different boundaries. Before a run, check the current sandbox, approvals, network, and writable roots rather than relying on a habit from another surface.
The first prompt is sent. Now let's configure Codex's persistent mechanisms: AGENTS.md, skills, config, hooks, and MCP.