Delegate task

From stevehuang0115/crewly · View interactive version

Delegate task is an AI agent skill from the GitHub repository stevehuang0115/crewly. Assign a task to a worker within the Team Leader's subordinate scope. Validates that the target worker's parentMemberId matches the TL's memberId before delegation. Subscribes the lead to the worker's idle event; a recurring progress check is opt-in (minimum 30 minutes).

How to use this skill

Skill file

Delegate Task (TL Version)

Assigns a task to a worker within the Team Leader's subordinate scope. Validates hierarchy before delegation — the target worker's parentMemberId must match the TL's memberId.

When to Use

Parameters

| Flag | JSON Field | Required | Description |

|------|-----------|----------|-------------|

| --to / -t | to | Yes | Target worker's PTY session name |

| --task / -T | task | Yes | Task description (or pipe via stdin) |

| --task-file | — | No | Read task description from a file path |

| --priority / -P | priority | No | Priority: low, normal, high (default: normal) |

| --context / -c | context | No | Additional context for the worker. Scanned for the Request Contract alongside --task |

| --project / -p | projectPath | No | Project path; recorded on the WorkItem (metadata.projectPath) |

| --team / -g | teamId | No | Team ID for hierarchy validation |

| --tl-member | tlMemberId | No | TL's member ID for hierarchy validation |

| --from | fromSession | No | Delegating TL's session name (for monitoring) |

| --request-id / -R | requestId | No | Ticket this work is for: the id (or TKT-123) from the [TICKET:TKT-123 <id>] line of the message you are acting on. Omit it and the task is still linked when your current turn has exactly one ticket |

| --ticket | ticket | No | Project ticket this work is for (e.g. APP-12). Without it a ticket is created for you when the target works on a project — see Project tickets |

| --thread | thread | No | Owner request from Slack: the key from the [SLACK-THREAD:<key>] of the owner's message. A <conversation id>:<chat thread id> pair from the chat works too. The member answers the owner in that thread itself — see Owner requests |

| --conversation | conversation | No | Owner request from the Crewly chat (no Slack thread): the conversation id from the [CHAT:<id>] of the owner's message — see Owner requests |

| --no-member-fits | noMemberFits | No | You keep the work: record what is missing (access, tool, permission, everyone busy). Needs --task; nothing is delegated — see No member fits |

| --work-item | workItemId | No | With --no-member-fits: the WorkItem you keep (gets a [NO-MEMBER-FITS] note) |

| --progress-check | monitor.progressCheckMinutes | No | Opt in to a recurring "TL progress check" every N minutes for this delegation. Off by default; values under 30 are raised to 30. Legacy JSON monitor.fallbackCheckMinutes is read the same way |

| --after | after | No | WorkItem id of a job this work must start AFTER (see Start after another job). The new item is created blocked on it and delivered when it succeeds |

| — | monitor.idleEvent | No | false skips the idle event subscription (default true) |

Monitoring

Each delegation subscribes you (one-shot) to the worker's agent:idle event,

so you are woken when the worker goes idle; the worker also reports

completion with report-status. That is enough for almost every task.

No recurring progress check is scheduled unless you ask for one. Every check

wakes your session and re-reads your whole context; the old default (every 5

minutes per delegation) woke leads 219 times in 3.5 days. Opt in only for a

long task with no other signal:

bash execute.sh --to worker-session --task "..." --progress-check 60

The minimum is 30 minutes (lower values are raised, with a note on stderr).

The backend applies the same floor to any "TL progress check" it schedules.

A check linked to the WorkItem stops once the item is done, verified,

cancelled or failed.

Who to delegate to

Role is a preference, not a limit: every member runs the same runtime and can

code, write and research. Any member can take any work that needs no special

account, tool or permission. Prefer an idle (or stopped) member over doing it

yourself. Do hands-on work yourself only for lead-level work (review,

decisions, owner communication, cross-team coordination), when every member

is busy, or when the work truly needs your own judgment.

Owner requests (`--thread` / `--conversation`)

When the owner asked in Slack, pass the thread key from the owner message's

[SLACK-THREAD:<key>]; when the owner asked in the Crewly chat (no Slack

thread), pass the conversation id from its [CHAT:<id>]:

bash execute.sh --to sage-session --task "Goal: … Outcome: … Eval: …" --thread C0THINK:1790000000.000100
bash execute.sh --to sage-session --task "Goal: … Outcome: … Eval: …" --conversation 5f1c…-room

The WorkItem carries that place and the member is told to post its progress

and result there itself (reply --work-item <id>), under its own name. You do

not relay its answer; the room's reply gate never holds the member's post.

(A thread in your DM with the owner: the member's bot cannot post there, so

it answers in its own DM with the owner, opened with Re: <task>.)

Without --thread / --conversation the work is yours, not the owner's.

The WorkItem's origin is you: the member's reply --work-item <id> reaches

you as an internal [RESULT] message, nothing goes to the owner, and Crewly

never posts a "finished" line to the owner for it. Pass the place only when

the owner actually asked for this work there; a place the owner last wrote in

more than 2 hours ago is not taken (the result then comes back to you). Work

you start on your own initiative — a refresh, a cleanup, something you noticed

— is delegated without a place, and you decide what, if anything, the owner

hears. (crewly#1357: a lead's own-initiative delegation inherited an old owner

DM, and two delegations made while the lead answered the owner in a video

thread inherited that thread; the members' internal reports landed on the

owner.)

Start after another job (`--after`)

When the brief says "start after X" (X is a deploy, a merge, another delegation), pass --after <X's workItemId> instead of delegating now and telling the worker to wait. The worker would sit idle, the stall detector would re-deliver the brief and eventually move the ticket back to ready.

bash execute.sh --to worker-session --task "..." --ticket APP-12 --after <upstream workItemId>

No member fits (`--no-member-fits`)

Rare. When you keep work yourself, record why — what is missing, not a role

mismatch — so the owner sees missing roles in the daily report:

bash execute.sh --no-member-fits "needs the owner's Stripe login" --task "Update billing settings" [--work-item <id>] [--ticket CE-7]

Nothing is delivered. With --work-item the WorkItem gets a

[NO-MEMBER-FITS] <reason> note.

Project tickets

Work for a teammate on a project always runs through a project ticket

(<project>/.crewly/tickets/, spec 2026-09-28-project-tickets.md §11):

live WorkItem) is assigned to --to and this WorkItem becomes its work. A

ticket that is already being worked, done, cancelled or unknown is refused:

nothing is delivered and the reason is printed.

the target's team, priority) and set in_progress for the target. The

output names it (projectTicket).

No ticket is made for work you target at yourself, review/verify items,

system or scheduled items, or targets whose team has no project. Work already

in flight without a ticket: project-tickets link --project P --id APP-12 --work-item <id>.

Request Contract check

Before delegating, the skill scans the brief for Goal, Expected Outcome, and

Eval Criteria markers, and emits a non-fatal warning on stderr naming any that

are missing. Workers use that warning to decide whether to push back under the

Brief Reception Protocol.

--task and --context are scanned together, so the contract may live in

either field or be split across both. A marker absent from both still warns.

Recognised synonyms: Objective for Goal; Acceptance Criteria or

Evaluation Criteria for Eval Criteria.

Usage — CLI Flags (preferred)

# Basic delegation
bash execute.sh --to worker-session --task "Implement login form" --priority high --project /path/to/project

# With hierarchy validation
bash execute.sh --to worker-session --task "Implement login form" --priority high --team team-123 --tl-member tl-member-id --project /path/to/project

# Task from stdin (for long descriptions with special characters)
echo "Implement the OAuth2 flow — it's critical for launch" | bash execute.sh --to worker-session --priority high --project /path

# Task from file
bash execute.sh --to worker-session --task-file /tmp/task-description.txt --priority high --project /path

Usage — Legacy JSON (backward compatible)

bash execute.sh '{"to":"worker-session","task":"Implement login form","priority":"high","teamId":"team-123","tlMemberId":"tl-member-id","projectPath":"/path/to/project"}'

Hierarchy Validation

When teamId and tlMemberId are provided, the script fetches team data and validates:

If validation fails, delegation is rejected with a hierarchy violation error.

Auto-Start Offline Workers

If the target worker is offline (delivery fails), the skill automatically:

  1. Looks up the worker's memberId from team data
  2. Calls POST /teams/:teamId/members/:memberId/start to boot the worker
  3. Waits 10 seconds for the agent to initialize
  4. Retries task delivery

This requires --team to be provided. Without team context, offline workers cannot be auto-started.

Differences from Orchestrator delegate-task

| Aspect | Orchestrator | Team Leader |

|--------|-------------|-------------|

| Scope | Any agent in any team | Only subordinates |

| Message prefix | "New task from orchestrator" | "New task from Team Leader" |

| Hierarchy check | None | Validates parentMemberId |

| Monitoring subscriber | Orchestrator session | TL session |

Output

JSON lines. The last line says what happened to the brief:

message right now. The task only waits for it. Do not tell anyone it was handed over or that the

worker is on it. Say "queued for <worker>, not yet picked up".

The WorkItem carries metadata.deliveredAt once the brief has reached the worker's running session.

If a delegation is still undelivered after 5 minutes you get one review WorkItem naming the item and

the worker.

Related Skills

Paused teams

The owner can pause a team temporarily (specs/2026-10-04-team-pause.md). A

paused team is hidden from agents and takes no work: handing it work, or

messaging, starting or assigning a ticket to one of its members, fails with

code: "team_paused" and a message saying what to do instead — usually

gh issue create -R <repo> --title "…" --body "…" (the team's issue repo),

otherwise tell the orc. Do that; do not retry or route around the pause.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.