agent-delegate
Skill3 starsChanged 8 days agoMITView on GitHub
Delegate a task to, or get an adversarial review from, the other AI agent (Codex from Claude Code, or Claude Code from Codex) via a headless CLI call — no cmux required. Returns a normalized report.json the caller can parse. Use for task hand-off, code/spec review, and second opinions in environments without cmux.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- IamLumiRay/Agent-delegatetheir own version, first seen Oct 17, 2026
- dylanjbarth/agent-skillstheir own version, first seen Jul 29, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- IamLumiRay/Agent-delegate★ 4same name
- dylanjbarth/agent-skills★ 1same 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 repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cmux-delegateSkill
- cmux-forkSkill
- cmux-second-opinionSkill
- handoverSkill
- harness-initSkill
- harness-loopSkill
- harness-planSkill
- ja-humanizerSkill
- magiSkill
- mcp-convertSkill
- skill-suggestSkill
- spec-codeSkill
- spec-evaluateSkill
- spec-generatorSkill
- spec-implementSkill
- spec-inspectSkill
- spec-orchestrateSkill
- spec-reviewSkill
- spec-rules-initSkill
- spec-testSkill
- spec-to-issueSkill
- spec-workflow-initSkill
- spec-writingSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 37
Run inside a git repository (touchedFiles measurement degrades outside one).
- Distinctive: line 59
When ambiguous, ask with bilingual options:
- Very specific: line 75
Write the full instruction for the peer to a file (e.g.
- Distinctive: line 89
If none is found, ask the reviewer to review freely.
- Distinctive: line 113
Before launch, register each task artifact's exact path, correlation value, freshness baseline, and task-specific validator.
- Very specific: line 149
Read report.json and summarize for the user in their language:
- Very specific: line 157
Every Critical / Improvement finding carries a fix_before tag whose value is in the stage list in effect — the four default values, or the …
- Very specific: line 170
If blocked: report blocker and blocker_category, and suggest a next step (e.g.
- Distinctive: line 199
Use agent-delegate when cmux is not available or a parseable report is needed.
≈ “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.
Files
agent-delegate — Headless Delegation and Review Between Agents
Hand a task to the other agent, or get an independent adversarial review, by
calling its CLI headlessly. This is the cmux-free counterpart to cmux-delegate
and cmux-second-opinion: it needs only a git repository and the peer CLI
installed, and it returns a machine-readable report.json.
The runnable interface is references/scripts/agent-delegate.sh. Its full
argument and output contract is in references/contract.md
(日本語: contract.ja.md). Upper skills call the
script directly; this SKILL.md is the interactive entry point for humans.
Language Rules
- Auto-detect input language → output in the same language
- Japanese input → Japanese output, use
references/*.ja.md - English input → English output, use
references/*.md - Explicit override takes priority (e.g., "in English", "日本語で")
Prerequisites
- Run inside a git repository (touchedFiles measurement degrades outside one).
- The peer CLI must be installed:
codexwhen running under Claude Code,claudewhen running under Codex. - Codex direction only: the workspace must be trusted in
~/.codex/config.toml. The script stops with exit 2 and instructions if it is not. - node (18 or later) must be on
PATH. The script reads and writes its JSON records throughreferences/scripts/json-tool.mjs; no other JSON tool is needed, so it also runs in Git Bash on Windows.
The script self-detects the host agent. If it cannot (neither CLAUDECODE nor a
Codex runtime marker is set), pass --target <codex|claude> explicitly.
Request Type Detection
Determine what the user wants from their phrasing:
| User input pattern | Mode |
| "delegate this", "have Codex do X", "Codex に実装させて", "投げて" | delegate |
| "review this", "second opinion", "レビューさせて", "セカンドオピニオン" | review |
| (ambiguous) | Ask with AskUserQuestion |
When ambiguous, ask with bilingual options:
- question: "What should the other agent do?" / "もう一方のエージェントに何をさせますか?"
- options:
- "Delegate a task" / "タスクを委譲" — hand off work and collect the result
- "Adversarial review" / "敵対的レビュー" — read-only review, structured findings
Execution Flow
Step 1: Summarize the request
Restate the task or review scope in one or two sentences so the user can confirm what will be sent. Identify the direction (which peer will run).
Step 2: Build the prompt file
Write the full instruction for the peer to a file (e.g. under the out-dir), and
pass it with --prompt-file. Never inline a long prompt as an argument.
- For
delegate: describe the task, the acceptance criteria, and any constraints. For
review: describe the review target (diff, spec paths, focus areas). The script prepends the adversarial template automatically; your file supplies only the context. If areview_rules.mdexists in the project, include its contents as review criteria and tell the reviewer to also raise issues beyond those rules — matching the cmux-second-opinion behavior. Detect it with:find . -name "review_rules.md" -maxdepth 3 2>/dev/nullIf none is found, ask the reviewer to review freely.
Step 3: Choose synchronous or detached
| Task | Mode |
| File-writing delegation, specification generation or repair, code implementation, E2E, or test-evidence recording | explicit --detach |
| Read-only review, investigation, or short delegation with a concrete basis for finishing within 5 minutes and no file writes | synchronous |
| Any task without that concrete 5-minute basis | --detach |
A synchronous call blocks until report.json is written. --detach returns
immediately and prints the run id followed by the future report.json path.
Save both as the expected run. Poll every 15 seconds by default, never less
often than every 30 seconds, and follow the expected-run state machine in
references/contract.md: validate the report first, then inspect owner, pid,
heartbeat, and process state. A missing report while the run is alive is not a
failure. Use the expected-run owner's worker_pid before the first heartbeat,
and select states in this order: terminal report, different owner, process
disappearance, invalid report, then heartbeat. Re-evaluate every detached run
at 30 minutes and every 30 minutes thereafter. At 2 hours, apply the contract's
controlled stop: recheck the report, send TERM only to the verified expected
monitor, wait up to 90 seconds for its terminal report, then stop waiting and
escalate with diagnostics. Never use --force for this timeout path.
Before launch, register each task artifact's exact path, correlation value,
freshness baseline, and task-specific validator. For review, also record a
pre-launch content fingerprint of tracked worktree and staged diffs plus every
non-ignored untracked path and its content, excluding the declared out-dir. If the expected-run terminal
report is blocked with blocker_category: env_error, run the contract's
fail-closed artifact recovery before reporting task failure. Monitor loss or a
missing idle signal alone does not decide completion. On hosts that reap
detached monitors, the durable waiter may be a synchronous bounded until loop
over the artifact validator, using the original launch deadline. The loop does
not relax recovery eligibility: without a valid expected-run env_error report,
it rejects recovery and escalates diagnostics at the deadline.
Step 4: Run the script
# Synchronous read-only delegate with a concrete <=5-minute basis
report="$(skills/agent-delegate/references/scripts/agent-delegate.sh \
--mode delegate --prompt-file <prompt> --out-dir <out> --label <slug> | tail -1)"
# Adversarial review with a concrete <=5-minute basis (always read-only)
report="$(skills/agent-delegate/references/scripts/agent-delegate.sh \
--mode review --prompt-file <context> --out-dir <out> --label <slug> | tail -1)"
# Writing or otherwise unbounded task, detached
launch="$(skills/agent-delegate/references/scripts/agent-delegate.sh \
--mode delegate --prompt-file <prompt> --out-dir <out> --label <slug> --detach)"
expected_run_id="$(printf '%s\n' "$launch" | sed -n 's/^run_id: //p')"
report="$(printf '%s\n' "$launch" | tail -1)"
# Register a durable 15-second watcher that applies the contract state machine.The last line of stdout is always the report.json path. A successful launch
also prints run_id: <uuid> immediately before it.
Step 5: Read the report and present the result
Read report.json and summarize for the user in their language:
status—doneorblocked.summary— the peer's final message headline.touchedFiles— files the peer changed (script-measured, authoritative).- For review: read
artifacts.review_fileand validate it in this order — the script verifies structure only, so never adopt theGateline at face value (seereferences/adversarial-review-prompt.md):- Every Critical / Improvement finding carries a
fix_beforetag whose value is in the stage list in effect — the four default values, or the ordered list the review context supplied instead (the prompt template tells the reviewer to use that list). A finding with a missing or out-of-list tag is malformed output (treat as blocked; re-run or inspect) — do not compute a gate from it, or an untagged Critical would silently pass. - Recompute the Gate from the tags — FAIL iff at least one finding carries
the gate-blocking stage: the first stage of the list in effect
(
implementationby default). AGateline that contradicts this tally is also malformed output. - Report the recomputed Gate, the Critical / Improvement / Minor counts, and the gate-blocking-stage count.
- Every Critical / Improvement finding carries a
- If
blocked: reportblockerandblocker_category, and suggest a next step (e.g. resume, fix the trust setting, retry). For the expected run'senv_erroronly, first apply artifact recovery fromreferences/contract.md: prove freshness and correlation, then run the review checks above or the task-specific delegate validator registered before launch. Review recovery must also compare the pre-launch and post-run content fingerprints after excluding the declared out-dir. Record an adopted artifact separately and retain the blocked report as a runtime diagnostic.
To continue a session, re-run with --resume <thread_id> from the prior report
(same sandbox stage; see contract.md for the constraints).
Error Handling
| Situation | Response |
| Peer CLI not installed | Script exits 2; report which CLI to install |
| Not self-detectable | Ask which side to target, pass --target |
| Codex workspace untrusted | Script exits 2 with the config snippet to add |
| Prompt file missing | Script exits 2; check the path |
| Not in a git repository | Warning; touchedFiles will be empty (delegate still runs) |
| Review output malformed | status: blocked, blocker_category: malformed_output; retry or inspect artifacts.last_message |
| read-only review touched files | status: blocked, blocker_category: sandbox_violation; the sandbox is misconfigured |
| Detached run died | Monitor synthesizes a blocked report (env_error); run fail-closed artifact recovery, then inspect stderr if recovery fails |
Notes
- This skill provides the mechanism. Result quality depends on the peer agent.
- For cmux-based delegation and review, use
cmux-delegate/cmux-second-opinion. Use agent-delegate when cmux is not available or a parseable report is needed. - The
report.jsonschema, sandbox mapping, resume rules, and the read-only guarantee-level difference between directions are documented in references/contract.md. - Codex under the
workspace-writesandbox may refuse to write agent-config dot directories (.agents/,.claude/), reportingwriting outside of the project; this can occur with repo layouts that include symlinks. When a task's edits target those directories, prefer assigning it to claude.
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
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.

