Statewright

Codex CLI

Install statewright in OpenAI Codex CLI

Codex CLI

Codex gives the model full tool access by default. Statewright constrains it per workflow phase: read-only during planning, edit tools during implementation, designated test commands during testing. Enforcement happens at the hook layer, not via prompts.

Install (Marketplace)

codex plugin marketplace add statewright/statewright
codex plugin add statewright --marketplace statewright

The plugin is dormant until you activate a workflow. It won't interfere with normal Codex usage.

Usage

statewright_load_workflow(name='bugfix')

Once active, the hooks inject phase context into every turn and block tools that don't belong in the current state. Try to call edit during planning and you'll see:

PreToolUse hook (blocked)
  feedback: Tool 'edit' is not available in the 'planning' phase.
  Allowed: read_file, grep. To advance, use statewright_transition with: READY.
Manual install (without marketplace)
  1. Get an API key at statewright.ai/keys
  2. Save it:
    mkdir -p ~/.statewright
    echo 'sw_live_...' > ~/.statewright/api_key
  3. Clone the repo and add the MCP server:
    git clone https://github.com/statewright/statewright.git
    codex mcp add statewright -- bash ~/statewright/plugins/codex/mcp-proxy.sh
    Codex won't pass your env vars through to MCP servers it spawns. Add env_vars so the proxy can authenticate:
    # In ~/.codex/config.toml
    [mcp_servers.statewright]
    command = "bash"
    args = ["~/statewright/plugins/codex/mcp-proxy.sh"]
    env_vars = ["STATEWRIGHT_API_KEY", "STATEWRIGHT_GATEWAY_URL"]
    Without env_vars, the proxy falls back to reading ~/.statewright/api_key from disk (which works fine for single-gateway setups).
  4. Create or edit ~/.codex/config.toml to enable hooks:
    [features]
    hooks = true
  5. Copy hooks.json to ~/.codex/hooks.json (or merge into existing if you have other hooks)

Also works with Oh My Codex

Oh My Codex uses the same .codex/hooks.json format, so this plugin works unmodified. A dedicated OMX plugin with TypeScript hooks is available for deeper integration.

Source

plugins/codex/

On this page