# Install & Configure: Codex CLI: The Official OpenAI Coding Agent for your Terminal
## What This Is
Codex CLI is a tool from OpenAI that lets developers use a powerful AI coding assistant directly within their computer's command line. This allows for quick code generation, bug fixing, and scripting without needing to switch to a web browser or a separate application, accelerating development tasks.
Source: https://github.com/openai/codex
## Before You Start
Scan my workspace and analyze:
- The project language, framework, and directory structure
- Existing agent configuration (check for .claude/, .codex/, CLAUDE.md, settings.json, commands/, skills/ directories)
- Whether this repository or a similar tool is already cloned or installed
Then ask me before proceeding:
1. Do I need to configure any service credentials for this plugin (database, API keys, etc.)?
2. Should this be project-scoped or global?
## Fetch the Source
Clone or inspect the repository to understand what needs to be installed:
```bash
gh repo clone openai/codex
```
Review the README, directory structure, and any install instructions before proceeding.
## What to Implement
This is an **Agent Plugin** — typically an MCP server or capability bundle.
- Install any required npm/pip packages from the source repository
- Register the MCP server in `.claude/settings.json` under the `mcpServers` key with the correct command and args
- Configure any required environment variables or credentials
- Verify the server starts correctly by checking its expected output
## Additional Context
- Scan the user's system to detect the presence of `npm` or `brew`. Install the `@openai/codex` package globally using the preferred package manager (`npm install -g @openai/codex` or `brew install --cask codex`).
- Check the user's environment files (e.g., `.env`, `.zshrc`, `.bash_profile`) for an existing `OPENAI_API_KEY`. If found, inform the user that the CLI can be configured to use it. If not found, advise the user that the primary authentication method is interactive sign-in with a ChatGPT account.
- Execute `codex --version` to verify the installation was successful and output the version number. Then, execute `codex --help` to display the list of available commands and provide a summary to the user for their first use.
## Reference Implementation
```
```shell
# Install using npm
npm install -g @openai/codex
```
```
## Guidelines
- Adapt everything to my existing project — do not assume a specific stack or directory layout
- Review any fetched code for safety before installing or executing it
- After setup, run a quick verification and show me a summary of exactly what was installed, where, and how to use it