Kipt

Your prompts and skills, one keystroke away.

Explore

Codex best practices: OpenAI's own guidance on prompts, AGENTS.md, task size and review

Codex best practices from OpenAI's docs: the four-part prompt, Plan mode, AGENTS.md, task sizing, safe permissions, testing, /review and the mistakes to avoid.

By the Kipt team · Updated 26 October 2026

OpenAI's Codex best practices come down to a few habits: give each task a goal, context, constraints and a clear "done when"; ask Codex to plan before hard work; move rules you repeat into AGENTS.md; keep permissions tight; and make Codex test and review its own changes before you accept them.

This page summarizes OpenAI's own guidance, mainly the Codex best practices guide and the prompting docs, read on 26 October 2026. The guide frames the whole approach in one line: "Codex works best when you treat it less like a one-off assistant and more like a teammate you configure and improve over time."

What are OpenAI's Codex best practices in short?

OpenAI lays out a progression: start with the right context for the task, use AGENTS.md for durable guidance, configure Codex to match your workflow, connect outside systems with MCP, turn repeated work into skills, and automate stable workflows. Each step builds on the one before.

Habit What it fixes Where it lives
Four-part prompts Vague results, scope creep Each prompt
Plan first Wrong approach on complex work /plan or Shift+Tab
One chat per unit of work Bloated context Your chat list
AGENTS.md Repeating the same rules Repo root, subfolders, ~/.codex
Tight permissions Risky actions config.toml, permissions control
Tests and /review Unchecked changes Prompt, AGENTS.md, /review
Skills and scheduled tasks Long, repeated prompts SKILL.md, the app's Scheduled page

How should you write a Codex prompt?

OpenAI notes that Codex can be useful even when your prompt isn't perfect, but clear prompts make results more reliable, "especially in larger codebases or higher-stakes tasks." Its suggested default is to include four things:

  • Goal: what you want changed or built.
  • Context: the files, folders, docs, examples or errors that matter. You can @ mention files to add them.
  • Constraints: the standards, architecture, safety rules or conventions to follow.
  • Done when: what must be true at the end, such as tests passing or a bug no longer reproducing.

Here is an example in that shape (our own wording, not from OpenAI):

Goal: Stop the settings page from showing "Saved" when the save request fails.
Context: @src/settings/SettingsForm.tsx and @src/api/settings.ts. Steps to reproduce: toggle "Enable alerts", click Save, refresh the page.
Constraints: Don't change the API shape. Keep the fix small.
Done when: The repro no longer fails, a regression test covers it, and lint and the settings tests pass.

OpenAI's bug-fix example makes the same point from the other side: the repro steps and constraints you supply "matter more than a high-level description." In the CLI, mention paths explicitly or use @ path autocomplete; the IDE extension adds your open files as context on its own.

Match the reasoning effort to the task. The guide suggests Low for faster, well-scoped tasks, Medium or High for complex changes or debugging, and Extra High for long, agentic, reasoning-heavy work. It recommends GPT-6.1 Sol where your account and client offer it, starting at the client's default effort. The Codex models guide covers how to switch.

You also don't have to wait for a run to finish to correct course. In the CLI, press Enter while Codex is working to steer the current turn, or Tab to queue a message for the next one. The Codex keyboard shortcuts guide lists the rest.

When should Codex plan before it writes code?

Plan whenever the task is complex, ambiguous or hard to describe. OpenAI lists three approaches:

  1. Plan mode. The guide calls it "the easiest and most effective option" for most users. Codex gathers context, asks clarifying questions and builds a plan before it edits. Toggle it with /plan or Shift+Tab.
  2. Ask Codex to interview you. When you have only a rough idea, tell Codex to question you, challenge your assumptions and turn the idea into something concrete first.
  3. Use a PLANS.md template. For long or multi-step work, you can have Codex follow an execution-plan template. OpenAI's execution plans article shows the pattern.

In the desktop app, the prompting docs add one more step: after the plan, use /goal (where Goal mode is available) to set a persistent goal for Codex to work toward.

How big should a Codex task be?

OpenAI gives no size limit, but the guide says to keep "one chat per coherent unit of work" and to fork only "when the work truly branches." Using one chat for an entire project is on its list of common mistakes because it "leads to bloated context and worse results over time."

Practical ways to keep tasks the right size:

  • Split big work into milestones. Have Codex plan, then implement one milestone per prompt. OpenAI's refactor example plans locally, then implements the milestones in a cloud chat.
  • Offload bounded side work. OpenAI's subagents docs suggest parallel agents for read-heavy work such as exploration, tests, triage and summaries, and warn that parallel write-heavy work "can create conflicts." See the Codex subagents guide.
  • Isolate parallel edits. Use Git worktrees when live tasks touch the same files.
  • Checkpoint with Git. The Codex CLI docs say: "Create Git checkpoints before and after a task so you can revert changes."
  • Compact long chats. Use /compact when a chat gets long; Codex also compacts automatically.

Scope also affects cost: when usage runs high, OpenAI's pricing FAQ suggests checking whether "a smaller model or tighter task scope would still produce a useful result." See the Codex usage limits guide.

What belongs in AGENTS.md?

Once a prompting pattern works, stop typing it. AGENTS.md loads into context automatically, and OpenAI calls it "the best place to encode how you and your team want Codex to work in a repository." A good one covers:

  • Repo layout and important directories
  • How to run the project
  • Build, test and lint commands
  • Engineering conventions and PR expectations
  • Constraints and do-not rules
  • What done means and how to verify work

Run /init to scaffold a starter file, then edit it to match how your team actually works. You can keep a global file in ~/.codex for personal defaults, a repo-level file for shared standards, and more specific files in subfolders; the file closest to your working directory wins.

Keep it short. In OpenAI's words: "A short, accurate AGENTS.md is more useful than a long file full of vague rules." Add a rule only after you notice a repeated mistake, and when Codex makes the same mistake twice, ask it for a retrospective and update the file. If it grows large, keep the main file lean and point to task-specific Markdown files. The Codex AGENTS.md guide covers loading order and overrides.

How should you set up config and permissions?

OpenAI's starting pattern for configuration: personal defaults in ~/.codex/config.toml, repo-specific behavior in .codex/config.toml, and command-line overrides only for one-off cases. The CLI, IDE extension and desktop app share the same configuration layers. See the Codex config guide and the Codex profiles guide.

For permissions, start with the defaults. OpenAI's advice is to keep approval and sandboxing tight, then loosen them only for trusted repos or specific workflows once the need is clear. The Codex sandbox and approvals guide explains each mode.

Set things up early, too. The guide warns: "Many quality issues are really setup issues, like the wrong working directory, missing write access, wrong model defaults, or missing tools and connectors."

How do you make Codex test and review its own work?

Ask Codex to write or update tests, run the right suites, check lint, formatting and types, confirm the behavior matches the request, and review the diff for bugs and risky patterns. Codex can run that loop, but only if it knows what good looks like, so put those expectations in the prompt or in AGENTS.md.

Then review. The /review command can review against a base branch, your uncommitted changes, or a single commit, or follow custom instructions. If your team keeps a code_review.md and references it from AGENTS.md, Codex follows it during review. On GitHub you can turn on automatic pull request reviews or tag @codex review; OpenAI notes that "At OpenAI, Codex reviews 100% of PRs." The Codex review guide covers all three ways.

When should you add MCP, skills and scheduled tasks?

Add each one only when it removes a manual loop you already have.

  • MCP fits when the context lives outside the repo, changes often, or should come from a tool instead of pasted text. OpenAI advises starting with one or two tools, not every tool you use. See the Codex MCP guide.
  • Skills fit when you keep reusing the same prompt or correcting the same workflow. Keep each skill to one job, say in the description what it does and when to use it, and scaffold it with the built-in $skill-creator. Personal skills go in $HOME/.agents/skills and team skills in .agents/skills in the repo. See the Codex skills guide.
  • Scheduled tasks in the desktop app fit workflows that already run reliably by hand. OpenAI's rule of thumb: "skills define the method and scheduled tasks define the schedule."

What mistakes does OpenAI warn about?

The guide ends with a list of common mistakes. In short:

  • Putting durable rules in every prompt instead of in AGENTS.md or a skill
  • Not telling Codex how to run build and test commands, so it can't check its work
  • Skipping planning on multi-step, complex tasks
  • Granting full computer access before you understand the workflow
  • Running live tasks on the same files without Git worktrees
  • Scheduling a recurring task before it works reliably by hand
  • Watching Codex step by step instead of working in parallel with it
  • Using one chat for a whole project instead of one per outcome

Where should your reusable prompts and skills live?

These habits leave you with prompts, AGENTS.md patterns and skills worth keeping. Kipt stores prompts and skills as Markdown in a private GitHub repo you own, and installs every skill into Codex or Claude Code with npx skills add https://github.com/<you>/<repo>.git --all -g. If you also use Claude Code, compare these habits with the Claude Code best practices guide.

Questions

What should a good Codex prompt include?

OpenAI's best practices guide suggests four parts: the goal, the context (files, docs, examples or errors that matter), the constraints Codex should follow, and a done-when condition such as tests passing. You can @ mention files to add them as context. A short prompt can still work, but this structure makes results more reliable in larger codebases.

When should I use Plan mode in Codex?

Use it when a task is complex, ambiguous or hard to describe. Plan mode lets Codex gather context, ask clarifying questions and build a plan before it edits anything. Toggle it with /plan or Shift+Tab.

How big should a Codex task be?

OpenAI recommends one chat per coherent unit of work and forking only when the work truly branches. Plan first for multi-step work, hand bounded side work such as exploration, tests or triage to subagents, and use Git worktrees when several tasks touch the same files.

What should go in AGENTS.md for Codex?

Repo layout, how to run the project, build, test and lint commands, conventions and PR expectations, do-not rules, and what done means. OpenAI says a short, accurate file beats a long one full of vague rules, and suggests adding rules only after you see repeated mistakes.

Which reasoning effort should I use in Codex?

OpenAI's guide suggests Low for faster, well-scoped tasks, Medium or High for more complex changes or debugging, and Extra High for long, agentic, reasoning-heavy tasks. Start with your client's default for GPT-6.1 Sol and adjust based on the result.

How do I get Codex to check its own work?

Tell it what good looks like, in the prompt or in AGENTS.md: write or update tests, run the right suites, check lint and types, and review the diff. Then run /review against your uncommitted changes, a commit or a base branch before you accept the work.

More in Codex

All guides

Keep your prompts and skills in one place, in your own GitHub. Install every skill with one command.

Get started

Kipt is an independent product, not affiliated with or endorsed by Anthropic, OpenAI, Cursor or GitHub. Claude, ChatGPT, Codex, Cursor and GitHub are trademarks of their owners.