用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Morrison-Lab/ai-config --skill delegate-to-codex命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | delegate-to-codex |
| description | Delegate sidecar task to Codex. |
| user-invocable | true |
| allowed-tools | ["Bash","Read","Write","Edit"] |
Standing rule: for heavy, parallelizable read / draft / verify work, spend the
separately-billed codex CLI (ChatGPT plan) first and keep Claude budget in
reserve. Claude stays the orchestrator — it writes the prompts, assembles the
stages, integrates the outputs — and is the fallback for anything codex
can't finish. Exhaust the current 5-hour codex window, then fall back to Claude
until the window resets. This skill is the mechanism; the preference lives in
memories/delegation.md.
The first two exceptions are stated in terms of work shape, so neither applies when the trigger is what the work reads. The third is not a shape exception at all --- it is about codex being available --- and under a data trigger it inverts rather than applies: the work waits for the window instead of falling back. Both cases are covered in the next section.
Everything above weighs delegation against quota: heavy fan-out earns a codex round-trip, a focused edit does not. A repo can also route work to codex because of what the work reads, and that trigger behaves differently in the one way that matters here.
The quota trigger is a heuristic that yields to workload shape. A data-sensitivity trigger does not yield at all. So read the exceptions above as scoped to the quota rationale: a focused, single-file, critical-path analysis of restricted data matches both of the first two exactly, and still goes to codex.
Two further consequences:
CLAUDE.md defines them and this skill stays the mechanism.
A good definition is mechanical rather than a judgment call --- ucdavis/bcs
uses "under inst/extdata/, anything git ls-files does not list", checkable
with git check-ignore -q, and names the boundary in its own API
(schema-only inspection stays local, collect() goes to codex).Do not infer a data trigger from a repo merely having sensitive data. It applies where the consuming repo has written the rule down.
codex --version # binary at ~/.local/bin/codex
codex login status # expect "Logged in using ChatGPT"
If your setup runs sessions under a cluster/HPC allocation, launch agent-scale codex work on a compute node or allocation, not a shared login node. If login fails or the account is out of quota, skip to step 4 (fall back to Claude).
Write each task's prompt to a file, and — when you need machine-readable results back — a JSON Schema so codex is forced to emit conforming JSON:
WORK=<scratchpad>/codex-run # a scratchpad dir, not the repo
mkdir -p "$WORK/out"
# ... write "$WORK/prompt_<id>.txt" per task, and "$WORK/schema.json" if structured
Fetch anything from the network yourself (e.g. gh issue view) and embed it in
the prompt — -s read-only keeps codex from mutating the repo, and you should
not rely on it having network/tooling for setup.
A single quick call runs in the foreground:
codex exec -C <repo> -s read-only --skip-git-repo-check \
-o "$WORK/out/<id>.json" --output-schema "$WORK/schema.json" \
- < "$WORK/prompt_<id>.txt"
-s read-only for read/analyze/verify (codex can still run rg/cat to
explore); drop to a writable sandbox only for a task that must edit.-o <file> captures the final message; --output-schema <file> forces JSON.- feeds a long prompt.Redirect stdin, always --- codex exec waits on it, and says so once and then blocks.
The - form above does that by construction.
The obvious alternative does not: codex exec "<prompt>" with the brief as a positional argument prints Reading additional input from stdin... and hangs until something kills it.
Nothing about that reads as a failure. There is no error, no usage message, and no partial output, so a foreground call looks exactly like a long review that is still thinking --- which is the one thing a dispatched review legitimately does for minutes at a time. Measured 2026-08-28: a foreground call in that shape sat until a ten-minute tool timeout, having emitted that single line.
- < "$WORK/prompt_<id>.txt", per the block above.< /dev/null when a short prompt really is passed positionally.codex exec as work in progress before checking that its stdin was redirected.Verify these flags against your installed codex-cli version (codex exec --help) — flag names can shift between releases.
Omit -m.
A ChatGPT-account login does not reach every model the CLI will accept on the command line, and the refusal comes from the API rather than from argument parsing, so the flag is accepted and the run dies afterwards.
Measured 2026-08-21: codex exec -m gpt-5.1-codex-max returned 400 invalid_request_error: The 'gpt-5.1-codex-max' model is not supported when using Codex with a ChatGPT account.
The same command with no -m ran normally.
Reach for -m only against an API-key login, and treat a 400 naming the account type as settled rather than retryable.
Don't wrap the call in timeout.
It is a GNU coreutils binary and is absent on macOS, so the wrapper fails before codex starts --- and it fails in a way that reads like codex failing.
The background-orchestrator pattern below is the portable answer to a long run, and it is the one this skill already prescribes.
codex takes ~2–4 min per task, which exceeds the foreground tool timeout —
so for multi-item or long work, run a background orchestrator and poll a
DONE marker (a nohup … & launcher returns immediately, so its completion
signal is NOT the run finishing — poll the marker instead):
cat > "$WORK/run.sh" <<'RUN'
#!/usr/bin/env bash
WORK="<scratchpad>/codex-run"; REPO="<repo>"; MAXPAR=3
export PATH="$HOME/.local/bin:$PATH"
rm -f "$WORK/DONE" "$WORK/status.log"
run_one() {
local id="$1" start=$SECONDS rc sz flag=""
codex exec -C "$REPO" -s read-only --skip-git-repo-check \
-o "$WORK/out/$id.json" --output-schema "$WORK/schema.json" \
- < "$WORK/prompt_$id.txt" > "$WORK/out/$id.codexlog" 2>&1
rc=$?; sz=$(wc -c < "$WORK/out/$id.json" 2>/dev/null || echo 0)
# Gate on failure: unconditional grep false-positives on incidental log mentions (warnings, prompt text).
if [ "$rc" -ne 0 ] || [ "$sz" -eq 0 ]; then
grep -qiE "rate limit|quota|usage limit|429|too many requests" "/out/.codexlog" && flag=
>>
}
<ids…>;
run_one &
[ -ge ]; 2;
;
RUN
+x
bash > 2>&1 &
Then poll for $WORK/DONE in a background Bash task (so the wait itself
doesn't hit the foreground timeout), reading $WORK/status.log for per-item
exit code / byte count / RATELIMIT flags.
Treat an item as codex-failed when its status.log line shows a non-zero rc,
bytes=0 (empty -o), or a RATELIMIT flag. For only those items, redo
the stage with a Claude Agent / Workflow — don't re-route the ones codex
already finished. If the whole window is rate-limited, fall back to Claude for
the remainder and note it; resume on codex after the window resets.
Read the $WORK/out/*.json results, validate them, and integrate. Claude owns
this synthesis step — codex produced the parts, Claude assembles the whole.
select-model — picks which Claude model for a task; this skill picks
whether to run it on codex at all first. Complementary: decide codex-vs-Claude
here, then model tier there.agent-builder's worker-role archetypes — this skill's "verify" work
(via a verify-only prompt, same steps 2–5) is the concrete mechanism for
that taxonomy's "paranoid reviewer, cross-model-family" case: point codex at
Claude's own prior output ("does this design/diff hold up?") instead of only
ever handing codex fresh investigation. Same procedure, different prompt.Workflow tool) — runs fan-out on Claude
subagents. Prefer this skill's codex path first for the read/verify stages to
conserve Claude budget; reserve Workflow for stages codex can't do or once
its window is exhausted.ums / record-learnings — capture any new codex mechanics learned into
the backing memory so this skill stays current.nohup … & launcher's immediate "completion" as the run
finishing — poll the marker, not the launcher.