| name | session-handoff |
| domain | core |
| skill_type | skill |
| description | Create and restore comprehensive context handoff documents for agent session transfers. Use when context is getting full, a major task milestone is complete, work is pausing, or when resuming from a previous session. Triggers include "create handoff", "save state", "context is full", "I need to pause", "load handoff", "resume where we left off", or proactively after 5+ file edits or complex multi-step work. Do NOT use for project documentation — this is for agent-to-agent context preservation. |
| license | MIT |
| tags | ["handoff","context","session","resumption","continuity","memory"] |
| metadata | {"version":"1.2.1","author":"Genius"} |
Session Handoff
Create comprehensive handoff documents that enable a fresh agent to seamlessly continue work with zero ambiguity. Solves the long-running agent context exhaustion problem.
Session Handoff
Create comprehensive handoff documents that enable a fresh agent to seamlessly continue work with zero ambiguity. Solves the long-running agent context exhaustion problem.
Capabilities
- Scaffold Generation — Auto-scaffolds handoff documents with system, git, and file context.
- Handoff Validation — Performs secret-scanning, placeholder checks, and quality scoring.
- Staleness Scoring — Calculates divergency metrics based on git timeline and files.
- Episodic Memory Integration — Double-writes handoffs as markdown and Graph-OS knowledge nodes.
Steps
Step 1: mode_selection
Determine which mode applies to the current session:
- Creating a handoff? User wants to save current state, pause work, or context is getting full.
- Follow branch:
generate_scaffold -> complete_and_validate -> memory_persistence.
- Resuming from a handoff? User wants to continue previous work or load context.
- Follow branch:
locate_handoffs -> verify_staleness_context -> begin_execution.
- Proactive suggestion — After substantial work (5+ file edits, complex debugging, major design decisions), suggest:
"We've made significant progress. Consider creating a handoff document to preserve this context for future sessions. Say 'create handoff' when ready."
Step 2: generate_scaffold [depends_on: mode_selection]
Run the scaffold script to create a pre-filled handoff document if in CREATE mode:
- Requires: primary script
scripts/create_handoff.py [task-slug]
- Example:
python scripts/create_handoff.py implementing-user-auth
- For continuation handoffs (linking to previous):
python scripts/create_handoff.py "auth-part-2" --continues-from 2024-01-15-143022-auth.md
- The script will:
- Create
.agent/handoffs/ directory if needed
- Generate timestamped filename (
YYYY-MM-DD-HHMMSS-[slug].md)
- Pre-fill: project path, git branch, recent commits, modified files
- Add chain links if continuing from a previous handoff
Step 3: locate_handoffs [depends_on: mode_selection]
Find available handoffs if in RESUME mode using either local filesystem or the Knowledge Graph:
Step 4: complete_and_validate [depends_on: generate_scaffold]
Open the generated file, fill in all sections, and run the validation script to verify completeness and security:
Step 5: verify_staleness_context [depends_on: locate_handoffs]
Assess if handoff context is still current and analyze divergence:
- Requires: primary script
scripts/check_staleness.py <handoff-file>
- The script checks: time elapsed, git commits since handoff, files changed, branch divergence, missing referenced files.
- Staleness levels:
- FRESH — Safe to resume; minimal changes since handoff
- SLIGHTLY_STALE — Review changes, then resume
- STALE — Verify context carefully before proceeding
- VERY_STALE — Consider creating a fresh handoff first
Step 6: memory_persistence [depends_on: complete_and_validate]
Persist the validated handoff to both local markdown and Graph-OS:
- Markdown local fallback: file is stored in
.agent/handoffs/ following the naming convention YYYY-MM-DD-HHMMSS-[slug].md.
- Knowledge Graph global memory store:
- Invoke
kg_memory_store MCP tool with memory_type set to episodic.
- Pass the full content of the handoff document, and include tags like
handoff, session, and the [slug].
- This ensures the dual-write strategy: the Markdown file acts as a local fallback, while the KG serves as the global memory store.
- For long-running projects, chain handoffs together to maintain context lineage:
handoff-1.md (initial work) -> handoff-2.md --continues-from handoff-1.md -> handoff-3.md --continues-from handoff-2.md.
Step 7: begin_execution [depends_on: verify_staleness_context]
Load the verified context and begin working on the immediate next steps list:
- Follow
references/resume-checklist.md:
- Verify project directory and git branch match
- Check if blockers from the handoff have been resolved
- Validate assumptions still hold (run a quick
git status)
- Review modified files for conflicts
- Check environment state (services running, env vars set)
- Start with Immediate Next Steps item #1 from the handoff document. Reference:
- "Critical Files" section for important file locations
- "Key Patterns Discovered" for conventions to follow
- "Potential Gotchas" to avoid known issues
- As you work: mark completed items in "Pending Work", add new discoveries to relevant sections, and for long sessions create a new handoff with
--continues-from to chain them.
Storage Location
Handoffs are stored in: .agent/handoffs/
Naming convention: YYYY-MM-DD-HHMMSS-[slug].md
Example: 2024-01-15-143022-implementing-auth.md
Scripts
| Script | Purpose |
|---|
scripts/create_handoff.py [slug] [--continues-from <file>] | Generate new handoff with smart scaffolding |
scripts/list_handoffs.py [path] | List available handoffs in a project |
scripts/validate_handoff.py <file> | Check completeness, quality, and security |
scripts/check_staleness.py <file> | Assess if handoff context is still current |
References
references/handoff-template.md — Complete template structure with guidance
references/resume-checklist.md — Verification checklist for resuming agents