> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nogic.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex

> Use OpenAI Codex to power Nogic's AI features

[Codex](https://github.com/openai/codex) (OpenAI's CLI) is a first-class option for the visualizer cursor. Unlike Claude Code, Codex doesn't accept a per-call `--mcp-config` flag; it only reads MCP servers from `~/.codex/config.toml`. The extension manages that file for you.

## Prerequisites

* Your editor (VS Code or compatible) with the [Nogic extension](/installation) installed
* Codex installed and on your `PATH`

Verify:

```bash theme={null}
codex --version
```

## Usage

1. Open the visualizer (**Nogic: Open Visualizer**)
2. In the MCP Setup overlay, ensure **Codex** is enabled
3. Press `Cmd+K` and ask your question

When Codex is enabled, the extension writes (or updates) a managed block in `~/.codex/config.toml`:

```toml theme={null}
# === nogic-extension begin (auto-managed; do not edit) ===
[mcp_servers.nogic]
url = "http://127.0.0.1:54123/mcp"
default_tools_approval_mode = "approve"
# === nogic-extension end ===
```

The block:

* Is rewritten on **every extension activation** (the URL changes per session)
* Sets `default_tools_approval_mode = "approve"` so `codex exec` doesn't auto-cancel MCP tool calls when there's no TTY to show approval prompts
* Is removed automatically if you disable Codex in the MCP Setup overlay
* Backs up your existing config to `~/.codex/config.toml.nogic.bak` the first time it touches the file

Anything outside the markers is left alone.

## Switching CLI / model

The cursor in the visualizer exposes per-turn overrides for CLI and model tier. To set a global default:

```jsonc theme={null}
// settings.json
{
  "nogic.walkthrough.preferredCli": "codex" // "auto" | "claude" | "codex"
}
```

`auto` probes both CLIs at startup and picks the first that's enabled and available (Claude Code first, Codex second).

## Disabling Codex

In the MCP Setup overlay, toggle **Codex** off. The extension immediately strips the managed block from `~/.codex/config.toml`. Re-enable any time to restore it.

You can also disable it via settings:

```jsonc theme={null}
{
  "nogic.walkthrough.enabledClis": ["claude"]
}
```

## Troubleshooting

**`codex` not detected**: ensure `codex --version` works in your shell. Restart VS Code if you installed Codex after VS Code was already running.

**Tool calls fail with "user cancelled"**: the auto-managed block sets `default_tools_approval_mode = "approve"`. If you've manually edited the block (the markers protect it on rewrite, but a manual edit between markers gets overwritten), make sure that line is still there.

**Stale URL after restart**: the block is rewritten on every activation. If you opened a Codex session before VS Code finished activating, exit and restart Codex.

## Next

<CardGroup cols={2}>
  <Card title="MCP Tools" icon="wrench" href="/mcp/overview">
    Full canvas tool reference
  </Card>

  <Card title="Claude Code" icon="terminal" href="/mcp/claude-code">
    Same flow with Claude Code
  </Card>
</CardGroup>
