ai claude-code codex agentic-workflows software-engineering automation multi-agent-systems technical-architecture

Architecting Tool-Agnostic Agentic Workflows: Seamlessly Migrating Claude Code Contexts to Codex

5 min read

Architecting Tool-Agnostic Agentic Workflows: Seamlessly Migrating Claude Code Contexts to Codex

In the rapidly evolving landscape of agentic software engineering, the ability to switch between specialized LLM-driven coding agents is becoming a critical competency. Relying on a single ecosystem creates a single point of failure; if a specific agent hits a reasoning bottleneck or a context window limitation, the developer's velocity drops to zero. The solution lies in tool agnosticism: designing project structures that allow for seamless context handoffs between disparate agents, such as Claude Code and Codex.

This post explores the technical architecture required to maintain a unified knowledge base while navigating the specific configuration nuances of different coding agents.

The Three-Layer Architecture of Agentic Context

To achieve true portability, a project must be decomposed into three distinct layers of abstraction. By separating shared knowledge from tool-specific configurations, we ensure that an agent's "intelligence" is not trapped within a proprietary directory structure.

1. The Shared Knowledge Layer

This is the foundation of the project. It consists of the raw data, documentation, and reference materials that any LLM can ingest. This layer includes:

  • Documentation: Markdown files, API references, and technical wikis.
  • Assets: Brand assets, diagrams, and architectural decision records (ADRs).
  • Scripts: Executable automation scripts and utility functions.
  • Audit Logs: Historical logs of previous development iterations.

Because this layer uses standard file formats (primarily Markdown), it remains agnostic to the agent being used. Whether you are invoking Claude Code or Codex, the underlying truth remains accessible.

2. The Workflow (Skills) Layer

The second layer contains the "skills"—reusable, task-specific logic. In this architecture, skills are implemented as Markdown files containing YAML front matter.

While the directory structure for these skills varies between agents, the content remains identical. For example, a morning_coffee_skill.md can be read by both agents because the logic is encapsulated in the Markdown/YAML structure, even if the path to find that file changes.

effectively 3. The Tool-Specific Configuration Layer

This is where the divergence occurs. Each agent requires a specific directory structure and configuration format to manage its internal state, sub-agents, and local settings.

Claude Code Configuration

Claude Code relies on a specific directory and file convention:

  • cloud.md: The primary instruction set and knowledge base entry point.
  • .cloud/: The configuration directory containing:
    • agents/: Sub-agents defined via Markdown files.
    • skills/: The skill library.
    • settings.local.json: Localized environment settings and preferences.

Codex Configuration

Codex utilizes a different structural paradigm:

  • agents.md: The equivalent of cloud.md, serving as the primary instruction set.
  • .codex/: The configuration directory containing:
    • agents/: Sub-agents, but notably defined using TOML rather than Markdown.
    • config: The primary configuration document.
  • .agents/: A dedicated directory specifically for storing skill files.

Technical Divergence: Markdown vs. TOML

One of the most significant technical hurdles in migration is the format of agent definitions. In Claude Code, agents are defined using Markdown. In Codex, agents are defined using TOML (Tom's Obvious, Minimal Language).

While the semantic content (the instructions, the tools, and the permissions) remains the same, the syntax must be transformed. This transformation is a prime candidate for LLM-driven automation, as the structural mapping is deterministic.

Automating the Migration: The Conversion Prompt

Manually duplicating configuration files is an anti-pattern that leads to "configuration drift." Instead, you can leverage the reasoning capabilities of the agents themselves to perform the migration.

When moving a project from Claude Code to Codex, use the following natural language prompt to instruct the agent:

"I built this project using Claude Code, but I need you, Codex, to be able to use it too. Please:

  1. Create an agents.md file that uses cloud.md as inspiration.
  2. Create a .codex configuration directory.
  3. Migrate all skills from the .cloud/skills directory to the .agents directory.
  4. Convert all agents from the .cloud/agents Markdown files into .codex/agents TOML files.
  5. Research the Codex and Claude Code documentation to ensure all critical configuration parameters are correctly mapped."

By treating the AI as the migration engineer, you ensure that the nuances of the .codex and .agents folders are respected without manual error.

The "Session Handoff" Pattern

The ultimate expression of tool agnosticism is the Session Handoff. This is a specialized skill designed to facilitate the transfer of "active state" between agents.

When an agent (e.g., Claude Code) reaches a point of failure or a logical impasse, the Session Handoff skill executes a summary of the current execution context, including:

  • Active Files: The files currently being modified or analyzed.
  • Active Decisions: The architectural choices made during the current session.
  • Next Steps: The immediate tasks required to progress.

This summary can be copied and pasted into a new terminal session running Codex, allowing the second agent to resume work with zero loss of context.

Operational Best Practices

To maintain a high-performance, multi-agent environment, adhere to these operational principles:

  1. Terminal-Centric Execution: Avoid relying solely on IDE extensions. Running agents directly via the terminal (e.g., typing cloud or codex) allows for better control over environment variables and concurrent execution.
  2. Concurrency Awareness: When running both agents simultaneously in separate terminals, be cautious of race conditions. If both agents attempt to write to the same file concurrently, you risk file corruption or lost updates.
  3. Maintain Tool Agnosticism: Always prioritize the Shared Knowledge layer. If a piece of information is only present in .cloud/ and not in agents.md, it is not truly portable.
  4. Explicit Sub-agent Invocation: Note that Codex sub-agents may not invoke automatically. You must implement explicit calls within your workflows to ensure the agent tree is traversed correctly.

By implementing these structural patterns, you transform your development environment from a single-tool dependency into a robust, multi-agent ecosystem capable of continuous, uninterrupted progress.