v0.13.2Control flow and dataflow are rebuilt on explicit semantics, Z3 translation matches executable C# numeric rules, and the build chain is hermetic and supply-chain verified with hash- and size-pinned Z3 binaries.See what's new

Codex Integration

This guide explains how to use Calor with OpenAI Codex CLI. For Claude Code integration, see Claude Integration.


Quick Setup

Initialize your project for Codex CLI with a single command:

Bash
calor init --ai codex

This creates:

FilePurpose
.codex/config.tomlMCP server configuration for Calor tools
.codex/hooks.jsonCodex-native write validation and post-write lint hooks
AGENTS.mdProject documentation with Calor-first guidelines

MCP Server Integration

The init command also configures an MCP (Model Context Protocol) server that gives Codex direct access to the Calor compiler. This enables Codex to:

  • Type check code and get semantic errors
  • Verify contracts using the Z3 SMT solver
  • Analyze code for bugs and migration potential
  • Convert between C# and Calor

How It Works

When you open the project in Codex CLI, the MCP server starts automatically based on the .codex/config.toml configuration:

toml
# BEGIN CalorC MCP SECTION - DO NOT EDIT
[mcp_servers.calor]
command = "calor"
args = ["mcp", "--stdio"]
# END CalorC MCP SECTION

Available Tools

ToolPurpose
calor_compileCompile Calor source to C#
calor_checkDiagnose, lint, type check, or validate snippets via action
calor_verifySeven-status Z3 contract verification
calor_analyzeAdvanced bug detection
calor_convertConvert between C# and Calor
calor_formatFormat source to canonical style
calor_session_open / calor_file_writeCross-file checks and transactional writes

See calor mcp for the complete 18-tool surface.


Enforcement

Codex supports project lifecycle hooks. Calor writes a PreToolUse hook for covered apply_patch, Edit, and Write operations plus a PostToolUse lint hook for changed .calr files. Run /hooks, review the generated commands, and trust the exact project configuration before relying on them.

The write hook validates rename destinations and multi-file patches, but it is a guardrail rather than a security boundary. Shell commands and specialized file-change paths can bypass lifecycle hooks. Run the smoke test in bench/phase0-agent-native/CODEX-SMOKE.md and keep repository CI checks enabled.


Project Guidance

calor init --ai codex writes a managed Calor section into AGENTS.md; it does not generate project-local Codex skill files. The guidance covers current indent-only syntax, contracts, effects, IDs, and the required validation loop. Re-running init updates the managed section without replacing unrelated project instructions.


Codex vs Claude Code

FeatureClaude CodeCodex CLI
Project instructionsCLAUDE.mdAGENTS.md
MCP ToolsYesYes
EnforcementHooksHooks for covered tools + AGENTS.md

Best Practices

  1. Review and trust hooks - Confirm both lifecycle hooks are active with /hooks
  2. Run the smoke test - Verify the current Codex tool path triggers the hooks
  3. Use MCP tools - Compile, check, and verify through the consolidated v0.12 surface
  4. Review generated files - Treat hooks as a guardrail and retain CI backstops
  5. Run analysis regularly - Use calor assess to find migration candidates

See Also