Skill: Codex Harness Orchestrator
Required before starting: Match the references/usage-examples.md scenarios against the user's utterance.
Core Principles
- 7 Architecture Patterns: Pipeline · Fan-out/Fan-in · Expert Pool · Producer-Reviewer · Supervisor · Hierarchical · Handoff
- Agent Definition: TOML format —
.codex/agents/{name}.toml
- Skill Format: SKILL.md —
.codex/skills/{name}/SKILL.md
- Project Context:
AGENTS.md — Path hierarchy: global ~/.codex/AGENTS.md → repo AGENTS.md → subdirectory (more specific file takes precedence). Short and precise files are better than long and vague ones.
- State Persistence:
_workspace/ file-based brokering
- Permission Control: TOML
sandbox_mode field — read-only | workspace-write | danger-full-access
- Subagent Constraint: Only the orchestrator may spawn subagents.
max_depth=1 (default) enforced.
- File I/O: Prefer
apply_patch (surgical edits). New files via shell write.
- Zero-Tolerance Failure Protocol: Arbitrary skipping is strictly prohibited. Maximum 2 retries (3 attempts total) →
Blocked.
Plan Mode
Always run the Plan Mode procedure before building a multi-stage harness.
- Activation: Collect context via
request_user_input → clarifying questions → build a solid plan, then implement
- Required cases: New builds, architecture changes, Stage additions
- May be skipped: Simple single-item tasks with a clearly scoped change (e.g., minor skill checklist edits)
Plan Mode Procedure (request_user_input-based)
PROCEDURE plan_mode(user_request):
// 1. Context collection
questions ← []
IF domain/goal is unclear:
questions.append("Please describe the goal and domain of the harness you want to build in detail.")
IF pattern cannot be determined:
questions.append("Do you have a preference for the agent team structure (Pipeline, Fan-out, Supervisor, etc.)?")
IF agent count/roles are unclear:
questions.append("Please list the agent roles you need.")
IF questions is not empty:
CALL request_user_input(questions) // Bundle all questions into one call
RETURN // Re-enter after receiving responses
// 2. Plan presentation and user approval
plan_summary ← Summary of domain, pattern, agent list, Stage/Step structure
CALL request_user_input(
"We will build the harness with the following plan. Shall we proceed?\n\n{plan_summary}"
)
RETURN // Enter Phase 1 after approval
request_user_input delivers multiple questions in a single call. Multiple unnecessary calls are prohibited.
Useful Slash Commands
| Command |
Purpose |
/plan |
Toggle Plan Mode (same as Shift+Tab) |
/compact |
Summarize previous context in a long thread — saves context |
/fork |
Branch while preserving the current thread — use for experiments |
/resume |
Resume a saved conversation |
/review |
Code review — compare base branch, uncommitted changes, specific commit |
Thread Strategy: 1 harness = 1 thread. Use /compact when context grows large. Use /fork for branching experiments. Start a new thread when the unit of work changes.
Workflow
Phase 0: Status Audit (Mode Branching)
Check for the existence of .codex/agents/, .codex/skills/, AGENTS.md, _workspace/checkpoint.json:
| State |
Mode |
Entry Phase |
| None exist |
New build |
Phase 1 |
| Some exist |
Expansion |
Phase 1 (see expansion-matrix.md) |
checkpoint.json in_progress |
Resume |
Resume from Phase 5 |
checkpoint.json blocked |
Ops/Modify |
Resolve blockage, then resume Phase 5 |
Phase 1: Domain Analysis + Pattern Matching
- Analyze user request → Extract domain, goals, and constraints.
- Match against
references/usage-examples.md scenarios → Derive pattern and Stage/Step structure.
- Check non-trigger utterances — prevent false positives.
Phase 2: Virtual Team Design
Separate agent responsibilities (single responsibility principle).
Select pattern (see references/agent-design-patterns.md).
Determine sandbox_mode for each agent:
| Agent Type |
sandbox_mode |
Rationale |
| Researcher / Analyst |
read-only |
File reading and web research only, no writes |
| Architect / Planner (consultative) |
read-only |
Returns analysis/opinion as text only — orchestrator captures output and writes to findings.md |
| Architect / Planner (document-producing) |
workspace-write |
Directly writes design docs (architecture.md, plan.md, etc.) to _workspace/{plan_name}/ |
| Coder / Developer |
workspace-write |
Directly creates and modifies code and documentation files |
| Reviewer / QA Inspector |
workspace-write |
Creates report files + runs tests |
| State Manager |
workspace-write |
CRUD on checkpoint, task, and findings files |
| Operator / Deployer |
danger-full-access |
Executes external processes such as kubectl, terraform, etc. |
Architect/Planner mode selection: Use read-only (consultative) when the orchestrator instructs "analyze and return opinion." Use workspace-write (document-producing) when the orchestrator instructs "write the design doc to _workspace/." Never assign read-only to an agent whose prompt says to write files — this will silently fail.
Subagent constraint check: Agents other than the orchestrator must not spawn subagents.
Phase 3: Agent TOML Creation
Create .codex/agents/{name}.toml. Reference: references/schemas/agent-worker.template.toml.
Required fields: name, description, developer_instructions, model, sandbox_mode, model_reasoning_effort.
model_reasoning_effort guidelines: low (StateManager) / medium (Analyst, Researcher) / high (Coder, QA, Reviewer) / xhigh (Orchestrator, Architect). Details: references/schemas/models.md.
Model ID SoT: references/schemas/models.md — do not guess arbitrary model IDs.
Phase 4: Procedure Skill Creation
Write .codex/skills/{orchestrator-name}/SKILL.md. Reference: references/schemas/agent-orchestrator.template.md.
Bundle schema files: Copy all 10 items from references/schemas/ → .codex/skills/{name}/references/schemas/ (9 schemas + state.py).
Phase 5: Integration and Orchestration
Create _workspace/, _workspace/{plan_name}/, _workspace/tasks/, _workspace/_schemas/.
Schema sync: Copy all 9 schemas from references/schemas/ → _workspace/_schemas/. Also copy references/schemas/state.py → _workspace/state.py (separate destination — callable as python _workspace/state.py).
Write workflow.md — Stage-Step structure, 6 required fields, verifiable exit conditions.
Initialize findings.md (sections by pattern).
Initialize tasks.md.
Create checkpoint.json (status: in_progress).
Update AGENTS.md — Add harness pointer:
## Harness: {plan_name}
> **Entry point:** Always invoke `@{orchestrator-agent}` first. It loads `.codex/skills/{orchestrator-name}/SKILL.md` and spawns worker subagents per workflow.md. Direct `@worker` calls without the orchestrator are prohibited.
> **Orchestrator role boundary (strict):**
> - Orchestrator = **subagent coordination only**. It reasons, routes, and spawns — nothing else.
> - Orchestrator does **NOT** read/write `checkpoint.json`, `findings.md`, `tasks.md`, or any `_workspace/` files directly.
> - All state I/O (checkpoint updates, task upserts, findings appends) is **delegated to `@state-manager`** via subagent spawn.
> - If `@state-manager` is absent from the virtual team, the orchestrator may perform state I/O as a fallback — but this is an exception, not the norm.
- Orchestrator: `.codex/agents/{orchestrator-agent}.toml` + `.codex/skills/{orchestrator-name}/SKILL.md`
- State Manager: `.codex/agents/state-manager.toml` — owns all `_workspace/` reads and writes
- Agents: {agent list + .codex/agents/ paths}
- Workflow: `_workspace/workflow.md`
- Checkpoint: `_workspace/checkpoint.json`
Phase 6: Validation
Pattern-based Codex Coordination
Based on Codex subagent spawn. Default parallel execution — sequential execution is separated by skill directives per stage:
| Pattern |
Codex Coordination Method |
pipeline |
Sequential spawn per stage — confirm previous stage task_*.json status=done before next |
fan_out_fan_in |
Parallel spawn → ATOMIC aggregation after all complete |
producer_reviewer |
Spawn producer → check task → spawn reviewer → check verdict |
expert_pool |
Automatic routing based on Codex description |
supervisor |
Dynamic spawn based on tasks.md claim |
hierarchical |
Spawn team lead → team lead spawns workers (max_depth=2 required: .codex/config.toml) |
handoff |
Parse [NEXT_AGENT:name] → sequential spawn |
Output Artifacts
{project}/
├── .codex/
│ └── agents/{name}.toml # Agent definition (TOML)
│ └── skills/{orchestrator}/
│ ├── SKILL.md
│ └── references/schemas/ # Schema copies (10 items: 9 schemas + state.py)
├── _workspace/
│ ├── state.py # State manager CLI (token-efficient reads/writes)
│ ├── _schemas/
│ ├── workflow.md
│ ├── findings.md
│ ├── tasks.md
│ ├── checkpoint.json
│ └── tasks/task_{agent}_{id}.json
└── AGENTS.md # Harness pointer + project context
Error Handling
Zero-Tolerance: Agent failure → maximum 2 retries → if unresolved, set task_*.json status=blocked + HALT.
Reference Documents
references/usage-examples.md — Trigger utterance scenarios + mode mapping
references/agent-design-patterns.md — 7 patterns + Codex sandbox permission mapping
references/orchestrator-template.md — Step 0~5 pseudocode (Codex version)
references/schemas/models.md — Model ID source of truth (OpenAI)
references/schemas/agent-worker.template.toml — Worker agent TOML reference
references/schemas/state.py — State manager CLI source (deployed to _workspace/state.py at init)
references/schemas/ — Runtime schema SoT (9 schemas + state.py = 10 items total)
Source: tae2089/harness — distributed by TomeVault.
1---2name: tae2089-harness-codex-harness3description: Skill: Codex Harness Orchestrator4---56# Skill: Codex Harness Orchestrator78> **Required before starting:** Match the `references/usage-examples.md` scenarios against the user's utterance.910## Core Principles11121. **7 Architecture Patterns:** Pipeline · Fan-out/Fan-in · Expert Pool · Producer-Reviewer · Supervisor · Hierarchical · Handoff132. **Agent Definition:** TOML format — `.codex/agents/{name}.toml`143. **Skill Format:** SKILL.md — `.codex/skills/{name}/SKILL.md`154. **Project Context:** `AGENTS.md` — Path hierarchy: global `~/.codex/AGENTS.md` → repo `AGENTS.md` → subdirectory (more specific file takes precedence). Short and precise files are better than long and vague ones.165. **State Persistence:** `_workspace/` file-based brokering176. **Permission Control:** TOML `sandbox_mode` field — `read-only | workspace-write | danger-full-access`187. **Subagent Constraint:** Only the orchestrator may spawn subagents. `max_depth=1` (default) enforced.198. **File I/O:** Prefer `apply_patch` (surgical edits). New files via shell write.209. **Zero-Tolerance Failure Protocol:** Arbitrary skipping is strictly prohibited. Maximum 2 retries (3 attempts total) → `Blocked`.2122## Plan Mode2324**Always run the Plan Mode procedure before building a multi-stage harness.**2526- Activation: Collect context via `request_user_input` → clarifying questions → build a solid plan, then implement27- Required cases: New builds, architecture changes, Stage additions28- May be skipped: Simple single-item tasks with a clearly scoped change (e.g., minor skill checklist edits)2930### Plan Mode Procedure (request_user_input-based)3132```33PROCEDURE plan_mode(user_request):34 // 1. Context collection35 questions ← []36 IF domain/goal is unclear:37 questions.append("Please describe the goal and domain of the harness you want to build in detail.")38 IF pattern cannot be determined:39 questions.append("Do you have a preference for the agent team structure (Pipeline, Fan-out, Supervisor, etc.)?")40 IF agent count/roles are unclear:41 questions.append("Please list the agent roles you need.")4243 IF questions is not empty:44 CALL request_user_input(questions) // Bundle all questions into one call45 RETURN // Re-enter after receiving responses4647 // 2. Plan presentation and user approval48 plan_summary ← Summary of domain, pattern, agent list, Stage/Step structure49 CALL request_user_input(50 "We will build the harness with the following plan. Shall we proceed?\n\n{plan_summary}"51 )52 RETURN // Enter Phase 1 after approval53```5455> `request_user_input` delivers multiple questions in a single call. Multiple unnecessary calls are prohibited.5657## Useful Slash Commands5859| Command | Purpose |60| ---------- | ----------------------------------------------------------------------- |61| `/plan` | Toggle Plan Mode (same as Shift+Tab) |62| `/compact` | Summarize previous context in a long thread — saves context |63| `/fork` | Branch while preserving the current thread — use for experiments |64| `/resume` | Resume a saved conversation |65| `/review` | Code review — compare base branch, uncommitted changes, specific commit |6667> **Thread Strategy:** 1 harness = 1 thread. Use `/compact` when context grows large. Use `/fork` for branching experiments. Start a new thread when the unit of work changes.6869## Workflow7071### Phase 0: Status Audit (Mode Branching)7273Check for the existence of `.codex/agents/`, `.codex/skills/`, `AGENTS.md`, `_workspace/checkpoint.json`:7475| State | Mode | Entry Phase |76| ----------------------------- | ---------- | ------------------------------------- |77| None exist | New build | Phase 1 |78| Some exist | Expansion | Phase 1 (see expansion-matrix.md) |79| checkpoint.json `in_progress` | Resume | Resume from Phase 5 |80| checkpoint.json `blocked` | Ops/Modify | Resolve blockage, then resume Phase 5 |8182### Phase 1: Domain Analysis + Pattern Matching83841. Analyze user request → Extract domain, goals, and constraints.852. Match against `references/usage-examples.md` scenarios → Derive pattern and Stage/Step structure.863. Check non-trigger utterances — prevent false positives.8788### Phase 2: Virtual Team Design89901. Separate agent responsibilities (single responsibility principle).912. Select pattern (see `references/agent-design-patterns.md`).923. Determine `sandbox_mode` for each agent:9394 | Agent Type | sandbox_mode | Rationale |95 | ------------------------------------------ | -------------------- | ---------------------------------------------------------------------------------------------- |96 | Researcher / Analyst | `read-only` | File reading and web research only, no writes |97 | Architect / Planner _(consultative)_ | `read-only` | Returns analysis/opinion as text only — orchestrator captures output and writes to findings.md |98 | Architect / Planner _(document-producing)_ | `workspace-write` | Directly writes design docs (architecture.md, plan.md, etc.) to `_workspace/{plan_name}/` |99 | Coder / Developer | `workspace-write` | Directly creates and modifies code and documentation files |100 | Reviewer / QA Inspector | `workspace-write` | Creates report files + runs tests |101 | State Manager | `workspace-write` | CRUD on checkpoint, task, and findings files |102 | Operator / Deployer | `danger-full-access` | Executes external processes such as kubectl, terraform, etc. |103104 > **Architect/Planner mode selection:** Use `read-only` (consultative) when the orchestrator instructs "analyze and return opinion." Use `workspace-write` (document-producing) when the orchestrator instructs "write the design doc to `_workspace/`." **Never assign `read-only` to an agent whose prompt says to write files** — this will silently fail.1051064. **Subagent constraint check:** Agents other than the orchestrator must not spawn subagents.107108### Phase 3: Agent TOML Creation109110Create `.codex/agents/{name}.toml`. Reference: `references/schemas/agent-worker.template.toml`.111112Required fields: `name`, `description`, `developer_instructions`, `model`, `sandbox_mode`, `model_reasoning_effort`.113114> `model_reasoning_effort` guidelines: `low` (StateManager) / `medium` (Analyst, Researcher) / `high` (Coder, QA, Reviewer) / `xhigh` (Orchestrator, Architect). Details: `references/schemas/models.md`.115116> **Model ID SoT:** `references/schemas/models.md` — do not guess arbitrary model IDs.117118### Phase 4: Procedure Skill Creation119120Write `.codex/skills/{orchestrator-name}/SKILL.md`. Reference: `references/schemas/agent-orchestrator.template.md`.121122Bundle schema files: Copy all 10 items from `references/schemas/` → `.codex/skills/{name}/references/schemas/` (9 schemas + `state.py`).123124### Phase 5: Integration and Orchestration1251261. Create `_workspace/`, `_workspace/{plan_name}/`, `_workspace/tasks/`, `_workspace/_schemas/`.1272. Schema sync: Copy all 9 schemas from `references/schemas/` → `_workspace/_schemas/`. Also copy `references/schemas/state.py` → `_workspace/state.py` (separate destination — callable as `python _workspace/state.py`).1283. Write `workflow.md` — Stage-Step structure, 6 required fields, verifiable exit conditions.1294. Initialize `findings.md` (sections by pattern).1305. Initialize `tasks.md`.1316. Create `checkpoint.json` (status: `in_progress`).1327. **Update AGENTS.md** — Add harness pointer:133134 ```markdown135 ## Harness: {plan_name}136137 > **Entry point:** Always invoke `@{orchestrator-agent}` first. It loads `.codex/skills/{orchestrator-name}/SKILL.md` and spawns worker subagents per workflow.md. Direct `@worker` calls without the orchestrator are prohibited.138139 > **Orchestrator role boundary (strict):**140 > - Orchestrator = **subagent coordination only**. It reasons, routes, and spawns — nothing else.141 > - Orchestrator does **NOT** read/write `checkpoint.json`, `findings.md`, `tasks.md`, or any `_workspace/` files directly.142 > - All state I/O (checkpoint updates, task upserts, findings appends) is **delegated to `@state-manager`** via subagent spawn.143 > - If `@state-manager` is absent from the virtual team, the orchestrator may perform state I/O as a fallback — but this is an exception, not the norm.144145 - Orchestrator: `.codex/agents/{orchestrator-agent}.toml` + `.codex/skills/{orchestrator-name}/SKILL.md`146 - State Manager: `.codex/agents/state-manager.toml` — owns all `_workspace/` reads and writes147 - Agents: {agent list + .codex/agents/ paths}148 - Workflow: `_workspace/workflow.md`149 - Checkpoint: `_workspace/checkpoint.json`150 ```151152### Phase 6: Validation153154- [ ] `.codex/agents/*.toml` required fields complete (name, description, developer_instructions, model, sandbox_mode, model_reasoning_effort)155- [ ] `.codex/skills/*/SKILL.md` frontmatter name and description validated156- [ ] workflow.md schema validated (6 required fields + verifiable exit conditions, no natural language)157- [ ] workflow.md cycle check158- [ ] `_workspace/_schemas/` all 9 files present159- [ ] `_workspace/state.py` exists and executable (`python _workspace/state.py --help`)160- [ ] `AGENTS.md` harness section added — includes orchestrator entry point, skill path, agent list, workflow/checkpoint paths161- [ ] `checkpoint.json` status is `in_progress`162163## Pattern-based Codex Coordination164165Based on Codex subagent spawn. Default parallel execution — sequential execution is separated by skill directives per stage:166167| Pattern | Codex Coordination Method |168| ------------------- | ----------------------------------------------------------------------------------------- |169| `pipeline` | Sequential spawn per stage — confirm previous stage `task_*.json` status=done before next |170| `fan_out_fan_in` | Parallel spawn → ATOMIC aggregation after all complete |171| `producer_reviewer` | Spawn producer → check task → spawn reviewer → check verdict |172| `expert_pool` | Automatic routing based on Codex description |173| `supervisor` | Dynamic spawn based on tasks.md claim |174| `hierarchical` | Spawn team lead → team lead spawns workers (`max_depth=2` required: `.codex/config.toml`) |175| `handoff` | Parse `[NEXT_AGENT:name]` → sequential spawn |176177## Output Artifacts178179```180{project}/181├── .codex/182│ └── agents/{name}.toml # Agent definition (TOML)183│ └── skills/{orchestrator}/184│ ├── SKILL.md185│ └── references/schemas/ # Schema copies (10 items: 9 schemas + state.py)186├── _workspace/187│ ├── state.py # State manager CLI (token-efficient reads/writes)188│ ├── _schemas/189│ ├── workflow.md190│ ├── findings.md191│ ├── tasks.md192│ ├── checkpoint.json193│ └── tasks/task_{agent}_{id}.json194└── AGENTS.md # Harness pointer + project context195```196197## Error Handling198199Zero-Tolerance: Agent failure → maximum 2 retries → if unresolved, set task\_\*.json status=blocked + HALT.200201## Reference Documents202203- `references/usage-examples.md` — Trigger utterance scenarios + mode mapping204- `references/agent-design-patterns.md` — 7 patterns + Codex sandbox permission mapping205- `references/orchestrator-template.md` — Step 0~5 pseudocode (Codex version)206- `references/schemas/models.md` — Model ID source of truth (OpenAI)207- `references/schemas/agent-worker.template.toml` — Worker agent TOML reference208- `references/schemas/state.py` — State manager CLI source (deployed to `_workspace/state.py` at init)209- `references/schemas/` — Runtime schema SoT (9 schemas + state.py = 10 items total)210211---212> Source: [tae2089/harness](https://github.com/tae2089/harness) — distributed by [TomeVault](https://tomevault.io).213<!-- tomevault:4.0:skill_md:2026-05-23 -->