Orchestrate OpenAI Codex CLI (ChatGPT Plus subscription) as an adversarial reviewer and module-level implementer under Antigravity supervision. Activate when delegating architecture/code reviews to GPT, dispatching scoped module work orders, verifying/applying isolated changes, running cross-module integration gates, or checking orchestrator health/cleanup.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Codex Orchestrator?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/georgeee817-l-codex-orchestrator)
---
name: codex-orchestrator
description: Orchestrate OpenAI Codex CLI (ChatGPT Plus subscription) as an adversarial reviewer and module-level implementer under Antigravity supervision. Activate when delegating architecture/code reviews to GPT, dispatching scoped module work orders, verifying/applying isolated changes, running cross-module integration gates, or checking orchestrator health/cleanup.
---
# Codex Orchestrator Workflow
Use the `codex-orchestrator` MCP tools (or `node src/cli.mjs`) to collaborate with GPT/Codex across a strict 5-stage engineering loop while protecting the local workspace and ChatGPT Plus quota.
## Core Tools
1. `codex_list_projects` — check registered `project_id`s, root paths, allowed modes, whitelisted test binaries, and `shared_readonly_dirs`.
2. `codex_list_models` — dynamically query available Codex CLI models (live account catalog with `--bundled` fallback), allowed reasoning efforts (up to `max`; `ultra` disabled), configured `profiles`, and `model_aliases`.
3. `codex_review` — read-only GPT review (`--sandbox read-only`, supports `profile: "light" | "standard" | "deep"`, `model`, `reasoning_effort` up to `max`). Never modifies repository files.
4. `codex_implement` — isolated `git worktree` implementation (`--sandbox workspace-write`, supports `profile`, `model`, `reasoning_effort`, `auth_mode`, `ignore_cooldown`), followed automatically by independent filesystem-vs-baseline audit and snapshot `verify_commands`.
5. `codex_apply` — transactional allowlist-only patch application to the target repo (refuses drift, gitignored collisions, or unverified tasks).
6. `codex_integrate` — runs real cross-module `integration_cases` on an isolated snapshot and verifies `candidate_digest`.
7. `codex_status` / `codex_cancel` — inspect state (plus `live_progress` while running) or terminate an active Codex process tree cleanly.
8. `codex_doctor` / `codex_cleanup` — run non-destructive health diagnostics (including model catalog, auth/quota cooldown & 24h usage) or safely prune finished/applied worktrees (never touches `running` or `unknown_needs_reconcile`).
## Pre-flight Capability Routing (Antigravity Controller)
Before dispatching any `codex_review` or `codex_implement` call, Antigravity MUST perform a zero-cost pre-flight routing assessment (never burn an extra GPT call just to pick a profile):
| Tier | Profile | Review Layer (`codex_review`) | Execution Layer (`codex_implement`) | Use When |
| :--- | :--- | :--- | :--- | :--- |
| **L0: Skip GPT** | — | — | — | Quick file lookups, doc/comment tweaks, deterministic <=10-line edits, or running local tests to diagnose trivial errors |
| **L1: Light** | `profile: "light"` | `gpt-6.2-astra` / `medium` / 240s | `gpt-6.2-sol` / `high` / 420s | Routine single-file/glue modules, unit tests, single-point `rework`, lightweight code checks |
| **L2: Standard** | `profile: "standard"` | `gpt-6.2-astra` / `medium` / 360s | `gpt-6.2-sol` / `xhigh` / 720s (500k ctx) | **Primary workhorse (85%–90%+ of calls)**: Normal Stage 2 adversarial design/contract reviews (`astra/medium`), almost all Stage 4 module implementations (`sol/xhigh`), multi-point `rework`, and Stage 5 combined-diff reviews |
| **L3: Deep** | `profile: "deep"` | `gpt-6.2-astra` / `high` / 480s | `gpt-6.2-astra` / `medium` / 900s | **Strictly rationed autonomous ceiling (capped at `quota.max_deep_runs_24h`, default 4/24h)**: ONLY when meeting the 3-criterion admission whitelist below |
| **L4: Elevated (User-Approved)** | Explicit `model` / `reasoning_effort` + `local CLI approval` | `astra/xhigh`, `max`, or `deep` above 24h cap | `astra/xhigh`, `max`, or `deep` above 24h cap | **Requires explicit user approval first**: Subtle multi-module race/security/rollback invariants (`astra/xhigh`), stubborn root-cause bugs (`max`), or extra `deep` runs beyond the 24h budget |
- **Separated Review vs. Execution Routing & Strict `deep` Admission (评审层与执行层分流)**:
- **Review Layer (`codex_review`) = Astra-First (`medium` / `high`)**: Adversarial design reviews and code audits default to **`gpt-6.2-astra` + `medium`** (`light`/`standard`, does NOT burn the 24h heavy `deep` cap), reserving **`gpt-6.2-astra` + `high`** (`deep`) strictly for high-blast-radius blind reviews or security/concurrency red-team audits.
- **Execution Layer (`codex_implement`) = Sol-First (`high` / `xhigh`)**: Isolated worktree coding defaults to **`gpt-6.2-sol` + `high`** (`light`) or **`gpt-6.2-sol` + `xhigh`** (`standard`, 500k context, ~4x lower quota cost). Only escalate `codex_implement` to `deep` (`gpt-6.2-astra/medium`) under whitelist criterion #3.
- **3-Criterion Positive Whitelist (must satisfy at least ONE to justify `profile: "deep"` = `gpt-6.2-astra/high`)**:
1. **High-blast-radius Stage 2 blind review**: Security/auth/permission/sandbox boundaries, process/lock concurrency, atomic rollback/persistence invariants, or destructive production operations/migrations.
2. **Focused security / race-condition / data-corruption red-team audit**.
3. **Complex root-cause bug or kernel-level invariant implementation** ONLY after `standard` (`gpt-6.2-sol/xhigh` for implement or `gpt-6.2-astra/medium` for review) failed to isolate/solve it, or where automated tests cannot cover subtle concurrency/rollback invariants.
- **Explicit Prohibition List (NEVER use `deep` for)**:
- CRUD, UI, glue code, config files, scripts, documentation, or unit tests.
- Routine Stage 4 module implementations whose Stage 3 interface contracts are already locked (use `standard` = `sol/xhigh` or `light` = `sol/high`).
- Normal `rework` fixes (`light` for single-point, `standard` for multi-point).
- Small/medium feature Stage 2 design reviews (use `standard` = `astra/medium`).
- Routine Stage 5 combined-diff reviews (use `standard` = `astra/medium`, or pass `model: "sol"` if the diff exceeds Astra's 272k context).
- **Budget & Mandatory Justification**:
- Soft cap **<= 1–2 `deep` calls per feature/milestone**. Never run consecutive `deep` calls across multiple Stage 4 modules without explicit user approval.
- Before dispatching `profile: "deep"` (or any `astra` run at `high`+ / `implement` mode), explicitly state **which whitelist criterion (1 / 2 / 3)** is satisfied and **why `standard` (`sol/xhigh` for implement or `astra/medium` for review) cannot handle it**; if no concrete security/concurrency/invariant reason exists, immediately downgrade to `standard`.
- When the code-enforced 24h `deep`/Astra budget (`quota.max_deep_runs_24h`, default 4) is reached (`deep_budget_exceeded: true`), downgrade to `standard`/`light` or request explicit user approval before using a locally approved CLI order.
- **Autonomous ceiling vs. L4 escalation request (向用户提出更高推理等级申请)**:
- Without asking, stay within the autonomous profiles (`review`: `astra/medium` or `astra/high`; `implement`: `sol/high`, `sol/xhigh`, or `astra/medium` under `deep`). **`astra/xhigh`**, **`max`** on any model, and extra `deep` runs beyond `max_deep_runs_24h` belong to L4 and require explicit user approval. Do not request L4 on routine modules.
- When you assess that `standard` or `deep` is likely insufficient (e.g., subtle multi-module security/concurrency/rollback invariants or a stubborn root cause after a failed `standard`/`deep` pass), **proactively pause and submit a concise escalation request to the user before calling Codex**:
1. **申请等级 (Target Tier)**: Requested `model` + `reasoning_effort` in progressive cost order — `gpt-6.2-astra` + `xhigh` for frontier multi-module invariants, reserving `max` for extreme cases.
2. **申请理由 (Technical Reason)**: 1–2 concrete reasons why `standard` (`sol/xhigh` / `astra/medium`) or `deep` (`astra/high` / `astra/medium`) may fall short on this task.
3. **额度提示与备选 (Quota & Fallback)**: Note the higher ChatGPT Plus quota draw, and state that if declined, you will proceed with `profile: "deep"` or `"standard"`.
- Use a locally approved CLI order with `--approve-elevated` for elevated work.
- **Dynamic model selection & aliases**: Any valid Codex CLI model slug returned by `codex_list_models` (or configured alias such as `sol` -> `gpt-6.2-sol`, `astra` -> `gpt-6.2-astra`, `terra` -> `gpt-6.1-terra`, `luna` -> `gpt-6-luna`) can be passed explicitly via `model` to override a profile default.
- **Effort cap**: `reasoning_effort` supports `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. `ultra` is hard-blocked by orchestrator policy to prevent automatic subagent delegation and unexpected quota burn.
- **State the routing choice**: In a brief sentence before calling `codex_review` or `codex_implement`, explain which `profile` (and any explicit `model` / `reasoning_effort` override) was chosen and why.
- **Tag module risk once in Stage 2**: On multi-module projects, ask GPT during the Stage 2 architecture review to tag each planned module's risk level (`high` / `medium` / `low`) so Stage 4 dispatches map directly (`high -> standard` [escalate to `deep` ONLY if whitelist criterion #3 applies or after a failed `standard` pass], `medium -> standard` or `light`, `low -> light`) without extra planning calls.
## 5-Stage Engineering Loop
1. **Stage 1 (Prototype & Scope)**: Align requirements, constraints, and rough architecture with the user before calling Codex.
2. **Stage 2 (Adversarial Design Review)**:
- For **high-blast-radius decisions** (security/auth/sandbox boundaries, concurrency/locking, atomic rollback/persistence, or destructive migrations), run a **blind review first**: give `codex_review` (`profile: "deep"`) only goals, constraints, and acceptance criteria to propose independent options before showing Antigravity's draft.
- For normal architecture/contract reviews on small or medium features, use `codex_review` (`profile: "standard"` or `"light"`) to hunt concrete edge cases, race conditions, and contract mismatches.
- For multi-module plans, have GPT tag module risk (`high` / `medium` / `low`) for Stage 4 routing.
3. **Stage 3 (Finalize Contracts & Module Plan)**: Synthesize both perspectives into exact interfaces, per-module `allowed_changes`, unit `verify_commands`, and cross-module `integration_cases`. Get user sign-off.
4. **Stage 4 (Module-by-Module Implementation & Gate)**:
- Dispatch **1–4 tightly related files** per `codex_implement` order with the routed `profile` (`light` or `standard` by default; `deep` only when whitelist criterion #3 holds), explicit interface contracts, and boundaries.
- Only call `codex_apply` after `status === "verified_ready_to_apply"`.
- On failure (`verify_failed` / `failed` / `timed_out`), rework with `rework: true` and the saved `session_id` (capped at `max_code_retries: 2` per work order). Escalate to the user after 2 failed code retries.
5. **Stage 5 (Cross-Module Integration Gate & Final Review)**:
- Run `codex_integrate` across the combined modules using real end-to-end integration tests (never mock-only).
- Optionally run one final read-only `codex_review` (`profile: "standard"` with 500k context by default; use `deep` only for critical security or destructive release sign-offs) on the combined diff before reporting completion.
- Periodically run `codex_cleanup` after modules are applied to keep `state/workspaces/` tidy.
## Quota Exhaustion & Fallback Ladder
If a call returns `status === "rate_limited"` or `cooldown_blocked: true`:
- **Never count quota blocks as code retries** and do not blindly retry the same command in a loop.
- **Tier 1 (Single Tier Downgrade — optional)**: Only if the error clearly indicates tier/model-specific throttling (not account-wide exhaustion), try **at most once** with `profile: "light"` and `ignore_cooldown: true`. Otherwise skip straight to Tier 2.
- **Tier 2 (Primary Fallback — Degraded Local Mode, $0 extra)**:
- **Stage 4 modules**: Antigravity implements the module directly while strictly respecting the planned `allowed_changes` scope, then executes the exact same local `verify_commands` and `codex_integrate` gate.
- **Stage 2 reviews**: For medium/low-risk modules, spawn an isolated Antigravity blind `research`/`self` subagent (given only goals, constraints, and acceptance criteria). For **high-stakes** security/permission/architecture decisions, record them in a `pending_gpt_reviews` list to back-fill with GPT once ChatGPT Plus cooldown expires.
- **Tier 3 (Optional Opt-In API Key Fallback — disabled by default)**:
- `runtime.json` defaults to `auth: { primary: "chatgpt", allow_api_key_fallback: false, api_key_env_var: "OPENAI_API_KEY" }`.
- If the user explicitly enables `allow_api_key_fallback: true` and exports `OPENAI_API_KEY`, the orchestrator automatically fails over once per rate-limited task to `forced_login_method="api"` (or honors `auth_mode: "api_key"`).
## Guardrails & Quota Rules
- **Never count auth/model/quota errors as code retries**: If `auth_required`, ask the user to run `codex login`. If `model_unsupported`, run `codex_list_models` and switch `model` / `profile` to a model supported by the active account.
- **Never bypass project registration**: If a target repo is not in `codex_list_projects`, ask the user for approval first, then register it with `node scripts/setup.mjs register <project_id> <root_path> [--modes review,implement,integrate] [--bin <abs_exe>] [--shared-dep node_modules]`.
- **Never execute unapproved commands**: `verify_commands` and `integration_cases` must reference absolute executable paths registered in the project's `allowed_command_bins`.
- **Preserve failed/reconcile workspaces**: Never force-unlock `unknown_needs_reconcile` without inspecting the workspace and confirming no Codex child process remains alive.