mcpField
C
codex-subagents

codex-subagents

github.com/obraAgent workflows24105 installsUpdated 44w ago
Repository

About codex-subagents

The codex-subagents skill delegates work to background threads so the main context stays lean. It is intended for parallel research, long-running tasks, and work that benefits from separate context, with commands for waiting, checking, and archiving threads.

Key features

  1. 01Launch subagents in background threads
  2. 02Run multiple research tasks in parallel
  3. 03Wait for threads or check their status
  4. 04Send follow-up prompts to stopped threads
  5. 05Archive completed threads and clean old archives

Use cases

  1. 01Research multiple APIs or topics in parallel
  2. 02Move long-running research out of the main context
  3. 03Continue a task after a background thread finishes

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/obra/external-subagents --skill codex-subagents

After installing, type/codex-subagentsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

TODO.md
.gitignore
README.md
.prek.toml
dev/
build.mjs
.editorconfig
.prettierrc
demo-watch.ts
.npmrc
demo-watch-prompt.txt
eslint.config.js
run-prek-install.mjs
package.json
package-lock.json
dev/src/bin/
codex-subagent.ts
dev/src/commands/
archive.ts
log.ts
clean.ts
label.ts
list.ts
status.ts
peek.ts
send.ts
start.ts
wait.ts
watch.ts
dev/src/lib/
backends.ts
controller-id.ts
exec-runner.ts
file-lock.ts

Details

From the project README

Codex Subagents

Overview

codex-subagent offloads work to background threads so your main context stays lean. Threads run detached by default; use wait/peek to check results.

Critical rules:

  1. You cannot send to a running thread. Always wait before sending follow-ups.
  2. Use --permissions read-only or --permissions workspace-write (not workspace-read)

For detailed workflow documentation, see reference/workflow.md.

When to Use

SituationWhy subagents help
Parallel research tasksMultiple threads run simultaneously
Context would bloatResearch stays in separate thread
Long-running workDetached execution, check later

Don't use for: Quick inline questions, tightly-coupled work needing your current state.

Core Workflow

1. start with --prompt    (inline text or stdin)
2. wait/peek → check result
3. send → resume with follow-up (ONLY after thread stops)
4. archive/clean → lifecycle management

The Running Thread Rule

You CANNOT send to a running thread. This is the #1 mistake.

# WRONG - thread might still be running
echo "followup" | codex-subagent send thread-abc --prompt -

# RIGHT - wait first, then send
codex-subagent wait --threads thread-abc
echo "followup" | codex-subagent send thread-abc --prompt -

Resumable statuses: completed, failed, stopped, waiting

Quick Reference

CommandPurposeKey flags
startLaunch new thread--role, --permissions, --prompt, --label, -w
sendResume stopped thread<thread-id>, --prompt, -w
peekRead newest unseen message<thread-id>, --save-response
logFull history<thread-id>, --tail, --json
statusThread summary<thread-id>
waitBlock until threads stop--threads, --labels, --all, --follow-last
listShow threads--status, --label, --role
archiveMove completed to archive--completed, --yes, --dry-run
cleanDelete old archives--older-than-days, --yes

Prompt input: --prompt "text" for simple prompts, --prompt - reads from stdin (for multi-line), -f/--prompt-file for files

Positional thread IDs: peek abc123 works like peek -t abc123

Common Patterns

Simple inline prompt
codex-subagent start --role researcher --permissions read-only \
  --label "quick-task" --prompt "List all exported functions in src/lib/"
Multi-line prompt (heredoc)
cat <<'EOF' | codex-subagent start --role researcher --permissions read-only --label "auth-research" --prompt -
Research authentication patterns in this codebase:
1. Find all auth-related files
2. Document the auth flow
3. Note any security concerns
EOF
Parallel research
# Launch multiple researchers
cat <<'EOF' | codex-subagent start --role researcher --permissions read-only --label "API: Stripe" --prompt -
Research Stripe API authentication methods and best practices
EOF

cat <<'EOF' | codex-subagent start --role researcher --permissions read-only --label "API: Twilio" --prompt -
Research Twilio API authentication methods and best practices
EOF

# Wait for all, see results
codex-subagent wait --labels "API:" --follow-last
Blocking task
# -w blocks until complete (may take minutes)
cat <<'EOF' | codex-subagent start --role researcher --permissions read-only --prompt - -w --save-response result.txt
Analyze error handling patterns in src/
EOF
cat result.txt

Warning: -w blocks for as long as the agent runs. For long tasks, prefer detached mode with wait --follow-last.

Cleanup old work
# Two-phase: archive completed, then clean old archives
codex-subagent archive --completed --yes
codex-subagent clean --older-than-days 30 --yes

Troubleshooting

ProblemCauseFix
"profile does not exist"Wrong permissionsUse read-only or workspace-write (not workspace-read)
"not resumable" errorThread still runningwait first, then send
"different controller"Wrong sessionUse --controller-id or check list
Thread disappearedWas archivedCheck archive dir or re-run task

Checklist

  • start has --role, --permissions, --prompt, and --label
  • Permissions are read-only or workspace-write
  • wait before send (never send to running thread)
  • Results captured with --save-response or peek

Comments

Markdown supported