Skip to content

Commit 04ad432

Browse files
committed
feat: add codex-subagent skill
1 parent 0539906 commit 04ad432

9 files changed

Lines changed: 992 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Repository of Codex skills organized by top-level folder.
44

55
## Skill Folders
66

7+
- `codex-subagent/` - Skills for dispatching parallel tasks to Codex CLI subagents.
78
- `gh/` - Skills for GitHub workflows and automations.
8-
- `review/` - Skills for reviewing artifacts, surfacing issues, and adjudicating claims.
99
- `triangulate/` - Skills for generic multi-agent evaluation workflows that generate, challenge, and adjudicate findings.

codex-subagent/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# codex-subagent
2+
3+
Skills for dispatching parallel tasks to Codex CLI subagents.
4+
5+
## Skills
6+
7+
| Name | Description | Install | Last updated (UTC) |
8+
|---|---|---|---|
9+
| `codex-subagent` | Dispatch parallel tasks to Codex CLI subagents to save Claude Code tokens. Accepts explicit task descriptions, auto-selects sandbox (read-only vs workspace-write) and reasoning effort (high vs xhigh) based on task type, and collects structured results with durable artifacts. | `npx skills install HenryQW/skills codex-subagent -a codex -a claude-code -y` | 2026-03-26 03:30 |

codex-subagent/SKILL.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
name: codex-subagent
3+
description: Dispatch parallel tasks to Codex CLI subagents to save Claude Code tokens. Accepts explicit task descriptions, auto-selects sandbox (read-only vs workspace-write) and reasoning effort (high vs xhigh) based on task type, and collects structured results with durable artifacts.
4+
---
5+
6+
# Codex Subagent
7+
8+
Dispatch 2+ independent tasks to Codex CLI subagents in parallel. Collect structured results with durable artifacts.
9+
10+
## When to Use
11+
12+
- The user or a calling skill needs to run 2+ independent tasks in parallel.
13+
- Tasks can be offloaded to Codex to save Claude Code tokens.
14+
15+
Do NOT use this skill when:
16+
17+
- There is only one task (run `codex e` directly instead).
18+
- Tasks depend on each other's output (run them sequentially instead).
19+
20+
## Task Types (Reference)
21+
22+
`run_batch.py` is the single source of truth for this mapping. This table is informational only.
23+
24+
| Type | Sandbox | Effort |
25+
|---|---|---|
26+
| `review` | read-only | high |
27+
| `analyze` | read-only | high |
28+
| `search` | read-only | high |
29+
| `document` | read-only | high |
30+
| `implement` | workspace-write | xhigh |
31+
| `refactor` | workspace-write | xhigh |
32+
| `debug` | workspace-write | xhigh |
33+
| `architect` | workspace-write | xhigh |
34+
35+
Unknown types default to read-only / high.
36+
37+
## Construct the Task Manifest
38+
39+
1. Receive explicit task descriptions from the user or calling skill.
40+
2. Do NOT invent tasks beyond what was described.
41+
3. Build a manifest JSON with a `tasks` array. Each task requires:
42+
- `id` -- unique string identifier
43+
- `type` -- one of the canonical types above
44+
- `prompt` -- full task instruction string
45+
- `cwd` -- working directory relative to git root (usually `"."`)
46+
47+
Example manifest:
48+
49+
```json
50+
{
51+
"tasks": [
52+
{
53+
"id": "lint-config",
54+
"type": "review",
55+
"prompt": "Review the ESLint configuration for deprecated rules and report findings.",
56+
"cwd": "."
57+
},
58+
{
59+
"id": "add-retry-logic",
60+
"type": "implement",
61+
"prompt": "Add exponential backoff retry logic to src/api/client.ts for transient HTTP errors.",
62+
"cwd": "."
63+
}
64+
]
65+
}
66+
```
67+
68+
## Execution Flow
69+
70+
1. Create `.context/codex-subagent/` if it does not exist.
71+
2. Write the manifest to `.context/codex-subagent/manifest.json`.
72+
3. Run the runner:
73+
74+
```bash
75+
python "<skill-install-path>/codex-subagent/scripts/run_batch.py" \
76+
--manifest ".context/codex-subagent/manifest.json" \
77+
--run-id "$(date +%Y%m%d-%H%M%S)"
78+
```
79+
80+
To specify a model, add `--model <model>`.
81+
82+
4. The runner prints summary JSON to stdout.
83+
84+
## Monitoring Long-Running Tasks
85+
86+
Every 5 minutes while the runner is executing, check `.context/codex-subagent/<run-id>/` for task progress:
87+
88+
- Task directory has only `prompt.txt` -- still launching.
89+
- Task directory has `prompt.txt` + `pid` -- currently running.
90+
- Task directory has `meta.json` (no `pid`) -- completed.
91+
92+
If a read-only task has been running >15 minutes or a workspace-write task >30 minutes, read the `pid` file and consider killing it with `kill <pid>`.
93+
94+
## Presenting Results
95+
96+
1. Read summary JSON from runner stdout.
97+
2. If any task has `truncated: true`, read the full output from `.context/codex-subagent/<run-id>/<task-id>/stdout.txt`.
98+
3. Present results as concatenated per-task outputs with task ID headers.
99+
4. If any task failed, report which ones and offer to retry.
100+
101+
## Write Isolation Warning
102+
103+
When dispatching multiple workspace-write tasks, the caller must ensure non-overlapping file sets. The runner warns but does not prevent overlapping writes. If parallel writes to the same files are needed, run the tasks sequentially instead.
104+
105+
## Exit Codes
106+
107+
| Code | Meaning |
108+
|---|---|
109+
| 0 | All tasks succeeded |
110+
| 1 | One or more tasks failed (partial results available) |
111+
| 2 | Runner error (bad manifest, missing codex, auth failure) |
112+
113+
## Error Recovery
114+
115+
- Exit code 2: verify `codex` is installed and authenticated (`codex login status`).
116+
- Individual task failure: check stderr in `.context/codex-subagent/<run-id>/<task-id>/stderr.txt`.

codex-subagent/scripts/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)