# Codex

Codex runs as a CLI, desktop app or VS Code extension and gets skills, rules, and MCP through mp agent install.

> Source: https://www.mainpath.ai/en/docs/codex/

Codex is OpenAI's AI agent. You can use it in three ways: as a CLI in the terminal, as a desktop app, or as the ChatGPT/Codex extension in VS Code, which the welcome page of MainPath extension links to directly. The [MainPath Toolbox]({{< relref "local-app" >}}) installs the CLI and the desktop variant during developer setup.

## Starting

For the CLI, change into the project folder and run `codex`. As with every agent, open the parent project folder so that all repositories are visible.

```bash
cd ~/Documents/MainPath/<organization-slug>/<project-slug>
codex
```

## Preconfiguration

MainPath rules come from the mp CLI agent plugin. `mp agent install` places the plugin and skills under `~/.codex/` and writes the MCP server `application-platform` into `~/.codex/mcp.json`. Codex therefore knows platform conventions from the start: applications start via `mp run-local`, `.gitlab-ci.yml` and `env/*.generated.env` are managed by MainPath, and custom values belong in `env/*.custom.env`. Project-specific additions go in an `AGENTS.md` in the application repository; how that works is described in [Your own rules for AI agents]({{< relref "ai-instructions" >}}).

## Install the agent plugin

```bash
mp agent install
mp login
```

A separate marketplace entry is not required. If the mp CLI is not signed in yet, run `mp login` and restart Codex. All installation routes, the list of MCP tools and the typical failure cases are described in [CLI and agent plugin]({{< relref "cli-and-agent-plugin" >}}).

A prompt such as "Create a new MainPath project with a Flutter app and a FastAPI backend and clone it." is enough from then on; the flow behind it is described in [Create a new project]({{< relref "create-project" >}}).

