---
description: Create handoff bundle for next agent or session
agent: build
---

# Handoff: $ARGUMENTS

## For Simple Session Handoff (No Active Task)

If handing off simple work:

```
Use session({ mode: "new", agent: "build", text: "$ARGUMENTS" })
```

The new agent gets fresh context.

---

## For Task-Constrained Handoff (With Active Task)

## MANDATORY GATE: Active Task Must Exist

Search Backlog MCP for In Progress tasks:

```typescript
backlog_task_list({ status: "In Progress" });
```

Then check for task with completed work in `@backlog/tasks/[TASK_ID]/review.md` having "What Changed:" section filled.

**If not found:** STOP. No active task to hand off.

## Step 1: Load Task Context

Read these files:

- `@backlog/tasks/[TASK_ID]/prd.md` - Goal, scope, success criteria
- `@backlog/tasks/[TASK_ID]/spec.md` - Architecture, constraints, edge cases
- `@backlog/tasks/[TASK_ID]/review.md` - What changed, what skipped, validation

Extract:

- **Task goal** (from PRD)
- **Task scope** (In-Scope and Out-of-Scope from PRD)
- **Task constraints** (from spec)
- **Current progress** (from review.md What Changed)
- **Remaining work** (success criteria not yet [x] marked)

## Step 2: Create Handoff Document

Create: `.opencode/memory/handoffs/YYYY-MM-DD-task-[TASK_ID]-handoff.md`

Include:

```
# Handoff: Task [TASK_ID]

Date: [Today]
From Phase: [Current phase from implementation]
To Phase: [Next phase needed]
Recommended Agent: [Based on complexity]

## Task Summary

**Goal:** [From PRD]
**Scope:** [In-Scope items from PRD]
**Status:** [What's been done from review.md]

## Task Files & Constraints

**PRD:** @backlog/tasks/[TASK_ID]/prd.md
**Spec:** @backlog/tasks/[TASK_ID]/spec.md
**Review:** @backlog/tasks/[TASK_ID]/review.md

**Constraints:** [From spec.md]
**Edge Cases:** [From spec.md]

## Work Accomplished

[From review.md What Changed section]

## Work Remaining

[Success criteria still unchecked in prd.md]

## Next Phase Instructions

$ARGUMENTS

**Important:** Continue only within task [TASK_ID] boundaries
```

## Step 3: Include User Instructions

Add to handoff:

```
## To Continue This Work

Next agent should:
1. Read this handoff file
2. Read task PRD: @backlog/tasks/[TASK_ID]/prd.md
3. Read task Spec: @backlog/tasks/[TASK_ID]/spec.md
4. Work ONLY within task scope
5. Update review.md as work progresses
6. Run /complete-task [TASK_ID] when done

DO NOT expand beyond task boundaries.
```

## Step 4: Validate Handoff

Before handoff is ready, verify:

- [ ] Task context (PRD+spec+review) is clear
- [ ] Task constraints are explicitly listed
- [ ] Next phase instructions are within task scope
- [ ] Remaining work is clearly identified
- [ ] Recommended agent matches complexity

---

**ANTI-HALLUCINATION: Task handoffs stay task-focused; session handoffs pass context to new agent**
