# Connect Codex CLI to Repowise

Wire the Codex CLI to the local or hosted Repowise MCP server, with project hooks, AGENTS.md and /prompts:repowise-* commands, then verify and remove it.

Codex CLI is a Full-tier host: MCP tools, project hooks, a managed
`AGENTS.md` and `/prompts:repowise-*` slash commands.

## Install

**Local, with your agent.** Paste this into Codex:

```text
Read https://docs.repowise.dev/setup.md and set up Repowise in this repository.
```

**Local, by hand.** An interactive `repowise init` offers Codex setup when
`codex --version` and `codex login status` both succeed. A non-interactive
run needs the flag:

```bash
repowise init --codex
```

or, on an indexed repository:

```bash
repowise agents add --target=codex
```

**The plugin.** Codex can also load the Repowise plugin (MCP, hooks, seven
skills) from a clone. See [Plugins](https://docs.repowise.dev/getting-started/plugins#codex-plugin).

**Hosted.** Run in the repository, then sign in:

```bash
repowise agents add --target=codex --hosted
codex mcp login repowise
```

## What gets written where

| File | Scope | What repowise writes |
|---|---|---|
| `.codex/config.toml` | project | `[mcp_servers.repowise]` running `repowise mcp`, and `[features] hooks = true`, without which Codex ignores the hooks file |
| `.codex/hooks.json` | project | `SessionStart` and `PostToolUse` hooks running `repowise-augment --client codex` |
| `AGENTS.md` | project | The managed Repowise block (`--no-agents` skips it). OpenCode and Hermes share it |
| `~/.codex/hooks.json` | user | The command-rewrite hook, on Codex builds that support it |
| `~/.codex/prompts/` | user | `repowise-ask`, `repowise-why`, `repowise-risk` and the other slash prompts |

Your global `~/.codex/config.toml` is not touched. The hosted entry is a
`url` table in the project `.codex/config.toml`, named `repowise-hosted`
when a local `repowise` exists.

## Restart

Start a new Codex session in the repository so it loads the project config.
For a hosted entry, run `codex mcp login repowise` (or `repowise-hosted`),
approve Repowise in the browser, then restart Codex. Run `/hooks` inside
Codex to review and trust the rewrite hook.

## Verify

```bash
codex mcp list
repowise agents
```

You should see `repowise` in the Codex list and `codex` with status
`configured`. In a session, type `/prompts:repowise-ask` and a question, or
ask "What are the hotspot files in this repo?" and check that Codex calls a
Repowise tool.

## Uninstall

```bash
repowise agents remove --target=codex
```

This removes the server table, the hooks, the prompts and the `AGENTS.md`
block (kept while OpenCode or Hermes still uses it), and leaves your own
content outside the markers.

## Troubleshooting

| Symptom | Fix |
|---|---|
| Hooks never fire | `[features] hooks = true` is missing from `.codex/config.toml`. Run `repowise agents refresh`. |
| Plugin hooks do not load | Plugin-bundled hooks are opt-in in Codex. Set `[features] plugin_hooks = true`, or use the hooks `repowise init --codex` writes. |
| `/prompts:repowise-*` is missing or stale | `repowise doctor` reports it. Run `repowise agents add --target=codex --scope=user`. |
| Commands are not rewritten through distill | Codex applies a rewrite only on 0.137 or newer, and only for families set to `permission: allow`. `repowise hook rewrite status` shows what your build supports. |
| `codex mcp list` has no `repowise` | Codex reads `.codex/config.toml` from the project you start it in. Start it in the repository root. |

## Next
- [Plugins](https://docs.repowise.dev/getting-started/plugins#codex-plugin) for the Codex plugin and the `codex_cli` provider.
- [Hooks](https://docs.repowise.dev/intelligence/hooks#codex-hooks) for what the Codex hooks say.
- [Tool profiles](https://docs.repowise.dev/agents/tool-profiles) to list all ten tools in Codex.
