
OpenAI Codex can keep coding tasks running in the cloud after you close your laptop. The coding agent also works in a terminal and VS Code-based IDEs, giving ChatGPT users several ways to work with a repository. OpenAI demonstrates how to install the tools, supply project context and connect outside services. Explore which settings and prompts can help you begin with a task you can check.
Install Codex and Sign In
TL;DR Key Takeaways :
- Install the CLI or VS Code extension and sign in once for both.
- Use concise AGENTS.md files to supply project context and verification commands.
- Check sandbox and approval defaults before expanding a task.
- Use code review, cloud tasks and structured output for broader workflows.
The CLI and IDE extension share a sign-in, so you can move between them after authenticating. OpenAI recommends installing the CLI with npm rather than brew because npm is the most up-to-date method and releases can arrive multiple times a week. Follow these steps to set up the tools and prepare a project:
- Install the Codex CLI using npm or brew. Check the update banner in a session for newer versions; the CLI is open source, with binary releases on GitHub and a version-by-version changelog on OpenAI’s developers site.
- In VS Code, open the Extensions tab, search for OpenAI Codex and install the official extension. Its listing shows the version and lets you switch between prerelease and release-candidate versions; turn on auto-update to receive updates.
- Sign in from the extension’s initial screen or run codex login in the CLI and use your work email, potentially through your organization’s SSO. Signing in through either surface also signs you in on the other.
- Run /status in the CLI to check the model, working directory, sandbox mode, approval policy, remaining context window, account and session ID.
- To follow the demonstrated project, clone the open-source agents.md website repository or use another repository. Change into its directory, install dependencies with npm and run npm run dev to run the site locally.
- Run /init in the CLI to generate an AGENTS.md file in the working directory, then edit it with the instructions your project needs.
Give Each Session Project Context
AGENTS.md acts as a lightweight readme for the agent. A new session starts with a fresh context window, so the file supplies instructions automatically instead of requiring you to repeat them in every conversation. A global file in the Codex home folder can cover all projects, while files at the Git root and in subdirectories can supply repository- or service-specific guidance.
OpenAI recommends keeping those instructions brief and focused: too many or conflicting instructions can leave the agent spending time resolving conflicts. Most AGENTS.md files in its monorepo were under 100 lines. Useful sections include project structure, build and test commands, CLI tools and MCP servers, a feature-implementation workflow and pointers to task-specific guidance.
Include feedback and verification commands, such as tests, linters, compile checks or screenshots, and update the file when Codex makes a mistake or takes too long to find a useful command. For detailed front-end, architecture or execution guidance, point to separate Markdown files that Codex can read when needed. A plans.md template can specify a living plan with a checklist and progress updates; OpenAI says one engineer used that approach for a successful refactor lasting more than 10 hours.
Choose Models, Permissions and Defaults
With project context in place, use /models in the CLI to choose a model and low, medium or high reasoning effort. OpenAI identifies GPT-5.1-Codex-Max as its most recent and best model for agentic coding, trained specifically in the Codex harness. In the VS Code extension, select local work or a connected cloud environment, an access mode such as chat, agent, agent full access or a custom configuration, and the model and reasoning level.
The config.toml file holds defaults for the model, reasoning effort, sandbox mode, approval policy and features such as web search, as well as profiles and MCP servers. The CLI is written in Rust, which is why it uses TOML. A named profile can use the fastest model and lowest reasoning effort for quicker replies; the demonstrated fast profile starts with codex -p fast. Terminal notifications can alert you when a background task finishes.
The default on-request approval policy lets Codex run until it decides it needs escalated permissions. Its default workspace-write sandbox permits writing in the current working directory, not outside it. OpenAI says its models are natively trained in Linux, macOS and Windows environments, including bash and PowerShell, and to follow sandbox rules and compact long conversations for longer work such as large refactors.
Web search is off by default. Enable web-search requests in config.toml or pass a configuration flag when starting a session if the task needs current web information. The example requested a latest-news footer about Next.js 15.
Start With Prompts You Can Check
OpenAI recommends starting with small tasks that are easy to test and review, then increasing their scope. Ask Codex to research a feature and break it into smaller units for follow-up prompts, or use an @ mention to give it a relevant file as a starting point. That file need not be the one ultimately edited, but it can steer the search away from unrelated parts of the project.
Include tests or linters in the prompt if they are not already in AGENTS.md, or state the requirements that define a complete feature. For debugging, paste the full stack trace so Codex can trace the error through the codebase. Open-ended prompts can also help brainstorm feature improvements, performance changes or what to build next, and the CLI suggests next steps for continuing a conversation.
Suggested starter tasks include explaining a codebase, writing documentation, fixing a bug from its stack trace, expanding tests for edge cases and refactoring repeated implementations into a generic component. In a demonstration, a read-only project question led Codex to research the repository and summarize it, while the extension displayed its work and the files it read. Codex can also inspect Git history to identify contributors or recent changes.
Work With Files and Images in VS Code
For a more directed IDE task, bind a keyboard shortcut to add highlighted text as context. The demonstration used Command-Shift-C to add 10 lines from the hero TSX file. You can also create a to-do in a code file and click Implement with Codex; multiple to-dos can be placed in code for the agent to implement.
In the agents.md site demonstration, an agent-mode prompt requested hero buttons to download the repository, view it on GitHub and copy the site’s Markdown. Codex explored the files, displayed a task list and added the buttons to the locally running site. A separate request produced an assets.html documentation page describing project flows and file relationships, which was opened in Chrome. A prompt for a clean Mermaid sequence diagram produced a concise diagram that could be copied or downloaded.
Images can provide context for a visual change: paste a screenshot into the CLI and describe the change, or click the plus button in the IDE and choose an image. A request for orange inline code chips led Codex to find the relevant code and change the backgrounds of the three setup commands. After leaving a CLI session, run codex resume to select a previous conversation, or use its session ID to return directly. In the IDE, search for the earlier task and continue it there, preserving its conversation context.
Reuse Instructions and Connect MCP Tools
For a recurring task, create a prompts folder in the Codex home folder and add a Markdown file containing the instructions. The example asked for unit tests for changed files using the existing test runner and minimal diffs. Restart the CLI, invoke the prompt from the prompts menu and press Enter to load those instructions and perform the task.
MCP connects models to additional tools and context. Codex supports standard I/O and HTTP transports; add a server by running codex mcp add with its parameters or by adding it directly to config.toml. The demonstrated command added a global server called Cupcake MCP and put its configuration in the file.
Examples include Figma for front-end work from mockups; Jira and Linear for finding assigned tickets, making code changes and updating tickets; Context7 for third-party API documentation; and Datadog for diagnosing production issues. Current documentation can help with a model’s knowledge cutoff as frameworks and APIs change, and some customers build MCP servers for internal documentation. To make documentation lookup routine, add an instruction to the global AGENTS.md telling Codex to search Context7 when implementing features with external libraries or APIs.
In the local agents.md project, a request to add Rachel’s cupcake order called Cupcake MCP, retrieved an order for seven marble cupcakes for pickup and displayed it at the bottom of the page. Another prompt used GPT-5.1-Codex-Mini at medium reasoning effort to add an input that generates an AGENTS.md file using OpenAI’s Responses API. Codex retrieved current API documentation through Context7 and added the section to the local page.
Review Changes and Run Cloud Tasks
Once a change is ready, the CLI can start a code review against a base branch, all uncommitted local changes or a specific commit, or use custom review instructions. Team-specific review guidelines can live in a separate Markdown file referenced by AGENTS.md. In the IDE, choose code review from the slash commands and select a base branch or uncommitted changes; the extension can offer a button to ask Codex to fix a reported issue.
OpenAI says its code-review model is trained to focus on high-priority issues, sometimes surfacing lower-priority ones, because excessive comments can cause people to tune them out. Codex Cloud can review pull requests as they open and comment on bugs and other issues before a merge. Its Slack integration can pick up a conversation thread when Codex is mentioned and produce a pull request.
Cloud containers can run multiple iterations in parallel, and background tasks can continue while a laptop is closed. OpenAI suggests asynchronous code review and working from a mobile phone as possible uses. You can select a connected cloud environment in the extension when a task suits that workflow.
Use Structured Output in Pipelines
For programmatic work, the CLI has a headless mode and SDK for containers and pipelines. codex exec can take an output schema and return structured JSON instead of opening an interactive session. A code-quality demonstration used a schema with file and issue counts, a score from 0 to 100 and an array of issues; the parsed result included file citations, line numbers, severity and descriptions for use with APIs, databases or CI/CD.
Codex can also run as an MCP server called by the OpenAI Agents SDK. The SDK can give separate front-end, project-management and back-end agents their own tools and context, coordinate handoffs, and trace calls and the context passed to Codex. Suggested programmatic uses include security triage, a test-coverage bot, automated refactoring and cleanup, and release hygiene that creates changelogs and readmes.
Organizations can build their own review pipeline in containers for on-premises use or a source-control system other than GitHub, using the same review prompt as the CLI and cloud service and structured outputs to flag issues. A custom CI workflow can trigger Codex when pull-request tests fail, check out the branch and open a pull request with a fix. In the Codex open-source repository, an issue-creation trigger applies predefined labels based on the issue’s intent.
We favor a small change with a clear verification command as a first task, rather than a broad instruction to rewrite a repository. AGENTS.md can make that task easier to repeat, but conflicting instructions and access settings deserve attention before increasing its scope. Check the sandbox and approval policy, review the resulting changes and add detailed guidance when the project needs it. MCP connections are useful for current documentation, but they are not necessary for every first prompt.
For further configuration, OpenAI provides Codex documentation, cookbooks, a frequently updated changelog, an enterprise admin guide and a security guide. Its rate card also shows Codex credit usage, which is worth checking when planning repeated or automated tasks.
- How OpenAI Codex Turns Sketches Into Front-End Code
- How to Create Avatar Videos With OpenAI Codex and MCP
- ChatGPT Codex CLI Update Adds Summaries and Editor Tools
- How to Set Up OpenAI Codex for Coding Tasks and Testing
Media Credit: OpenAI
Disclosure: Some of our articles include affiliate links. If you buy something through one of these links, Geeky Gadgets may earn an affiliate commission. Learn about our Disclosure Policy.