{"data":{"slug":"discovered-c9f8e02e7857e75b0b4d7b2597eb1d5264af6c79e651ff50","title":"Codex Leader \u2014 Orchestrating Codex as Your Executor","summary":"Orchestrate OpenAI Codex as a real-time observable Executor \/ Sub-Agent through the `codex-bridge` MCP server (or CLI). Use this skill whenever acting as a Leader agent delegating coding, debugging, refactoring, research, or long-running `\/goal` work to Codex while keeping every invocation traceable and live-visible in Codex Desktop.","url":"https:\/\/skillshunter.net\/skills\/discovered-c9f8e02e7857e75b0b4d7b2597eb1d5264af6c79e651ff50","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-c9f8e02e7857e75b0b4d7b2597eb1d5264af6c79e651ff50","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-c9f8e02e7857e75b0b4d7b2597eb1d5264af6c79e651ff50.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-c9f8e02e7857e75b0b4d7b2597eb1d5264af6c79e651ff50\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Set `leader_approval=True` on `codex_run` or `codex_send` in either `desktop_live` or `headless_rpc` (CLI: `--leader-approval`). This changes an unset or `never` approval policy to `on-request` and forces reviewer `user`.","instructions":"---\nname: codex-leader\ndescription: >-\n  Orchestrate OpenAI Codex (CLI + Desktop) as a real-time observable Executor \/ Sub-Agent\n  through the `codex-bridge` MCP server (or CLI). Use this skill whenever acting as a Leader\n  agent delegating coding, debugging, refactoring, research, or long-running `\/goal` work to\n  Codex while keeping every invocation traceable and live-visible in Codex Desktop.\n---\n\n# Codex Leader \u2014 Orchestrating Codex as Your Executor\n\nYou are the **Leader** (product\/architecture owner, planner, reviewer, and communicator with the human). **Codex** is your **Functional Implementer \/ Executor** (\u529f\u80fd\u5b9e\u73b0\u5668).\nUse the `codex-bridge` MCP tools (or `codex-bridge` CLI fallback) to dispatch, monitor, steer, and audit Codex runs while letting the human watch trajectories in **Codex Desktop**.\n\n## 1. Know Your Executor: Codex Strengths, Weaknesses & Prompting Rules\n\nDesign every prompt around Codex's real behavioral profile:\n\n- **Strengths**: Delivers rigorous, high-quality, well-verified code when requirements, boundaries, and acceptance criteria are unambiguous (e.g., algorithmic\/math tasks, well-specified modules, bug fixes with a concrete reproducer, test-backed refactors).\n- **Weaknesses**:\n  - **Weak human communication**: Often jargon-heavy, terse, or overly low-level; poorly suited for open-ended requirement discovery or user-facing explanation.\n  - **Tunnel vision (rabbit-holing)**: On long-horizon or loosely bounded tasks, Codex can fixate on a local sub-problem or edge case and burn turns\/tokens instead of stepping back.\n\n**Therefore, as Leader you MUST:**\n\n1. **Treat Codex strictly as a Functional Implementer (\u529f\u80fd\u5b9e\u73b0\u5668)**:\n   - Leader owns ambiguous requirements, architectural trade-offs, scope boundaries, and all human-facing communication.\n   - Never forward vague user asks verbatim. Translate them into a self-contained engineering spec: **exact goal, target file paths\/interfaces, explicit non-goals (what NOT to modify), and verifiable acceptance commands** (tests, linters, expected output).\n   - Never relay Codex's raw jargon-heavy response directly to the user\u2014synthesize the outcome into clear, plain language for the human.\n2. **Prevent rabbit-holing (anti-tunnel-vision guardrails)**:\n   - Break large ambiguous projects into small, crisp, verifiable milestones rather than one giant open-ended prompt.\n   - Always include an explicit **stop\/escalation boundary** in the prompt (e.g., *\"If blocked after 2 failed attempts or a design ambiguity arises, stop and report the exact blocker\u2014or call `ask_leader`\u2014instead of guessing or refactoring unrelated code\"*).\n   - When using `\/goal`, always set concrete completion checks and a `goal_token_budget`; monitor long runs and intervene early via `codex_steer`, `codex_interrupt`, or `codex_goal(action=\"pause\")`.\n   - Use `enable_ask_leader=true` (so Codex escalates decisions mid-turn) or `output_schema` (when you want clean structured facts instead of verbose prose).\n\n## 2. Choose the Right Execution Mode\n\n| Mode | When to use | Desktop visibility | Special capabilities |\n| :--- | :--- | :--- | :--- |\n| **`desktop_live`** *(default)* | Standard tasks, interactive coding, `\/goal` runs, anything the user wants to watch live | **Real-time streaming** in Codex Desktop under the project (zero lock conflict, zero manual refresh) | Full Desktop plugins (browser, computer-use, native approvals UI); follow-ups via `codex_send` (`codex queue`) |\n| **`headless_rpc`** | Structured JSON contracts (`output_schema`), mid-turn Leader Q&A (`enable_ask_leader=true`), `codex_steer`, per-turn model\/permission switching, or parallel background workers without stealing window focus | Native trajectory in Desktop upon completion (`open_desktop=true` or manual refresh, zero lock conflict) | `output_schema`, `ask_leader` dynamic tool callback, `codex_steer`, `codex_interrupt` |\n\n> **Rule of thumb**: Prefer `desktop_live` whenever running 1 focused task for the human to observe; switch to `headless_rpc` when you need strict JSON output, `ask_leader` callbacks, or parallel fan-out.\n\n## 3. Select Model, Reasoning Effort, Permissions & `\/goal`\n\nCall `codex_capabilities` once per session if you are unsure which models or profiles exist locally.\n\n- **Model & Effort routing** (adapt to `codex_capabilities` output):\n  - Fast lookups \/ small edits \/ test runs: fast coding model (e.g. `gpt-6.2-sol`) + `effort=\"low\"` or `\"medium\"`.\n  - Deep debugging \/ architecture \/ complex refactors: flagship model (e.g. `gpt-6.2-astra` or `gpt-6-astra`) + `effort=\"high\"` or `\"xhigh\"`.\n  - Autonomous multi-agent delegation: `effort=\"ultra\"`.\n- **Permissions**:\n  - Inspection \/ code review only: `sandbox=\"read-only\"`.\n  - Standard implementation: `sandbox=\"workspace-write\"`, `approval_policy=\"never\"`, `approvals_reviewer=\"auto_review\"` (or `\"user\"` + `approval_policy=\"on-request\"` when human approval in Desktop is desired).\n  - Elevated tasks: `sandbox=\"danger-full-access\"` (only when explicitly justified).\n- **Long-horizon `\/goal` mode**:\n  - Pass `goal=\"<clear verifiable objective>\"` (and optional `goal_token_budget`) in `codex_run` when Codex should iterate autonomously across turns until tests\/checks pass.\n  - Manage later with `codex_goal(action=\"get\"|\"pause\"|\"resume\"|\"clear\")`.\n\n## 4. Standard Leader Workflow\n\n1. **Scope & correlate**: Pick a short `leader_task_id` (e.g. `feat-auth-01`) so every Codex call for the same user request stays grouped in the Leader ledger and clearly titled (`[Leader\/<id>] ...`) in Codex Desktop.\n2. **Dispatch cleanly**:\n   - Single short task (live): `codex_run(cwd=..., prompt=..., mode=\"desktop_live\", model=..., effort=..., sandbox=..., leader_task_id=..., title=...)`.\n   - Multi-file \/ `high`+ effort tasks (may exceed an MCP client's ~3-minute per-call timeout): dispatch with `wait=False`, then check progress with `codex_status` or `codex_wait(timeout_seconds=120)`.\n   - Parallel tasks: call `codex_run(..., mode=\"headless_rpc\", wait=False)` for each subtask, then `codex_wait(run_ids=[...])`.\n3. **Handle mid-turn callbacks (two-way wakeup)**:\n   - If `codex_run` or `codex_wait` returns `status=\"waiting_for_leader\"` with `pending_callbacks`, inspect the question, decide as Leader (or ask the human if a product decision is needed), and call `codex_reply_callback(callback_id=..., answer=...)`.\n   - Check `codex_events(unacked_only=True, ack=True)` to receive Hook notifications (`Stop`, `PermissionRequest`, `SessionEnd`, `Interrupt`) even from threads the human continued manually in Desktop.\n4. **Iterate or verify**:\n   - Follow up on the same thread with `codex_send(thread_id=..., prompt=...)` rather than spawning duplicate threads for small revisions.\n   - Review Executor output via `codex_get_result` \/ `codex_read_thread` and verify key diffs\/tests before reporting back.\n5. **Report to the human with full traceability**:\n   - Summarize what Codex changed and verified in clear, jargon-free language.\n   - Always include the clickable Desktop deep link (`codex:\/\/threads\/<thread_id>`) and `thread_id` so the human can jump straight to the trajectory.\n\n## 5. Reference Docs (Load On Demand)\n\n- Complete tool parameter & return reference: [tools-reference.md](.\/references\/tools-reference.md)\n- Codex Hooks & `ask_leader` bidirectional callback patterns: [hooks-and-callbacks.md](.\/references\/hooks-and-callbacks.md)\n\n## Plan Mode and Leader Approval\n\nUse `codex_run(..., collaboration_mode=\"plan\")` to plan; results expose the latest\n`plan` text. Start implementation with `approved_plan=\"<approved Markdown>\"` and\n`collaboration_mode=\"default\"`, or switch an existing thread with\n`codex_send(..., collaboration_mode=\"default\")` (auto mode selects `headless_rpc`).\nCLI: `run --plan`, `run --approved-plan <text-or-file>`, and\n`send --collaboration-mode default`.\n\nSet `leader_approval=True` on `codex_run` or `codex_send` in **either**\n`desktop_live` or `headless_rpc` (CLI: `--leader-approval`). This changes an unset\nor `never` approval policy to `on-request` and forces reviewer `user`.\nOn `waiting_for_leader`, inspect `pending_callbacks`, then use\n`codex_reply_callback(callback_id=..., answer=..., decision=\"accept\")`.\nDecisions: `accept`, `acceptForSession`, `decline`, `cancel`.\n","use_cases":["Delegate coding tasks to Codex with real-time visibility in Codex Desktop","Monitor and steer Codex runs using `codex-bridge` MCP tools","Handle mid-turn callbacks and make decisions on behalf of the user","Run parallel tasks using `headless_rpc` mode for structured JSON contracts or mid-turn Q&A"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/sssn-tech\/codex-bridge\/blob\/d3a826fbba3f5a2ae9b35f5bd8fc3b2578723f70\/skills\/codex-leader\/SKILL.md","source_commit":"d3a826fbba3f5a2ae9b35f5bd8fc3b2578723f70","license":null,"version":null,"listing_approved_at":"2026-12-02","created_at":"2026-11-30T08:49:25.000000Z","updated_at":"2026-12-02T09:15:00.000000Z","seo_title":"Codex Leader \u2014 Orchestrate OpenAI Codex as an Executor","seo_description":"Use the Codex Leader skill to delegate coding, debugging, refactoring, research, or long-running tasks to OpenAI Codex while maintaining traceability and real-time observ","seo_keywords":["Codex Leader","OpenAI Codex","Executor Agent","Codex Bridge","Real-time Coding","Codex Workflow","Leader Agent","Codex Desktop"]}}