When developing with OpenAI Codex, do you ever encounter moments where you feel, "I should be able to use this more efficiently"? I use Codex daily, and after reading the official best practices guide, I realized there was significant room for improvement in how I had been using it.
In this article, I will provide a thorough explanation of the official OpenAI Codex best practices guide. I will cover everything from the four elements of prompt design to persistent context management via AGENTS.md, the proper use of reasoning levels, and the utilization of skills and automation from a practical perspective. I have compiled the know-how to take AI-driven development to the next level, while also incorporating perspectives comparing it to Claude Code.
Best Practices for Prompt Design as Shown in the Official Guide

The official OpenAI guide recommends treating Codex not as a "one-off assistant," but as a "teammate with whom you build up settings over time." This shift in perspective is the key to maximizing the use of Codex.
Personally, I initially gave instructions to Codex from scratch every time. However, this approach failed to maintain consistency and resulted in repeating the same explanations. The approach proposed by the official guide is to gradually teach Codex "our way of doing things." Since switching to this mindset, my development speed has clearly improved.
The 4 Basic Elements to Increase AccuracyThe official guide defines four elements that make up an effective prompt. By consciously including these, the accuracy of Codex's understanding and the quality of its output will improve significantly.
Goal is an element that clearly describes the changes or features you want to realize. Instead of vague instructions like "implement a login feature," show it concretely, such as "implement an authentication feature using email address and password with JWT tokens." In my experience, the more detailed you write the goal, the more you tend to avoid unintended implementations.
Context is an element that includes references to related files, folders, and documents. Specifically instruct the information sources Codex should refer to, such as "refer to the files in the src/auth/ directory" or "specifications are described in docs/api.md." If context is lacking, Codex will not have the appropriate material to make decisions, increasing the likelihood of off-target implementation.
Constraints is an element that specifies the standards or architectural requirements to follow. For example, if you do not explicitly state "build the UI using DaisyUI," Codex might choose Shadcn UI on its own. I have experienced this failure many times. It is important to communicate the libraries, frameworks, and coding conventions to be used in advance.
Done when is an element that indicates the criteria for judging that a task is complete. Set clear criteria, such as "all tests pass" or "the specified endpoint returns a normal response." This allows Codex to understand "what constitutes completion," preventing it from stopping halfway or doing excessive work.
Since I started consciously structuring my prompts with these four elements, my interactions with Codex have become smoother than before.
Plan Mode for Succeeding with Complex ImplementationsWhen faced with complex tasks, it is dangerous to start implementation immediately. The official guide recommends using Plan mode or asking Codex to interview the user.
Plan mode is a familiar feature that also exists in Claude Code. In this mode, Codex collects the necessary context in advance and creates an implementation plan. When I performed a refactoring that spanned multiple files, having it create a plan in Plan mode first prevented significant rework later on.
What is interesting is the approach of "asking Codex to interview you." If you instruct it, "I want to implement this feature, so please ask me for the necessary information," Codex will ask you questions. This allows me to organize the requirements myself and prevents misunderstandings before they happen.
Also, visualizing the plan by utilizing a plan.md file is effective. If you save the created plan in a file, you can refer to it across sessions, and sharing it within the team becomes easy. Not underestimating the planning phase and dedicating sufficient time to it will ultimately lead to higher development efficiency.
Writing Techniques to Eliminate AmbiguityPrompt ambiguity is the primary cause of disappointing output. You can mitigate this problem by mastering a few writing techniques.
ToDo List-Driven is a method of presenting tasks as a step-by-step checklist. By instructing the model to "proceed according to the following ToDo list" and clarifying each step, Codex can work without getting lost. Using a format where you check off completed items also makes it easier to track progress.
Presenting Concrete Verification Methods is also extremely important. Tell it how to verify correctness, such as "Once implementation is complete, run npm test and confirm that all tests pass" or "Open the screen in a browser and take a screenshot for me to check." Without verification methods, Codex might finish thinking it has "implemented it" when it hasn't.
The One-Thread-One-Task Principle should not be forgotten either. Mixing multiple different tasks in a single thread contaminates the context and causes unintended behavior. By separating threads for each task, you can keep the work environment clean.
By combining these techniques, communication with Codex will become significantly smoother.
AGENTS.md and Settings to Optimize Development Context
If you are writing the same instructions in your prompt every time, there is room for improvement. The official guide recommends utilizing AGENTS.md and configuration files to have Codex "remember" persistent rules.
I also used to write "Please use TypeScript" and "Follow ESLint rules" every time. However, since moving these to AGENTS.md, my prompts have become cleaner, and I can focus on essential instructions.
The Role of AGENTS.md in Defining Team StandardsAGENTS.md is a file that plays the same role as CLAUDE.MD in Claude Code. When Codex starts a session, this file is automatically read, and the rules described within are always applied.
Content that should be included includes the following:
Repository Structure: Explanations of major directories and their roles
Execution Methods: Build commands, test commands, and startup methods
Engineering Rules: Coding standards, libraries to use, and patterns to avoid
PR Expectations: Conditions that must be met for pull requests
The official guide recommends keeping AGENTS.md "short and accurate." If it becomes too long, it actually becomes harder to understand and wastes context capacity. It is wise to split it into a docs folder and link to it from AGENTS.md if it gets too long.
Another feature is that it can be placed in multiple hierarchies. You can define common personal rules in global settings (~/.codex/AGENTS.md), project-specific rules in repository-specific AGENTS.md, and even more detailed rules in subdirectory AGENTS.md files.
As a note of caution, the approach of "adding a rule after two mistakes" should be handled carefully. If you keep adding rules too easily, AGENTS.md will become bloated, which can actually reduce its effectiveness. Things like code formatters should be delegated to the hooks described later.
Configuration management via config.toml and hooksIt is recommended to manage Codex settings using configuration files rather than command-line arguments. This is because using a configuration file ensures that consistent settings are applied regardless of whether you access it from the CLI, an IDE, or an app.
Place config.toml in the .codex hidden folder directly under your user directory. Here, you can manage both personal default settings and repository-specific settings.
Of particular note is the hooks feature. You can set up custom processes for events such as start_session and stop_session. For example, you can display a greeting message when a session starts or send a specific notification when it ends.
A practical use case is the automatic execution of code formatters. If you set it to automatically run prettier or eslint --fix when a session ends, you can always maintain formatted code. It is more reliable to automate this with hooks than to write "please format" in AGENTS.md.
By managing settings appropriately, you can achieve a consistent development experience across the entire team.
Introducing MCP to streamline external integrationThe Model Context Protocol (MCP) is a mechanism that directly connects Codex with external tools, databases, and systems. This eliminates the hassle of manually copying and pasting context.
For example, if you connect database schema information via MCP, Codex can refer to that information as needed. It can also integrate with API documentation and project management tools.
However, be aware that information connected via MCP always consumes context. If you connect everything via MCP, it may put pressure on your context capacity and potentially reduce efficiency.
As mentioned in the video transcript, it is important to understand the characteristic that "MCP is always in the head (consumes context)." With this in mind, it is sometimes more efficient to delegate tasks to skills where possible. We will explain the proper use of MCP versus skills in a later section.
Using reasoning levels according to task difficulty
Codex provides four levels of reasoning effort. By selecting the appropriate level for the task, you can optimize the balance between cost and performance.
The official guide recommendations are as follows:
Low: Simple tasks that can be solved quickly. Such as typo corrections or simple renames.
Medium: Complex changes or debugging. Such as general feature implementation or bug fixes.
High: Tasks spanning multiple files. Large-scale refactoring or feature additions.
Extra High: Long-duration reasoning and multi-step agent tasks. Highly complex architectural changes.
From my experience as a practitioner, I recommend using Medium to High as the baseline. While Low is certainly fast, I get the impression that judgment errors increase in slightly complex tasks.
On the other hand, you should be cautious with Extra High. It consumes a massive amount of reasoning tokens, which can sometimes lead to lower efficiency. As the official guide notes, it is for "long-duration reasoning," so it should be limited to truly complex tasks.
Also, you need to be aware that Codex itself has some difficulty with long contexts (over 256K). Rather than stuffing in a massive amount of context, you tend to get better results by splitting it up and processing it appropriately.
It is important to choose the reasoning level by carefully considering the nature of the task. My basic stance is to use Medium by default, High for complexity, and avoid Extra High unless absolutely necessary.
Skills and Automation to Accelerate AI-Driven Development
Codex is a powerful enough tool just by utilizing the features explained so far. However, by taking it a step further and utilizing "skills" and "automation," Codex evolves from a mere chatbot into an "autonomously working colleague."
At first, I didn't feel the need for skills or automation. However, I realized I was asking Codex to do the same tasks over and over, so I started creating skills. The result was a surprising increase in work efficiency.
Defining Skills to Package Routine TasksSkills are repeatable workflows defined in an SKILL.md file. When you ask for similar tasks repeatedly, packaging them as a skill allows you to execute them with consistent quality.
Here are a few points for defining skills.
Focus on one job per skill: If you pack multiple purposes into one skill, it becomes difficult to use. Focus on a single purpose, such as "component creation," "test generation," or "document updates."
Include trigger phrases in the description: To have Codex automatically recognize the skill, include trigger phrases in the description, such as "Use this skill when creating components."
Start with 2-3 use cases: It is more practical to build up a few actual usage examples and refine them later rather than trying to create a perfect skill from the start.
Distinguish between personal and team skills: Manage personal routine tasks as personal skills and team-wide workflows as team skills.
Turn highly abstract common tasks into CLI tools: Processes common to multiple skills can be extracted as CLI commands and called from the skills to increase reusability.
Compared to MCP, skills have the advantage of consuming context only when needed. It is more efficient to offload information that doesn't need to be referenced constantly to skills.
Automation features for handling continuous processingAutomation is a feature that can be configured within the Codex app, allowing you to execute workflows periodically. By selecting a project and setting the unit of automation, development and information organization proceed in the background.
For example, you can automate tasks such as "checking for dependency updates at a specific time every day," "periodically verifying document consistency," or "checking for new issues and proposing response strategies."
When utilizing automation, it is important to set up only stable workflows. Automating unstable processes can lead to a chain reaction of errors or unexpected issues.
Additionally, there is the idea of periodically checking the execution history of automations to find potential skills. If you notice, "This task is frequently automated," you can redefine it as a skill, allowing for more flexible use.
While automation is a powerful feature, I recommend avoiding over-reliance on it and leaving important judgment points for human verification.
Session management and verification for driving the development cycleTo efficiently manage your interactions with Codex, you should master a few commands and techniques.
Session management commands:
Resume: Resume a previous session
Fork: Branch a session to experiment in a different direction
Compact: Compress session history to save context
You can also press Ctrl+C twice to exit a session and restart it. For long sessions, it is important to take breaks at appropriate intervals.
Quality check methods:
diff panel: Review changes in a PR style
/review command: Execute source code checks within the app
codex review command: Execute reviews from the command line
Importance of the verification process:
As emphasized in the video transcript, it is extremely important to provide the means for verification. Instead of just saying "implement this," you should communicate how to verify correctness, such as by saying "please take a screenshot with the browser tool to confirm" or "run the tests and report the results."
It is also effective to define rules for correction loops using skills or AGENTS.md. Decide on a response flow for errors, such as: "If a test fails, identify the cause and fix it. If it is not resolved after three attempts, report it."
By refining the details of your verification methods, you can expect better output. Instructing Codex on "how to verify" is the key to quality.
Common Development Mistakes Warned by the Official Guide
The official guide also lists "common mistakes" that developers often fall into. Just knowing these can prevent many failures.
Writing rules that should be in AGENTS.md into the prompt every time: This is the most typical mistake. Move persistent rules to AGENTS.md and let the prompt focus on essential instructions.
Not setting up code formatters in hooks: Instead of writing formatting instructions every time, you should automate them with hooks.
Not teaching verification methods or testing procedures: It is important not to just end with "implement this," but to also convey "how to verify it."
Not using plan mode for complex tasks: By creating a plan first instead of jumping straight into implementation, you can prevent rework.
Overly broad permission settings: If permissions are too broad, there is a risk of allowing unintended changes. Keep permissions to the minimum necessary.
Parallel tasks without Git worktrees: If you perform file operations from multiple threads in a single repository simultaneously, conflicts will occur. Separate worktrees or process them sequentially.
Automating unstable processes: If you set up unreliable workflows for automation, problems will chain together.
One task per thread instead of one project per thread: Instead of managing the entire project in one thread, separating threads by task keeps the context clean.
All of these mistakes are "wasteful" causes of failure. If you adopt the right habits from the start, you should be able to receive the maximum benefits of Codex.
Summary
We have gained many important insights from the official OpenAI Codex Best Practices guide. Finally, let's review the key points of this article.
Basics of Prompt Design: Be conscious of the four elements: Goal, Context, Constraints, and Completion Criteria, and utilize plan mode for complex tasks. To eliminate ambiguity, To-Do list-driven approaches and providing concrete verification methods are effective.
Persistent Context Management: Define team standards in AGENTS.md and automate settings with config.toml and hooks. MCP is powerful for external integration, but consider the trade-off with skills while being mindful of context consumption.
Selecting Reasoning Levels: The default should be Medium to High, and Extra High should be limited to extremely complex tasks. It is important to make a choice that considers the balance between cost and accuracy.
Skills and Automation:
Turn routine tasks into skills and automate stable workflows. Instructions that include verification methods are the key to quality.
Mistakes to Avoid:
Understand the pitfalls listed in the official guide and develop the habit of preventing them.
Codex is not just a chatbot, but a "teammate" that you nurture over time. Try incorporating the best practices introduced in this article little by little to take your AI-driven development to the next level.
The OpenAI Codex best practices guide was full of practical insights for streamlining AI-driven development. Personally, after reading this guide, my approach to working with Codex changed significantly. The perspective of "gradually building up settings" rather than "giving instructions every time" is an approach I highly recommend everyone try. Start by creating an AGENTS.md file and being mindful of the four elements of a prompt. Small steps will eventually lead to significant efficiency gains.
The author runs an AI x Development Practical Community on note. We provide information and a learning environment for "truly useful" AI for
"professional developers" with plenty of experience. We offer unlimited consultations, study sessions, and exclusive code & articles. If you are interested, please check the link below.