agentleFS
VallykrieVallykrie/swarmGPT/skills/codex-swarm/SKILL.md

codex-swarm

Skill2 starsChanged 3 months agoMITView on GitHub

Use BEFORE writing or editing code, tests, docs, or other content yourself — whenever the writing spans more than one file or more than ~20 lines. Delegating the writing to Codex sessions via the `codex` CLI is the default; you orchestrate. Also use when the user asks to swarm/fan out/parallelize work across Codex or GPT, or invokes /codex-swarm. Triggers include implementing a feature, scaffolding or creating files, refactors, migrations, bulk edits, boilerplate, test suites, documentation, and multi-topic research. Skip only for trivial edits (a few lines in one file) or when the codex CLI is unavailable.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. magnusrodseth/dotfiles★ 3same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. About 0 are common, 13 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before you write anything, apply this rule:

    line 19
  2. Distinctive:

    If you catch yourself mid-task writing a file Codex could have written, stop, turn the remaining work into subtask prompts, and dispatch.

    line 30
  3. Very specific:

    If codex exec later fails every job with an auth error, stop and tell the user to run codex login in a terminal.

    line 49
  4. Very specific:

    If none was given, use default.

    line 55
  5. Distinctive:

    No two subtasks may write the same file or depend on each other's output.

    line 73
  6. Distinctive:

    Prefer splits along existing boundaries: different files, modules, directories, or research topics.

    line 74
  7. Distinctive:

    If a task has a genuinely sequential core, keep that core for yourself and swarm only the independent parts.

    line 76
  8. Distinctive:

    Before dispatch, check the ownership map: every required file has exactly one owner, and no file has two.

    line 89
  9. Distinctive:

    If dispatch stops with "codex … is too old", relay its upgrade instructions to the user and stop.

    line 114
  10. Very specific:

    Create one prompt file per subtask in a temp directory (e.g.

    line 121
  11. Distinctive:

    Otherwise: run the script yourself from the project root, in one call, with a Bash timeout of at least 20 minutes:

    line 155
  12. Very specific:

    Every job launches concurrently and the script blocks until all finish.

    line 162
  13. Very specific:

    Add --jobs N if the user asks you to limit concurrency.

    line 169
  14. Distinctive:

    Read the actual diff for every file a subtask claims it touched.

    line 176
  15. Distinctive:

    Check cross-subtask compatibility: imports, interfaces, naming, shared assumptions, generated artifacts.

    line 177
  16. Distinctive:

    Run integration-level verification: focused tests first, then broader tests, type checks, lint, or build as risk warrants.

    line 179
  17. Very specific:

    Ensure the run log exists at .codex-swarm/logs/<ISO-timestamp>.md (the dispatcher subagent writes it.

    line 184
  18. Distinctive:

    If the project is read-only or the request forbids writes, skip the log file and put the same fields inline in your final message instead.

    line 207
  19. Distinctive:

    Stop and return to the relevant step if any of these happen:

    line 215

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

codex-swarm

You are the orchestrator: you plan, decompose, route, and review. codex exec sessions running GPT-6 do the writing and the token-heavy bulk work. Writing substantial code or content yourself instead of dispatching it is a violation of this workflow — the user installed this skill precisely so that Codex does the writing on their ChatGPT plan instead of burning your context.

Verified against Codex CLI 0.158.0 (the GPT-6 models require it). Re-check codex exec --help if flags seem wrong — this CLI changes fast.

Delegate by default

Before you write anything, apply this rule:

  • Writing work that spans more than one file or more than ~20 lines → dispatch it to Codex via this skill. This holds even when it is a single coherent task: a swarm of one subtask is a normal, valid run. Parallel fan-out is an optimization, not a precondition.
  • Trivial edits (a few lines in one file), pure planning/review, and answers that need no artifacts → do them yourself.
  • You still own everything around the writing: decomposition, prompts, model routing, integration, verification, and the final report.

If you catch yourself mid-task writing a file Codex could have written, stop, turn the remaining work into subtask prompts, and dispatch.

Excuse for writing it yourselfReality
"It's faster if I just write it"Dispatch overhead is seconds; Codex writes while your context stays free for review.
"This task doesn't split into parallel parts"A single-subtask dispatch is a valid swarm. Splitting is optional.
"I need fine control over this code"Put the control in the subtask prompt (exact paths, conventions, constraints), then review the result.
"The user didn't ask for a swarm"The user installed this skill so Codex does the writing by default. Explicit invocation is not required.
"I'm already halfway through writing it"Sunk cost. Dispatch the remaining files.

Step 0 — Preflight

  1. command -v codex — if missing, stop and tell the user to install the Codex CLI (npm install -g @openai/codex) and run codex login.
  2. Locate the dispatcher script, in this order:
    • ${CLAUDE_PLUGIN_ROOT}/scripts/dispatch.sh (plugin install)
    • scripts/dispatch.sh next to this SKILL.md (standalone skill install)
    • $(dirname "$0")/../../scripts/dispatch.sh (repo checkout)
  3. If codex exec later fails every job with an auth error, stop and tell the user to run codex login in a terminal. Never paste a key into chat.

Step 1 — Resolve the sandbox mode

The /codex-swarm command (or the user directly) supplies one of four modes. If none was given, use default.

ModeDispatch flagWhat the Codex jobs may do
defaultmirror the hostIf you are running with auto-accepted/bypassed permissions, use --auto. If your own edits require user review, use --readonly.
auto--auto--sandbox workspace-write: write anywhere in the project, no network, no approval prompts. This is the normal mode for write tasks.
readonly--readonly--sandbox read-only: read and analyze only. Jobs report findings or emit patches for you to apply. Use for research and for review-mode hosts.
yolo--yolo--dangerously-bypass-approvals-and-sandbox: no sandbox at all. Only when the user explicitly asks and the environment is already isolated (container/VM).

codex exec is non-interactive: there is no TTY to approve a gated command, so a job that needs approval stalls until the timeout. That is why the modes are sandbox levels rather than approval policies. Never ask the user to pick a mode mid-run; resolve it yourself from the rule above.

Step 2 — Decompose the task

Split the task into independent subtasks:

  • No two subtasks may write the same file or depend on each other's output. Prefer splits along existing boundaries: different files, modules, directories, or research topics.
  • If a task has a genuinely sequential core, keep that core for yourself and swarm only the independent parts.
  • Each subtask prompt must be fully self-contained. The Codex sessions share nothing — no conversation history, no knowledge of the other subtasks. Include in every prompt: the goal, the exact file paths to read/write, relevant constraints/conventions, and the expected output format.
  • For write tasks, tell each subtask exactly which files it owns and to touch nothing else. End each prompt with: "When done, print a line starting with TOUCHED: listing every file you created or modified, then a one-paragraph summary of what you did."
  • Typical fan-out is 1–10 subtasks. One subtask is fine when the task is a single coherent unit — dispatch it anyway rather than writing it yourself.

Before dispatch, check the ownership map: every required file has exactly one owner, and no file has two.

Step 3 — Route a tier per subtask

Choose per subtask, automatically — never ask the user which model. Write the tier name, not a model slug, in the MODEL: header:

MODEL:Work profile
heavyVery hard or high-stakes: system architecture, cross-cutting refactors, gnarly debugging, concurrency/security-sensitive code, anything where a wrong answer is very expensive
mediumMedium-to-heavy reasoning: feature implementation with real logic, non-trivial refactors, integration-sensitive changes, bug fixes that need investigation
lightBulk, boilerplate, mechanical: scaffolding, mass renames, format conversions, test scaffolding, doc generation, file summarization, straightforward CRUD

Classify each subtask by its hardest material requirement; when torn between two tiers, pick the heavier one. Omit the EFFORT: header — each tier already carries its tuned effort.

dispatch.sh resolves tiers to concrete Codex models through a routing table that it refreshes from the SwarmGPT repository once a day, so routing stays current even when this skill file is old. Do not hardcode model slugs from memory. To see the current mapping, run bash "$DISPATCH" --print-routing. A literal slug (MODEL: gpt-6-sol, optionally with EFFORT:) is accepted only when the user explicitly asks for a specific model.

If dispatch stops with "codex … is too old", relay its upgrade instructions to the user and stop. If a model is otherwise rejected by the CLI (every job for it fails immediately), report the failure and ask before substituting. Never silently swap models.

Step 4 — Write the subtask files

Create one prompt file per subtask in a temp directory (e.g. $(mktemp -d)/01-slug.prompt.md). Format — tier header, blank line, then the prompt:

MODEL: light

Create src/parser/tokens.ts ...

Name files NN-short-slug.prompt.md; the basename (minus .prompt.md) becomes the subtask name in logs. A useful prompt skeleton:

Goal: <one concrete outcome>
Read: <exact context paths and conventions to follow>
Own: <exact writable paths; touch nothing else>
Requirements: <behavior, conventions, constraints>
Acceptance: <observable criteria and the verification command to run>

When done, print a line starting with TOUCHED: listing every file you created
or modified, then a one-paragraph summary.

For read-only subtasks replace Own: with Write: none and require source locations or evidence in the summary.

Step 5 — Dispatch (always parallel)

If the codex-dispatcher subagent is available (plugin install), delegate to it: pass the task-file paths, the mode flag, and the project root. It runs the script, waits, writes the run log, and returns only a summary — keeping raw Codex output out of your context.

Otherwise run the script yourself from the project root, in one call, with a Bash timeout of at least 20 minutes:

bash "$DISPATCH" --auto --timeout 20m 01-*.prompt.md 02-*.prompt.md

Every job launches concurrently and the script blocks until all finish. Its stdout is a short status table plus the run directory (.codex-swarm/logs/<ts>/). Read results.tsv and each <name>.last (the agent's final message — small). Never cat a <name>.out file; those are full event streams and will flood your context. For failures, read the last few lines of <name>.err.

Add --jobs N if the user asks you to limit concurrency; the default is unlimited.

Step 6 — Verify, integrate, report

A subtask's own success claim is a handoff, not proof.

  1. Read the actual diff for every file a subtask claims it touched.
  2. Check cross-subtask compatibility: imports, interfaces, naming, shared assumptions, generated artifacts.
  3. Run integration-level verification: focused tests first, then broader tests, type checks, lint, or build as risk warrants.
  4. On failure, re-dispatch the affected subtask with the concrete failing evidence in the prompt. Fix only small integration seams yourself; substantive rewrites go back to a subtask.
  5. Ensure the run log exists at .codex-swarm/logs/<ISO-timestamp>.md (the dispatcher subagent writes it; write it yourself if you dispatched directly). Same timestamp as the run directory:
# codex-swarm run <ts>

<One paragraph: what was dispatched, how many subtasks, which models,
what passed/failed, total wall-clock time.>

- **Mode**: auto | readonly | yolo
- **Wall-clock**: NNs total
- **Integration verification**: <commands and results>

## Subtasks

### <name> — ok | FAIL
- **Model**: <tier> → <slug> / <effort>
- **Duration**: NNs
- **Files touched**: <from TOUCHED:, or none>
- **Result**: <one or two sentences>

If the project is read-only or the request forbids writes, skip the log file and put the same fields inline in your final message instead.

  1. Report the integrated outcome, material changes, verification results, any remaining blockers, and the run-log path. Do not dump agent transcripts.

Red flags

Stop and return to the relevant step if any of these happen:

  • Writing substantial files locally before dispatching
  • Waiting for parallelism before dispatching a single substantial task
  • Asking the user which model or effort to use
  • Hardcoding a model slug instead of a tier
  • Two subtasks owning the same file
  • Prompts that assume conversation context the Codex session never saw
  • Dispatching a write task in readonly mode, or yolo without an explicit ask
  • cat-ing a .out file into your context
  • Treating a subtask's "done" as verification
  • Claiming completion before integration-level checks pass

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.