This file provides guidance to Codex Code (localhost:3000/code) when working with code in this repository.
- Install and set up local launchers:
pnpm installpnpm buildpnpm install:local
- Repeat local setup in one command:
pnpm setup:local - Build the CLI bundle:
pnpm build - Type-check the repo:
pnpm check - Run the main test suite:
pnpm test - Run a single root test file with the same harness as
pnpm test:NODE_ENV=test node --import tsx --loader ./dist/loader.mjs --test tests/<name>.test.ts- Swap in
*.test.mjs,*.smoke.mjs, or*.behavior.mjsas needed.
- Run the built CLI directly without installing launchers:
pnpm startpnpm start:helppnpm start:version
- Verify local launcher installation:
codex-code --help,ccx --help - Install launchers into a custom bin dir:
pnpm install:local --bin-dir /custom/bin - Reinstall over an existing launcher:
pnpm install:local --force - Prototype workspace commands live under
packages/codex-code-proto/:node --testnode src/main.js
There is no root lint script in package.json; use the existing pnpm check and test suite instead of assuming pnpm lint exists.
README.mdand this rootCLAUDE.mdare the repo-local guidance files; there is no.cursorrules, no.cursor/rules/, and no.github/copilot-instructions.md.package.jsondefines the shipped CLI package (codex-code) and the canonical root scripts.scripts/build.mjsandscripts/install-local.mjsare part of the product surface, not just tooling glue.
- The root package is the real product.
pnpm-workspace.yamlincludespackages/*, butpackages/codex-code-proto/is an auxiliary prototype package, not the main runtime. - Startup is intentionally layered:
src/entrypoints/cli.tsxis the thin bootstrap. It handles fast paths like--version, loads Codex config, applies early environment guards, and routes special modes before importing the full app.src/main.tsxis the heavy orchestrator. It wires together interactive TUI mode, non-interactive/query flows, sessions, tool execution, MCP/bootstrap APIs, permissions, remote-managed settings, team context, and worktree support.
- The codebase is organized by subsystem instead of by package:
src/entrypoints/for startup modessrc/services/for product subsystemssrc/tools/for model-callable toolssrc/cli/,src/context/, and adjacent UI/state files for terminal interaction flowsrc/utils/for shared runtime helpers
- Tooling is a first-class part of the app architecture.
src/tools/contains the concrete tool implementations exposed to the model, andsrc/entrypoints/mcp.tsre-exposes the tool surface through an MCP server. src/query.tsis part of the non-interactive/model loop path and connects messaging, compaction, tool-use summaries, attachments, and queue management.
- The build is custom.
pnpm buildrunsnode scripts/build.mjs, not a plain TypeScript compile. scripts/build.mjsuses a staged build rooted atsrc/entrypoints/cli.tsx, emitsdist/loader.mjs, and hard-disables a large set of internal-only features/import paths for this external build.- Local execution depends on built artifacts in
dist/.scripts/install-local.mjsrefuses to install launchers untildist/cli.jsexists. - Installed
codex-codeandccxlaunchers defaultCODEX_CODE_USE_CODEX_PROVIDER=1andDISABLE_AUTOUPDATER=1. - The repository is source-installed, not npm-published. Prefer the local launchers or
node dist/cli.jsflows documented inREADME.md.
- The root suite is behavior-heavy and product-level, not just unit tests. Expect coverage around sessions, slash commands, permissions, memory, plan mode, MCP/tool behavior, and TUI acceptance flows.
- The root
pnpm testscript runs Node's built-in test runner withtsxand the built loader across:tests/*.test.tstests/*.test.mjstests/*.smoke.mjstests/*.behavior.mjs
- When debugging a feature, trace from
src/entrypoints/cli.tsx->src/main.tsx-> the relevantsrc/services/orsrc/tools/module, then confirm behavior intests/.
- If a rebuilt launcher behaves strangely, rebuild first with
pnpm build; if you replaced an existing launcher, also rerunpnpm install:local --force. ~/.local/binis the default launcher install location; if the commands are missing, checkPATHbefore assuming the install failed.- Treat
packages/codex-code-proto/as a reference or experiment area for Codex-response shaping, not as the main place to implement product behavior unless the task is explicitly about that prototype.