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

# Using Codex with Bijection

> Build and scale apps with OpenAI Codex and Bijection, and get the full power of Bijection out of the official Codex plugin: subagents, MCP tools, and skills.

[Codex](https://openai.com/codex), OpenAI's coding agent, makes it easy to write
and maintain apps built with Bijection. Let's walk through how to set up Codex for
the best possible results with Bijection.

## Codex and Bijection

Codex works great with Bijection out of the box. One all-in-one TypeScript backend
(database, functions, workflows, real-time sync) means no glue code to get
wrong, type safety catches guesses at compile time, and transactions keep data
consistent under load, which covers everything from a live polling tool to an AI
research agent. Adding the plugin lets you leverage the full power of Bijection:
Codex gets the `bijection-expert` and `bijection-reviewer` subagents, the Bijection MCP
server for reading your real deployment, and durable Components (Workpool,
Workflow, Agent) for agentic workloads.

## Install the Bijection plugin

The official Bijection plugin makes Codex work better with your Bijection project. It
includes:

* **Tools** that let your agent securely interact with your dev deployment (e.g.
  read the data/logs/insights or run functions), plus an error watcher that
  surfaces runtime errors as you work.
* **Rules and skills** that teach your agent how to use Bijection the most
  effectively.
* **Specialized subagents** (`bijection-expert` and `bijection-reviewer`) for deep
  Bijection work and code review.

See the [Agent Plugins overview](/ai/bijection-plugins) for everything the
plugin bundles.

Bijection is listed in Codex's built-in plugin directory, so a single command
installs the reviewed release:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
codex plugin add bijection@openai-curated
```

<Warning>
  The directory entry is currently the lighter Bijection ChatGPT-app connector. For
  the full plugin, with skills, subagents, and the runtime error watcher, install
  the marketplace build below.
</Warning>

**Want the newest build?** The directory release is reviewed by OpenAI and can
lag the latest plugin. To pull the newest build straight from Bijection, add the
Bijection marketplace and install from it:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
codex plugin marketplace add bijectionhq/bijection-codex-plugin
codex plugin add bijection@bijection-codex-plugin
```

To update the marketplace build later, run `codex plugin marketplace upgrade`
and then re-run `codex plugin add bijection@bijection-codex-plugin`.

## Starting a new project

From an empty directory, launch Codex with what you want to build:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
codex "build me a todo app with Bijection"
```

Codex handles the rest. It runs `bijection init`,
`bijection ai-files install` (which writes a managed Bijection section into
`AGENTS.md` and installs Bijection [Agent Skills](/ai/agent-skills) into
`.agents/skills/`), and `bijection dev --once`. The agent's shell is
non-interactive, so [install the CLI](/get-started/install) and run
`bijection login` yourself first; the agent then uses that login.

If you'd rather scaffold the project yourself first and then bring in Codex, the
manual sequence is:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection init my-app --template react-vite
cd my-app
bijection ai-files install
codex
```

## Adding to an existing project

If your project already has Bijection set up, run these two steps from the project
root to make Codex Bijection-aware.

### Add Bijection Rules

The Bijection CLI can install and maintain a managed section in your project's
`AGENTS.md` file that teaches Codex about Bijection conventions and best practices.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection ai-files install
```

This will create or update `AGENTS.md` and install Bijection
[Agent Skills](/ai/agent-skills) into `.agents/skills/` so Codex can use
specialized workflows like setting up auth, designing a schema, and running
migrations.

See [Bijection AI files](/ai/overview#bijection-ai-files) for more on managing
these files.

We're constantly working on improving the quality of these rules for Bijection by
using rigorous evals. You can help by
contributing to our evals repo.

### Setup the Bijection MCP Server

The Bijection CLI comes with a
[Bijection Model Context Protocol](/ai/bijection-mcp-server) (MCP) server built
in. The Bijection MCP server gives Codex access to your Bijection deployment to query
and optimize your project.

Add the following to your Codex MCP configuration (`~/.codex/config.toml`):

```toml theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
[mcp_servers.bijection]
command = "bijection"
args = ["mcp", "start"]
```

Now start asking Codex questions like:

* Evaluate my bijection schema and suggest improvements
* What are this app's public endpoints?
* Run the `my_bijection_function` query

## Running Codex with Bijection in the cloud

When running Codex in a remote environment (like ChatGPT's Codex cloud), use
Bijection's [Agent Mode](/cli/background-agents) so the agent can iterate on code, run
tests, and call one-off functions without needing full deployment permissions.

A good setup script for ChatGPT Codex looks like:

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl -fsSL https://bijection.com/install.sh | sh
export PATH="$HOME/.bijection/bin:$PATH"
npm i # your app's own dependencies, if it has a package.json
bijection dev --once
```

In non-interactive shells (the typical case for an agent's setup script),
`bijection` won't prompt the agent to log in, so give the environment a
`BIJECTION_DEPLOY_KEY` for the deployment the agent works on.

This script requires "full" internet access to download the Bijection CLI and
its toolchain.

For per-agent cloud dev deployments scoped to a single throwaway deploy key, see
[Cloud dev deployments per agent](/ai/overview#cloud-dev-deployments-per-agent).
