How to Migrate from Claude Code to Codex Without Losing Your Setup

How to Migrate from Claude Code to Codex Without Losing Your Setup

Aident AI

Developer workstation representing a controlled migration from Claude Code to Codex.

How to Migrate from Claude Code to Codex Without Losing Your Setup

Use OpenAI's official migrate-to-codex skill to scan your Claude Code setup, preview the mapping, run a dry migration, and validate the generated Codex files. Migrate instructions, skills, commands, hooks, subagents, and MCP configuration, but review every partial mapping before you delete or stop using the Claude Code source. Start a fresh Codex session with a short handoff document instead of assuming that a large Claude conversation can be resumed safely.

The practical rule is simple: migrate configuration as code, validate behavior, and keep the Claude setup as your rollback until the Codex project passes the same real task.

If you want a second-model review without moving the project, use Codex inside Claude Code for code review instead. The rest of this guide is for an actual project or user-configuration migration.

What Migrates and What Needs Review

The official migrator handles the common project surfaces, but the runtimes are not identical.

Claude Code source

Codex target

What to check

CLAUDE.md or AGENTS.md

AGENTS.md

Claude-only commands, paths, and permission assumptions

.claude/skills/

.agents/skills/

Frontmatter, scripts, references, and permission guidance

.claude/commands/

.agents/skills/source-command-*

Arguments, shell interpolation, file expansion, and routing

.claude/agents/

.codex/agents/

Tools, sandbox, model, skill preload, and delegation behavior

.mcp.json or MCP entries in .claude.json

.codex/config.toml

Transport, environment variables, headers, OAuth, and timeouts

Hooks in Claude settings

.codex/hooks.json

Event coverage, matchers, blocking semantics, and async behavior

Claude plugins and marketplaces

Manual migration

Bundled skills, agents, hooks, MCP servers, and plugin layout

Some mappings are intentionally partial. For example, Codex does not treat a skill's allowed-tools field as a strict permission boundary, some Claude hook events have no Codex equivalent, and SSE MCP servers need a different transport. The migration report marks these cases for review.

Prerequisites

Before writing anything:

  • update Codex and confirm codex --version works;

  • install the official migrate-to-codex skill;

  • commit or back up the current project configuration;

  • identify whether you are migrating a project, global user configuration, or both;

  • list the real workflows that must still work, including hooks, subagents, and connected tools;

  • keep secrets out of copied config files and terminal output.

The commands below assume the skill is installed at .codex/skills/migrate-to-codex/ in the project. Adjust that path if you installed it globally.

Step 1: Scan Without Writing Files

Define the migrator command once:

MIGRATE_TO_CODEX='python3 .codex/skills/migrate-to-codex/scripts/migrate-to-codex.py'

Scan the project-level Claude configuration:

$MIGRATE_TO_CODEX --source ./.claude/ --scan-only

For global configuration, use:

$MIGRATE_TO_CODEX --source ~/.claude/ --scan-only

Expected result: the report lists active and inactive instructions, commands, skills, hooks, agents, plugins, and MCP configuration without creating Codex files.

If expected files are missing, stop here. Confirm the source path and whether your MCP configuration lives in .mcp.json, project settings, or ~/.claude.json.

Step 2: Generate a Plan and Run Doctor

Preview the project targets:

$MIGRATE_TO_CODEX --source ./.claude/ --target ./.codex/ --plan
$MIGRATE_TO_CODEX --source ./.claude/ --target ./.codex/ --doctor

Repeat with ~/.claude/ and ~/.codex/ if you also need the user-level setup.

Expected result: --plan names each generated path, while --doctor separates ready mappings from manual-review items and validation risks. Review the plan before running a write because project and global scopes can contain different instructions or MCP servers.

Step 3: Dry-Run Before the Real Migration

Run the same mapping without writing:

$MIGRATE_TO_CODEX --source ./.claude/ --target ./.codex/ --dry-run

Inspect the proposed AGENTS.md, skills, agents, hooks, and config. In particular, check that the migration will preserve unrelated entries already present in .codex/config.toml.

Then run the migration:

$MIGRATE_TO_CODEX --source ./.claude/ --target ./.codex

Expected result: Codex artifacts are created or updated, and .codex/migrate-to-codex-report.txt records converted, partial, skipped, and manual-review items. Do not use --replace unless you deliberately want the migrator to remove orphaned generated skills or agents.

Step 4: Review Generated Files in Dependency Order

Review these files in order:

  1. AGENTS.md

  2. .agents/skills/

  3. .codex/config.toml

  4. .codex/hooks.json

  5. .codex/agents/

  6. plugin and marketplace items in the migration report

That order keeps shared instructions and tool access stable before you evaluate specialized agents.

Instructions

OpenAI's AGENTS.md documentation explains how Codex discovers project instructions. Remove references that only make sense in Claude Code, such as Claude slash commands or .claude/agents/ paths. If the instructions are provider-neutral, keep one shared source instead of duplicating two documents that will drift.

Skills and commands

Codex discovers reusable workflows as skills. A Claude command may become a generated skill, but placeholders such as $ARGUMENTS, shell-output interpolation, model routing, and automatic file expansion can require a rewrite. Test a concrete invocation rather than trusting the converted text.

MCP servers

Codex stores MCP server configuration in config.toml. Confirm each command, URL, environment variable, header, and timeout. The official mapping supports stdio and Streamable HTTP, but not an SSE-only server. Environment-variable fallbacks and some OAuth fields also need manual work.

For a large catalog, do not make migration harder by loading every tool into every session. Reduce MCP token usage by narrowing the tool surface or discovering tools only when needed.

Hooks and subagents

Claude Code hooks and subagents do not map one-to-one. Verify what can block a command, which matchers still run, what sandbox a subagent inherits, and whether a skill that was previously preloaded now needs explicit instructions. Treat a generated hook or agent marked for review as disabled in your confidence model until its behavior is tested.

Step 5: Validate the Target

Run the official validator:

$MIGRATE_TO_CODEX --validate-target ./.codex

The validator checks configuration syntax, skill frontmatter, custom-agent fields, instruction size, and MCP command availability. Fix every actionable generated-artifact error, then rerun both validation and the dry-run:

$MIGRATE_TO_CODEX --validate-target ./.codex/
$MIGRATE_TO_CODEX --source ./.claude/ --target ./.codex/ --dry-run

Expected result: the target validates, and the second dry-run reveals no unexplained drift from the source.

Step 6: Test One Real Workflow End to End

Static validation does not prove that the migrated setup behaves the same. Choose one representative task that uses instructions, a skill or subagent, and an external tool. Record:

  • the prompt and expected result;

  • which instruction and skill Codex selected;

  • which tool or MCP server it used;

  • whether a hook allowed, blocked, or modified the action as intended;

  • the command, test, or external read that verifies the outcome.

Run the task in a disposable branch or staging-safe environment. Keep the Claude setup available and compare the results. The migration is complete only when the Codex result meets the same acceptance criteria, not merely when the files exist.

Preserve Session Context With a Handoff, Not a Blind Import

Configuration and conversation history are different migration problems. A July 2026 Codex issue about imported Claude sessions reported that very large compacted histories could exceed the model input limit after import. That is a specific reported failure, not proof that every session import fails.

For an active project, create a short handoff.md outside the permanent agent instructions with:

  • the current objective and accepted decisions;

  • files changed and commands already run;

  • unresolved errors or risks;

  • the next concrete step;

  • links to the issue, plan, or pull request that holds durable context.

Start a fresh Codex session, ask it to read the repository instructions plus the handoff, and verify its understanding against the current diff. Do not paste secrets, full chat logs, or stale exploratory detail into the handoff.

Common Migration Failures

Codex Ignores the Migrated Instructions

Confirm the file is named AGENTS.md, is in the expected directory hierarchy, and does not exceed the configured instruction limit. Remove Claude-only path assumptions, then start a new session so discovery runs again.

A Skill Exists but Behaves Differently

Inspect its frontmatter and any manual-migration block. Rewrite Claude runtime features as explicit Codex instructions or scripts, then test one invocation with known inputs and an observable result.

An MCP Server Does Not Start

Run the configured command directly, verify required environment variables exist, and check whether the source used SSE. Migrate SSE-only servers to stdio or Streamable HTTP, and compare the generated authentication fields with the provider's current documentation.

Hooks No Longer Block the Same Actions

Do not assume event names imply identical behavior. Check Codex's current hook coverage and exit-code contract, then test a harmless command that should be allowed and one that should be denied.

Existing Codex Configuration Was Overwritten

Restore the committed file, rerun --plan and --dry-run, and merge only the generated sections you reviewed. Avoid --replace unless removing generated orphans is the explicit goal.

Keep Tool Access Portable Across Claude Code and Codex

Instructions and skills can be stored in the repository, but provider credentials should not be copied between agent configuration files. Aident Loadout gives Claude Code and Codex a shared, scoped way to discover and run connected Actions while credentials remain outside prompts and project files.

Ask either coding agent:

Follow https://aident.ai/SETUP.md

Then connect one staging-safe integration and test the same read-only task in both agents. For the architecture tradeoff, see Local vs Remote MCP Servers and Connect Claude Code and Codex to Real-World Tools.

Use Aident Loadout to run the check. The measurable goal is one successful, equivalent read-only tool call from Claude Code and Codex without copying a provider secret into either configuration.

Sources

Refresh this guide when OpenAI changes the migrator's supported mappings, Codex hook coverage, plugin migration behavior, or session-import handling.

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.