PTENES
MODULE 4.2 · Track 4 · Advanced & cross-environment

🌐 Subagents in Codex and other environments

The subagent isn’t a Claude Code trick—it’s a idea: delegate work to a isolated context and receive only the report. This idea works elsewhere. In this module you’ll write one source .md that works in more than one environment — Claude Code e OpenAI's Codex CLI.

6
Topics
~30
Minutes
Advanced
Level
Portable
Type

Think of a power outlet. The device is the same; the adapter changes depending on the country. The principle (110/220 V, one plug) doesn't change — what changes is the fit. A subagent is the same: the principle—“delegate to an isolated context, receive a summary”—is universal. What changes from one environment to another is the fit: where the file lives, what the frontmatter is called, the tool names. The goal of this module is to write a single .md and plug it into two runtimes.

SKILL.md a portable source adapter.claude/agents adapter~/.codex/prompts Claude Codeagent / skill running Codex CLIprompt / running agent

↑ One source .md; each runtime applies its own adapter. The idea is the same — the fit changes.

Detailed content

1

🧩 The idea is bigger than the tool

Everything you’ve learned so far — a maestro who delegates, a dedicated context window, a clean report — describes a default, not a product. The pattern is: "a large task becomes a subprocess with its own context; only the conclusion comes back". Every serious agent tool needs something like this, because the problem (context filling up, work repeating) is universal. That's why the concept transfers.

🔌 Principle × fit

Separate two things in your mind. The principle is what you delegate and why. The fit is the local paperwork—folder, field name, syntax. Switching environments only changes the fit:

  • •Principle (unchanged): isolate context · one role per agent · return a summary, not the conversation.
  • •Fit (changes): where the file lives · what the frontmatter is called · tool names · who invokes it.
  • •Consequence: 80% of yours .md is reusable; only the shell needs adapting.
What it is:

The realization that a "subagent" is an architectural pattern (delegating to an isolated context), not a feature exclusive to one app.

Why learn:

Frees you from relying on a single tool. Knowledge of the entire workflow becomes useful in any agent runtime, now or in the future.

Key concepts:

Standard × product · principle (stable) × fit (local) · concept portability.

2

🟢 Codex CLI: the same thing, under another name

O Codex CLI (OpenAI’s terminal agent) has the same components, just with different terminology. Where Claude Code says “subagent” and “skill,” Codex talks about prompts e agents Markdown that you save in a folder and invoke. The structure is the same: an instruction file + a trigger + a set of permitted tools.

Concept Claude Code Codex CLI (equivalent)
Delegated unit of worksubagent (.md)Markdown prompt/agent
Reusable skillskill (SKILL.md)saved prompt + AGENTS.md
Where it lives (project).claude/agents/.codex/prompts/
Where it lives (global)~/.claude/agents/~/.codex/prompts/
Project memoryCLAUDE.mdAGENTS.md
How to invoke itautomatic through the description or @nomeexplicit by prompt name (e.g., /nome)

💡 The most important difference

Claude Code auto-routes: the conductor reads the description and decides on its own when to delegate. Codex tends to be more explicit — you call the prompt by name. Same piece, different trigger: there, the description is an automatic magnet; here it becomes another label for you to choose.

What it is: the name-by-name map between Claude Code components and Codex CLI components.
Why learn: with the map, “porting” stops being a translation from scratch and becomes filling in a table of equivalents.
Key concepts: Codex prompt/agent · AGENTS.md × CLAUDE.md · auto-routing × explicit invocation.
3

♻️ Cross-runtime: the idea behind "polyskill"

Instead of maintaining two copies (one for Claude, one for Codex) that drift apart over time, you write one source only and “emits” each runtime's version from it. That's the idea behind a polyskill: one .md portable is the template, and each environment is a build of that mold. One truth, multiple destinations — the opposite of copy and paste.

portable source (the template) rolewho is stepswhat it does outputwhat comes back build → Claude Code+ shell: name, description, tools build → Codex CLI+ shell: prompt, AGENTS.md

📊 Why it’s worth having a single source

Two copies drift apart: you fix a bug in one, forget the other, and within a month they contradict each other. With one source → multiple builds, the fix goes in once, and both environments inherit it. That’s exactly the “clean context” idea from Track 1 applied to your skills repository: less duplication, less drift.

What it is: a single .md portable template that serves as a pattern; each runtime is generated (built) from it.
Why learn: maintains a single source of truth—correct it in one place, and it applies everywhere—instead of copies that diverge.
Key concepts: polyskill · template × build · portable core (role/steps/output) × runtime-specific shell.
4

🛠️ Tool equivalence

The tools have different names, but the capabilities are the same: read a file, search text, list paths, edit, run shell commands. Instead of naming the exact tool in the body of your .md, describe the capability ("read the files", "search by default") — that way, the same text works in both, because each runtime resolves which specific tool to use.

Capability Claude Code Codex / shell
Read a fileReadcat / file reading
Search textGreprg / grep
List paths by defaultGlobfind / ls
Edit fileEdit / Writepatch / shell write
Run commandBashnative shell execution
Search the webWebFetch / WebSearchweb tool (if enabled)

✓ Write the body like this (portable)

  • ✓"Read the changed files and understand the intent."
  • ✓"Search the code for unsafe calls."
  • ✓"Do not modify anything—just report."

✗ Avoid tying it to a tool

  • ✗"Use the tool Grep with a flag -n…" (Claude only)
  • ✗"Call WebFetch in…" (some in Codex)
  • ✗Mentioning exact names in the body limits portability.
What it is: the mapping between named Claude Code tools (Read/Grep/Glob…) and their shell/Codex equivalents.
Why learn: describing the capability instead of the tool name makes the body of the .md run the same in both runtimes.
Key concepts: capability × named tool · Read↔cat, Grep↔rg, Glob↔find · tool-agnostic body.
5

⚖️ What changes × what doesn't change

Before porting, define the boundary. The principle — delegate to an isolated context, one role per agent, return a summary — it works intact across any environment. What changes is the shell: field names, folder, invocation syntax, available tools. Knowing what stays stable keeps you from rewriting what was already right.

✓ What doesn’t change (the principle)

  • ✓Delegate to one isolated context
  • ✓Return report, not the whole conversation
  • ✓One role per agent (without a do-it-all agent)
  • ✓The core: role + steps + output + limits

✗ What changes (the wrapper)

  • ✗Frontmatter field names
  • ✗Folder where the file lives
  • ✗What the agent is like invoked
  • ✗Names of the specific tools

⚠️ The most common portability mistake

Rewrite the core thinking that each runtime needs a different brain. It doesn't: the brain (role, steps, output, limits) is the same. A good port only changes the shell and leave the core untouched — that way both builds behave the same.

What it is: the line separating the invariant (principle/core) from the variable (wrapper/fit) when switching environments.
Why learn: porting is fast when you only touch the shell and never rewrite what already worked.
Key concepts: invariant × variable · core intact · shell adaptable · behavioral parity.
6

🚚 Port a skill — and where the limits are

Porting is a three-step process: extract the core, swap the shell, test parity. But portability has limits: not everything crosses the boundary. Things tightly coupled to a runtime — an exclusive MCP, a specific tool name, a model from just one provider — don't travel and become a adaptation note.

1

Extract the core

What’s the same in both.

Separate role + steps + output + limits from everything else. Rewrite any “use tool X” as a capability (“read,” “search”). This text becomes the portable source.

2

Change the wrapper

The fit for each runtime.

Build the target's frontmatter (Claude: name/description/tools; Codex: prompt + AGENTS.md) and put the file in the right folder for the environment.

3

Test parity

Same input, same output?

Run the same task in both and compare. If Codex doesn't trigger on its own, remember that invocation there is usually explicit—that's a wrapper, not a bug.

🚧 The boundaries (what doesn't cross)

  • →Exclusive tool/MCP of a runtime: leave a note "in Codex, replace with the equivalent shell command".
  • →Single-provider model (e.g., an Opus): in the other environment, choose the corresponding role model.
  • →Auto-routing: a description that triggers automatically in Claude may require an explicit call in Codex.
What it is: the extract → swap the shell → test parity procedure, plus the list of what isn’t portable.
Why learn: provides a repeatable step-by-step process and builds the habit of recording the adaptation note where portability ends.
Key concepts: extract the core · swap the shell · parity test · adaptation note · limitations (MCP, model, routing).
📄

Real example: a portable agent (Claude → Codex)

Here's a doc-summarizer.md written to be portable: the frontmatter is the shell from Claude Code, and the body is the core tool-agnostic. Right after that, the adaptation note shows what to change to run the same file in Codex CLI.

.claude/agents/doc-summarizer.md Markdown + YAML
--- # CASCA (Claude Code) — troca por runtime
name: doc-summarizer
description: Lê documentos longos e devolve um resumo
  curto com os pontos-chave. Use para condensar
  arquivos grandes sem encher o contexto.
tools: Read, Grep, Glob   # só leitura
model: haiku             # barato p/ escanear
---

# MIOLO (portável) — NÃO cita ferramenta por nome
You are a precise document summarizer.

When invoked:
1. Read the target documents and grasp the intent.
2. Search for the key claims, numbers and decisions.
3. Write a summary: 5 bullets, then the source paths.

Output: only the summary. Do not paste raw
content. Do not modify any file.

📝 Adaptation note — run in Codex CLI

  • 1.Folder: move the file from .claude/agents/ for .codex/prompts/ (or the global ~/.codex/prompts/).
  • 2.Frontmatter: Codex doesn't use tools:/model: that way — record the role and rules in the AGENTS.md from the project; the body (main text) stays the same.
  • 3.Tools: "Read/Grep/Glob" turn into cat/rg/find in the shell — the body already says "read/search," so nothing needs to change there.
  • 4.Invocation: instead of auto-triggering via description, call the prompt by name (/doc-summarizer).

🧠 The core (travels intact)

  • Role — "a precise document summarizer".
  • Steps — read, search, summarize (no tool name).
  • Output — 5 bullets + paths.
  • Limits — don't paste it raw or edit it.

🔌 The shell (switch by runtime)

  • Folder — .claude/agents ↔ .codex/prompts.
  • Config — frontmatter ↔ AGENTS.md.
  • Tools — named ↔ shell.
  • Trigger — auto ↔ called by name.
⌨️

Ready-made prompts (copy and paste)

Three prompts to port and cross-run. The pattern is always the same: ask it to preserve the core, adapt shell, and leave a note where portability ends.

Prompt 1 — adapt a subagent for Codex shell swap
Pegue este subagente do Claude Code e adapte para o
Codex CLI. Mantenha o corpo (papel/passos/saída) intacto,
troque só a casca: pasta, frontmatter e invocação. No fim,
liste uma "nota de adaptação" com o que não é portável.
Prompt 2 — make a skill portable (polyskill) one source → multiple builds
Reescreva esta skill como fonte portável: remova nomes
de ferramenta específicos do corpo e descreva a capacidade
("leia", "busque"). Depois emita dois builds — um para
Claude Code, um para Codex — a partir da mesma fonte.
Prompt 3 — map tools across runtimes tool equivalence
Liste as ferramentas que este .md usa no Claude Code
(Read, Grep, Glob, Bash…) e me dê o equivalente de shell
para o Codex. Aponte quais não têm equivalente direto e
precisam virar nota de adaptação.
🖥️

Simulated screen: emitting the source for 2 runtimes

This is how a cross-runtime build appears in the terminal: you run the emitter once on the portable source, and it generates the files for each environment—adapting the shell while keeping the core. Notice the two destinations branching from the same SKILL.md.

polyskill build · doc-summarizer · 2 runtimes ⏱ 00:06
$ polyskill build doc-summarizer.md --all
→ portable source loaded · core: role + steps + output
● build claude-code
okay
→ .claude/agents/doc-summarizer.md (frontmatter: name, description, tools, model)
● build codex
okay
→ .codex/prompts/doc-summarizer.md + note → AGENTS.md
! 1 adaptation note: named tools → shell (cat/rg/find)
✓ 2 runtimes emitted from 1 source · identical core
single source · doc-summarizer.md
core parity
100%

↑ Illustrative recreation of the terminal (not a real screenshot). One source goes in; two builds come out with the same core and different shells.

🎯

Exercise

Take one of your subagents (or the doc-summarizer.md above) and port it to Codex CLI. Deliver two items: the adapted file and a adaptation note with what changed and what isn’t portable.

How to do it

  1. Extract the core: separate role + steps + output + limits; rewrite any tool name as a capability.
  2. Change the wrapper: point to the new folder (.codex/prompts/), where the config goes (AGENTS.md) and how to invoke it.
  3. List the limits: point out at least one thing that no crosses (MCP, provider model, auto-routing) and what to do instead.

✅ Verification criteria — how to know you got it right

Your deliverable passes if it meets the four signals:

  • →O core remained intact — identical role/steps/output for both.
  • →A shell changed — correct folder, config, and invocation for Codex.
  • →The body doesn't mention a tool by name — says "read/search," not Grep.
  • →Exists at least one adaptation note naming a real limitation.

If you had to rewrite the core for Codex, something from the shell probably leaked into the body — go back and isolate it.

Solved example (one line of each)

Core (same): "you are a precise document summarizer · read → search → 5 bullets + paths". Shell (swapped): file in .codex/prompts/, rules in the AGENTS.md, called by /doc-summarizer. Note: "model: haiku doesn't exist in Codex — use the provider's equivalent low-cost/fast model".

✅ Module summary

✓
Idea > tool — a subagent is a pattern (delegating to isolated context), not a feature of just one app.
✓
Codex CLI — same components with another name: prompt/agent, AGENTS.md instead of CLAUDE.md, explicit invocation.
✓
Polyskill — one source .md portable → multiple builds; fix it in one place, and it applies everywhere.
✓
Tool equivalence — Read↔cat, Grep↔rg, Glob↔find; describe the capability, not the name.
✓
Changes × doesn't change — the principle/core stays firm; the shell (folder, fields, trigger, tools) is what adapts.
✓
Port + limits — extract → swap the shell → test parity; anything that doesn't carry over becomes an adaptation note.

Next module:

4.3 — Comparing models by role. Opus/Sonnet/Haiku × GPT/Codex × other providers: which model for each role in the fleet.