@danielbolivar/opencode-handoff
v0.1.5
Published
OpenCode plugin for session handoff - transfer context to focused new sessions without compaction loss
Maintainers
Readme
@danielbolivar/opencode-handoff
Transfer context to focused new sessions without compaction loss.
Handoff creates a new session with intelligently extracted context from your current session. Unlike compaction (which is lossy), handoff lets you specify what the new session should focus on, and the LLM distills only the relevant context.
Why Handoff?
The best workflow for complex tasks:
Research Session → Planning Session → Implementation Session
(messy) (focused) (pristine)Each handoff creates a clean context window with only conclusions, not the journey.
- Research → Planning: Distills findings into actionable insights
- Planning → Implementation: Extracts just the finalized plan
- No mid-impl compaction: Fresh context means better accuracy
Installation
From npm
npm install @danielbolivar/opencode-handoffAdd to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@danielbolivar/opencode-handoff"],
"command": {
"handoff": {
"description": "Create focused new session from current context",
"template": "$ARGUMENTS"
}
}
}From source
- Clone this repo and build:
bun install && bun run build - Copy
dist/index.jsto.opencode/plugin/handoff.js - Add the command config to
opencode.json(see above)
Usage
/handoff <goal for new session>The LLM analyzes your session and generates a focused handoff prompt tailored to your goal. It automatically determines what kind of context you need.
Examples
After research, ready to plan:
/handoff create a detailed implementation plan for the auth systemAfter planning, ready to implement:
/handoff execute phase 1 of the planContinue with next phase:
/handoff now implement this for teams as wellHit a wall, need to research more:
/handoff investigate why the token refresh is failingHow It Works
- You type
/handoff <goal> - The LLM analyzes the current session and your goal
- It generates a handoff prompt with:
- Relevant
@filepathreferences (loaded into context first) - Appropriate context based on what your goal requires
- Clear goal statement
- Relevant
- A new child session is created (linked to parent)
- Session list opens - select the new session
- Handoff prompt auto-fills, ready for you to review and send
What the LLM Extracts
The LLM adapts the handoff based on your goal:
For implementation goals (execute, build, implement):
- The plan/phase being executed
- Numbered tasks and specific steps
- Exact file paths, function names, signatures
For planning goals (design, architect, plan):
- Key findings from research
- Constraints to respect
- Decisions that need to be made
For research goals (investigate, explore, understand):
- Current understanding
- Dead ends to avoid
- Specific questions to answer
For general goals:
- Brief current state
- What needs to happen next
Principles
Every handoff follows these principles:
- Files first -
@filepathreferences load context before prose - No journey - Only conclusions matter, not how you got there
- Actionable immediately - Start working from the first line
- Dense information - Like notes from a colleague, not a report
Programmatic Usage
import { executeHandoff } from "@danielbolivar/opencode-handoff"
const result = await executeHandoff(client, sessionId, {
goal: "implement the auth system",
})
console.log(result.newSessionId) // ID of the new session
console.log(result.prompt) // The generated handoff prompt
console.log(result.files) // File references extractedDevelopment
bun install
bun run build
bun run typecheckLicense
MIT
