> ## 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.

# Codex

> Set up Codex with the bijection CLI and project guidance

[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

Point the assistant at the actual app tree (`bijection/app.ts`),
its tables, labels, roles and guards, and the committed `bijection.lock`. Types
catch a call to a function that does not exist or with the wrong arguments, and
`bijection check` explains label flow and lexicon problems in remedy sentences.
Review the lock diff and the tasks a change submits as you would a person's.

The assistant runs `bijection` with the same verbs and tree paths as the code:
`bijection check` checks the source and writes the lock,
`bijection query notes.list` and `bijection mutate notes.add text=Hi` call
functions, `bijection trial` shows what a mutation would write without
committing it, `bijection list notes.items --first 5` reads facts and
`bijection watch sys.logs` follows function logs. `bijection status request` observes or resumes
a deploy request whose reply was lost.

## Set up the Bijection CLI

[Install the CLI](https://docs.bijection.com/start/install.md), then add Bijection's guidance for
coding agents from your project directory:

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

This writes a managed pointer section into the project's `AGENTS.md` and
`CLAUDE.md`, a `bijection` stub skill for each selected agent (Claude Code and
Codex by default) and a `bijection` entry in `.mcp.json` that runs
`bijection mcp serve`. The guidance itself ships as Agent Skills inside the
installed `@bijectionhq/bijection`, so it matches the project's SDK version:
the MCP server serves it with the Skills extension, and `bijection skills list`
and `bijection skills show <name>` print it.

An application can also [declare an MCP server](https://docs.bijection.com/mcp/servers.md) for its
queries and mutations. [Connect the host](https://docs.bijection.com/mcp/clients.md) to that HTTP
endpoint as a person or an issued session. Each tool call runs under the
caller's own grants, and a write carries its `once`, so a retry is the same
effect.

## Starting a new project

[Install the CLI](https://docs.bijection.com/start/install.md). Local development can use the starter's
development identity. For hosted work, run `bijection login` yourself
or configure a deployment-scoped credential before the non-interactive agent
starts. 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 can create the project with `bijection create` and push it with
`bijection dev --once`. 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 create my-app --template react-vite
cd my-app
codex
```

## Adding to an existing project

If your project already has Bijection set up,
[set up the CLI](#set-up-the-bijection-cli) and start asking Codex
questions like:

* Review my tables and indexes, and suggest the index a selection needs
* Which functions are exposed, and to which roles? (read `bijection.lock`)
* Run `bijection trial` on the `orders.place` mutation and explain its writes

## Running Codex with Bijection in the cloud

When running Codex in a remote environment (like ChatGPT's Codex cloud), use
Bijection's [Agent Mode](https://docs.bijection.com/development/parallel-coding-assistants.md) 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](https://docs.bijection.com/development/parallel-coding-assistants.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.