skills/delegate/SKILL.md

Delegate a job to a factory role

A factory workflow gives you a job: the role to run, the inputs it may receive, and what it must return. Run that job in an isolated context and bring the result back to the workflow. You stay the orchestrator: you own task state and gates, and you never do the role's work yourself. The orchestrator never reviews its own work.

1. Prepare the job

  • Read the role's instructions in agents/<role>.md, next to this skills/ folder. Frontmatter there (such as tools or model) configures Claude Code only; it is not a tool list for another agent.
  • Pass only the inputs the job lists. Use absolute paths for the task file, catalog root and product checkout. Workers do not inherit your shell variables.
  • Pass the absolute factory directory, the folder holding agents/ and skills/ (the plugin directory in Claude Code, .agents/factory/ in Codex), and tell the worker to resolve the relative links in its role instructions against <factory directory>/agents/. The worker gets the role file's text, not its location, so a link like ../skills/storage.md doesn't resolve on its own.
  • Give every commit as a full SHA read with git rev-parse in the owning checkout, never a short SHA or a value copied from a worker's report.
  • Tell the worker to read the product's applicable AGENTS.md/CLAUDE.md instructions before acting, and to run Git, build and test commands in that checkout.
  • Never pass your conversation, your reasoning, or the builder's reasoning to a reviewer.

2. Start the role

Check in the current session that fresh-context workers are usable; installed configuration is not proof.

Reviewers first follow Reviewers run on the other agent below.

  • Claude Code: launch the plugin's factory:<role> subagent, for example factory:builder.
  • Codex: start a fresh subagent whose instructions are the role file's body, as described in the Codex guide.

If your agent has no spawn tool of its own, check the tools the host application provides before deciding that fresh workers are unavailable, for example an orchestrator's capability and delegate tools. Use one only if it starts a fresh context that gets the role's instructions and your brief and nothing from this conversation, and tell the developer which tool ran the role when you return its result. Run the builder and designer on your own agent. Fall back to the handoff below only when neither your agent nor the host can start a worker.

Reviewers run on the other agent

Start the reviewer and design-reviewer on the other agent (Codex when you are Claude Code, Claude Code when you are Codex) when this session can, so the review doesn't share the author's model. Use a host delegation tool that can pick the agent, or the other agent's command-line tool run non-interactively in the product checkout if it is installed and signed in (the Claude Code and Codex guides give the commands). Either way, pass the role file's body as the worker's instructions with your brief from step 1, including the factory directory, and nothing else; the other agent may not have the factory installed. Start it with that agent's read-only mode where it has one, never bypass its permission checks, and otherwise apply the paragraph below. Both agents share the same catalog, so no records are exported. You stay the orchestrator; only the worker runs elsewhere.

If the other agent can't be started (not installed, not signed in, no tool that can run it, or it fails to start), run the reviewer or design-reviewer as a fresh worker on your own agent instead. Tell the developer when you return its result that the review ran on the same agent as this session, and why the other agent wasn't used. Never present a same-agent review as a cross-agent one.

Apply the role's permissions through the agent's own controls where available. For reviewers, if read-only cannot be enforced, instruct the worker to stay read-only and report that the limit is only an instruction. Do not claim a prompt restriction is a sandbox.

3. If fresh workers are unavailable: separate-session handoff

Stop at this point and give the developer a handoff containing the absolute role file, task/catalog paths, checkout/base/branch and submitted revision where applicable, and the job's allowed evidence. Do not include conversation history. The developer runs that role in a new session in the product checkout and returns its verdict/evidence. The handoff itself is never approval.

While the handoff is pending, keep the workflow's current status, record the pending worker and supplied revision in the task log, and release held task/named locks. Do not mark done or infer approval.

The developer may run the handoff in either agent; it carries the same role, revision and evidence contract. Never export records or infer authorization.

4. Accept the result

Return the worker's report to the workflow. After a separate-session handoff, first reacquire the relevant locks, re-read the record and confirm that the task definition, checkout HEAD or artifact revision, and approval evidence still match. Changed inputs invalidate the result and require a renewed gate/review. Existing blocked-task resume rules still apply. A design definition remains draft until independent review and developer approval; final visuals always require human approval of the exact revision.

Original Markdown, including metadata
---
name: delegate
description: Start a factory role (builder, reviewer, designer or design-reviewer) in a fresh context for a job described by a factory workflow, or hand it off to a separate session when fresh workers are unavailable. Used by deliver and design, not invoked directly.
user-invocable: false
---

# Delegate a job to a factory role

A factory workflow gives you a **job**: the role to run, the inputs it may receive, and what it must return. Run that job in an isolated context and bring the result back to the workflow. You stay the orchestrator: you own task state and gates, and you never do the role's work yourself. The orchestrator never reviews its own work.

## 1. Prepare the job

- Read the role's instructions in `agents/<role>.md`, next to this `skills/` folder. Frontmatter there (such as `tools` or `model`) configures Claude Code only; it is not a tool list for another agent.
- Pass only the inputs the job lists. Use absolute paths for the task file, catalog root and product checkout. Workers do not inherit your shell variables.
- Pass the absolute factory directory, the folder holding `agents/` and `skills/` (the plugin directory in Claude Code, `.agents/factory/` in Codex), and tell the worker to resolve the relative links in its role instructions against `<factory directory>/agents/`. The worker gets the role file's text, not its location, so a link like `../skills/storage.md` doesn't resolve on its own.
- Give every commit as a full SHA read with `git rev-parse` in the owning checkout, never a short SHA or a value copied from a worker's report.
- Tell the worker to read the product's applicable `AGENTS.md`/`CLAUDE.md` instructions before acting, and to run Git, build and test commands in that checkout.
- Never pass your conversation, your reasoning, or the builder's reasoning to a reviewer.

## 2. Start the role

Check in the current session that fresh-context workers are usable; installed configuration is not proof.

Reviewers first follow [Reviewers run on the other agent](#reviewers-run-on-the-other-agent) below.

- **Claude Code:** launch the plugin's `factory:<role>` subagent, for example `factory:builder`.
- **Codex:** start a fresh subagent whose instructions are the role file's body, as described in [the Codex guide](../../docs/adapters/codex.md#roles).

If your agent has no spawn tool of its own, check the tools the host application provides before deciding that fresh workers are unavailable, for example an orchestrator's capability and delegate tools. Use one only if it starts a fresh context that gets the role's instructions and your brief and nothing from this conversation, and tell the developer which tool ran the role when you return its result. Run the builder and designer on your own agent. Fall back to the handoff below only when neither your agent nor the host can start a worker.

### Reviewers run on the other agent

Start the reviewer and design-reviewer on the other agent (Codex when you are Claude Code, Claude Code when you are Codex) when this session can, so the review doesn't share the author's model. Use a host delegation tool that can pick the agent, or the other agent's command-line tool run non-interactively in the product checkout if it is installed and signed in (the [Claude Code](../../docs/adapters/claude-code.md#roles-and-handoffs) and [Codex](../../docs/adapters/codex.md#roles) guides give the commands). Either way, pass the role file's body as the worker's instructions with your brief from step 1, including the factory directory, and nothing else; the other agent may not have the factory installed. Start it with that agent's read-only mode where it has one, never bypass its permission checks, and otherwise apply the paragraph below. Both agents share the same catalog, so no records are exported. You stay the orchestrator; only the worker runs elsewhere.

If the other agent can't be started (not installed, not signed in, no tool that can run it, or it fails to start), run the reviewer or design-reviewer as a fresh worker on your own agent instead. Tell the developer when you return its result that the review ran on the same agent as this session, and why the other agent wasn't used. Never present a same-agent review as a cross-agent one.

Apply the role's permissions through the agent's own controls where available. For reviewers, if read-only cannot be enforced, instruct the worker to stay read-only and report that the limit is only an instruction. Do not claim a prompt restriction is a sandbox.

## 3. If fresh workers are unavailable: separate-session handoff

Stop at this point and give the developer a handoff containing the absolute role file, task/catalog paths, checkout/base/branch and submitted revision where applicable, and the job's allowed evidence. Do not include conversation history. The developer runs that role in a new session in the product checkout and returns its verdict/evidence. The handoff itself is never approval.

While the handoff is pending, keep the workflow's current status, record the pending worker and supplied revision in the task log, and release held task/named locks. Do not mark done or infer approval.

The developer may run the handoff in either agent; it carries the same role, revision and evidence contract. Never export records or infer authorization.

## 4. Accept the result

Return the worker's report to the workflow. After a separate-session handoff, first reacquire the relevant locks, re-read the record and confirm that the task definition, checkout HEAD or artifact revision, and approval evidence still match. Changed inputs invalidate the result and require a renewed gate/review. Existing blocked-task resume rules still apply. A design definition remains draft until independent review and developer approval; final visuals always require human approval of the exact revision.