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.
↑ One source .md; each runtime applies its own adapter. The idea is the same — the fit changes.
Detailed content
🧩 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
.mdis reusable; only the shell needs adapting.
The realization that a "subagent" is an architectural pattern (delegating to an isolated context), not a feature exclusive to one app.
Frees you from relying on a single tool. Knowledge of the entire workflow becomes useful in any agent runtime, now or in the future.
Standard × product · principle (stable) × fit (local) · concept portability.
🟢 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 work | subagent (.md) | Markdown prompt/agent |
| Reusable skill | skill (SKILL.md) | saved prompt + AGENTS.md |
| Where it lives (project) | .claude/agents/ | .codex/prompts/ |
| Where it lives (global) | ~/.claude/agents/ | ~/.codex/prompts/ |
| Project memory | CLAUDE.md | AGENTS.md |
| How to invoke it | automatic through the description or @nome | explicit 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.
AGENTS.md × CLAUDE.md · auto-routing × explicit invocation.♻️ 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.
📊 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.
.md portable template that serves as a pattern; each runtime is generated (built) from it.🛠️ 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 file | Read | cat / file reading |
| Search text | Grep | rg / grep |
| List paths by default | Glob | find / ls |
| Edit file | Edit / Write | patch / shell write |
| Run command | Bash | native shell execution |
| Search the web | WebFetch / WebSearch | web 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
Grepwith a flag-n…" (Claude only) - ✗"Call
WebFetchin…" (some in Codex) - ✗Mentioning exact names in the body limits portability.
.md run the same in both runtimes.⚖️ 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.
🚚 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.
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.
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.
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
descriptionthat triggers automatically in Claude may require an explicit call in Codex.
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.
--- # 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 theAGENTS.mdfrom the project; the body (main text) stays the same. - 3.Tools: "Read/Grep/Glob" turn into
cat/rg/findin 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.
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.
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.
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.
↑ 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
- Extract the core: separate role + steps + output + limits; rewrite any tool name as a capability.
- Change the wrapper: point to the new folder (
.codex/prompts/), where the config goes (AGENTS.md) and how to invoke it. - 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
AGENTS.md instead of CLAUDE.md, explicit invocation..md portable → multiple builds; fix it in one place, and it applies everywhere.Next module:
4.3 — Comparing models by role. Opus/Sonnet/Haiku × GPT/Codex × other providers: which model for each role in the fleet.