> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automagik.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# /work

> Execute an approved wish plan — orchestrate subagents per task group with fix loops, validation, and review handoff.

# /work — Execute Wish Plan

Orchestrate execution of an approved wish. The orchestrator never executes directly — always dispatches via subagent.

## When to Use

* An approved wish exists and is ready for execution
* After `/review` returns SHIP on the plan
* Orchestrator needs to dispatch implementation tasks to subagents

## Flow

1. **Load wish** — read `.genie/wishes/<slug>/WISH.md`, confirm scope.
2. **Pick next task** — select next unblocked pending execution group.
3. **Self-refine** — dispatch `/refine` on the task prompt with WISH.md as context.
4. **Dispatch agent** — send the task to a fresh subagent session.
5. **Local review** — run `/review` per group against acceptance criteria. On FIX-FIRST, dispatch fix subagent (max 2 loops).
6. **Quality review** — dispatch review subagent for quality pass (security, maintainability, perf).
7. **Validate** — run the group validation command, record evidence.
8. **Signal completion** — notify the leader via `genie send`.
9. **Repeat** until all groups done.
10. **Handoff** — `All work tasks complete. Run /review.`

## Dispatch

All dispatch uses the `genie spawn` command:

| Need                | Method                                                |
| ------------------- | ----------------------------------------------------- |
| Implementation task | `genie spawn engineer`                                |
| Review task         | `genie spawn reviewer` (never same agent as engineer) |
| Fix task            | `genie spawn fixer` (separate from reviewer)          |
| Quick validation    | `Bash` tool directly — no subagent needed             |

## State Management

* **Agents signal** completion via `genie send` to the leader.
* **Leader tracks** state via `genie status <slug>` and marks groups complete via `genie done <ref>`.
* Agents do NOT call `genie done` — that is the leader's responsibility.
* If a group gets stuck, the leader can use `genie reset <ref>` to retry.

## Escalation

When a subagent fails or fix loop limit (2) is exceeded:

* Mark task **BLOCKED** in wish
* Create follow-up task with concrete gaps
* Continue with next unblocked task
* Include blocked items in final handoff

## Task Lifecycle Integration

When PostgreSQL tasks exist, `/work` integrates with the task system at each step:

| Event                         | Command                                                           |
| ----------------------------- | ----------------------------------------------------------------- |
| Claim task before starting    | `genie task checkout #<seq>`                                      |
| Log progress during execution | `genie task comment #<seq> "Building group N..."`                 |
| Move task on group completion | `genie task move #<seq> --to review --comment "Group N complete"` |
| Mark parent task done         | `genie task done #<parent-seq> --comment "All groups shipped"`    |

Task integration is graceful — if no PG task exists, the work flow proceeds without task commands.

## Rules

* Never execute directly — always dispatch subagents
* Never expand scope during execution
* Never skip validation commands
* Never overwrite WISH.md from agents
* Keep work auditable: capture commands + outcomes
* Run local `/review` per group before signaling done
