AI tips · No. 2
2026-09-25

Put Claude in charge of Codex and Grok

Claude plans and reviews. Codex builds to a spec. Grok researches and argues.

Using an AI agent? Don't build this by hand. Point your agent at this page; there is a section for it at the bottom.

The problem

I pay for three AI plans: Claude, ChatGPT (for Codex) and Grok. Two of them were sitting unused, because using three agents by hand means three chats and a lot of copy and paste.

The worse problem shows up once they are doing real work. Every agent checks its own work and tells you it passed.

The split

Claude Code is the foreman: it writes the spec, sends the work out, and reviews what comes back. The other two are crew, called headless from Claude's own shell. Work is routed by what it is, not by what is cheapest:

  • Claude, in the session: the plan, the spec, the taste calls and the final review. Never delegated.
  • Codex: a specified build, meaning code or models written to a spec that already exists.
  • Grok: breadth research, a second opinion, an adversarial read of a plan. It is read-only unless told otherwise.
  • Me: anything physical or irreversible. A print, a push, a purchase.
codex exec --sandbox workspace-write --skip-git-repo-check \
  "$(cat task.md)" < /dev/null > codex.log 2>&1

grok -p "$(cat task.md)" --cwd ~/projects/farm \
  --tools read_file,grep,list_dir --output-format json

A bonus: Grok Build reads the same CLAUDE.md files Claude Code does, so the rules I write down once reach both agents.

Every call

A worker call goes out with six things, or it doesn't go out:

  1. A spec file to read first, named by path. The spec is never pasted into the prompt.
  2. The exact output path.
  3. Which part of the spec this worker is the second opinion on.
  4. The acceptance test as literal commands. If you can't write the command that decides whether the output is good, the task isn't ready to hand out.
  5. "You cannot ask a question. Stdin is closed. Where something is open, make the reasonable choice and say what you chose."
  6. "Do NOT run git commit, git add, or git push." Workers write; the session commits.

The review

The review is the whole point of the split. Across eight batches of 3D models the workers handed back a French cleat with its bevel upside down, a joint that was really a T-slot, six models missing a required field, and fifteen files leaking brand names onto public pages. Every one of them passed the worker's own self-check. Claude caught them, by running the checks itself and looking at a render of every model.

The order of escalation: Grok tries first, on everything and in parallel, because it is cheap. Codex gets only what Grok couldn't fix, one at a time. The most expensive model sees only what both failed, and only after I say yes.

What bit

  • Codex hangs forever with stdin open. Called from a script it prints Reading additional input from stdin... and waits. Always redirect < /dev/null. It looks exactly like a slow model.
  • Headless can't answer a permission prompt. Give the worker an allowlist of tools rather than a mode that asks. It will hang otherwise.
  • Telling a read-only worker to write a file doesn't let it. It spends its whole turn budget reading, then dies with max turns reached, an error about turns and not tools.
  • Time out before your harness does. My bridge gives up at 110 seconds, just under Claude Code's default 120-second limit on a command, so the failure is reported instead of the process being killed without a word.
  • Log every exchange with its cost. Two agents talking to each other is billed. My bridge logs a call when it succeeds, so a failed one never appears and the real spend is higher than the log says.
  • More reasoning isn't always better. At a higher reasoning setting, Codex spent 32 minutes double-checking six models that a tight spec had already pinned down.

The result

All three plans do real work now, and I talk to one agent. A batch of models went from 32 minutes to 12 once the spec got strict: an acceptance test of exactly three commands, one file per model, a short header, and a normal reasoning setting instead of a higher one. A Grok consult runs from under two cents for a lookup to about twenty for a hard read of real files. Nothing a worker writes reaches a public page until Claude has checked it.

For your AI agent

Anyone with an AI agent will just tell it to read this and set it up, so this part is written for the agent. Paste something like this into Claude Code:

Read https://jacobkunselman.com/tips/claude-orchestrates-codex-and-grok/agent.md
and set up the same split on my machine: the Grok bridge, the Codex call, and the
routing rules in my CLAUDE.md. Test each worker with one small task.

agent.md is the plain-text spec: the routing rules to drop into CLAUDE.md, the six-part worker call as a template, the two headless invocations, the review gate, and acceptance tests. The reference files: