# Session Handoff

> Preserve critical state when a session approaches context limits so the next session can pick up seamlessly. Use this skill whenever you're in a long, multi-step workflow, working with Google Workspace resources (Docs, Slides, Drive), creating external resources that have IDs you need to track, running multi-step pipelines that might need to be resumed, approaching context limits, or when the user says things like "save state", "let's pause", "I'll come back later", "save progress", "I need to stop for now", "bookmark this", "save my work", or when you detect that a workflow involves multiple phases and the user might return later. This skill is CRITICAL after creating Google Docs, Slides, or Drive files — those resource IDs are impossible to recover if lost. Also apply proactively during analysis pipelines after major phases complete (data exploration done, charts generated, narrative written, deck created) so users can resume at natural checkpoints. Write session state immediately after any external resourc

- Skill: `ai-analyst-lab/session-handoff` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ai-analyst-lab/session-handoff`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ai-analyst-lab/session-handoff/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: ai-analyst-lab (https://skillmd.com/u/ai-analyst-lab)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/ai-analyst-lab/session-handoff

---


# Skill: Session Handoff

## Purpose

Preserve critical state when a session approaches context limits, so the next
session (or `/resume-pipeline`) can pick up seamlessly. Prevents lost work when
context compaction occurs or the user starts a new conversation.

## When to Apply

Automatically when:
- A long multi-step workflow is in progress
- A multi-step Google Workspace workflow is in progress
- The pipeline involves external resource IDs (doc IDs, slide IDs, Drive folders)
- Before any pause point where the user might come back later

---

## What to Save

Write to the EXACT path `working/session_state.yaml` (not `session_state_handoff.yaml` or any variant). The `/resume-pipeline` command looks for this specific file path.

This file MUST be comprehensive, regardless of how simple the handoff seems. Capture ALL of the following information:

**Required Fields (always include):**
- ✅ Dataset name and connection details
- ✅ Task description (what analysis/work is in progress)
- ✅ Pipeline progress (what's complete, what's next)
- ✅ All external resource IDs (Google Docs, Slides, Drive files) with URLs
- ✅ Local file inventory (working/ and outputs/ directories)
- ✅ Auth state (user email, last verified date)
- ✅ Known issues or blockers (write "None" if no issues)
- ✅ Resume instructions (step-by-step guide)

---

## The Template (Use This Every Time)

**Use the complete template.** Fill every section (an empty section is "None"), because the next session has no other context.

**Template:**

```yaml
# Session State — auto-generated by session-handoff skill
# Last updated: {{DATE}} {{TIME}}

dataset: "{{DATASET_NAME}}"
task: "brief description of what we're doing"

# External resource IDs (Google Workspace, etc.)
resources:
  google_doc:
    id: "18MTagnf_z5..."
    title: "Document Title"
    url: "https://docs.google.com/document/d/18MTagnf.../edit"
    status: "content complete, needs formatting review"
  google_slides:
    id: "1in6mkRf..."
    title: "Deck Title"
    url: "https://docs.google.com/presentation/d/1in6mkRf.../edit"
    status: "12 slides built, reviewer passed"
  drive_folder:
    id: "1PV9ols..."
    name: "Folder Name"
  drive_files:
    - id: "1abc..."
      name: "01_chart.png"
    - id: "2def..."
      name: "02_chart.png"

# Pipeline progress
pipeline:
  last_completed_step: "chart generation"
  current_step_status: "narrative draft 80% complete — context and findings done, recommendations need 2 more paragraphs"  # Use this for partially-complete steps
  next_step: "Google Doc creation"
  steps_remaining:
    - "Create Google Doc with proper image placement"
    - "Run Google Doc Reviewer"
    - "Final review of both deliverables"

# Local file inventory
local_files:
  charts:
    - outputs/charts/01_height_crossover.png
    - outputs/charts/02_height_gap.png
  data:
    - outputs/ms_case_study/data.csv
  working:
    - working/narrative_draft.md
    - working/storyboard.md

# Auth state (REQUIRED)
auth:
  google_email: "user@example.com"  # If not provided by user, check working files or note "unknown — verify at resume"
  last_verified: "2026-03-05"
  notes: "Tokens expire between sessions — expect re-auth"

# Known issues or blockers (REQUIRED — use "None" if no issues)
issues:
  - "Google Doc images overlap with text — needs rebuild with proper placement"
  - "Doc heading formatting was applied manually, may need re-check"
  # OR if no issues:
  # - "None — all work completed successfully"

# Resume instructions (REQUIRED)
resume:
  command: "/resume-pipeline"
  steps:
    - "Verify auth for {{auth.google_email}}"
    - "Load external resources"
    - "Continue from: {{pipeline.next_step}}"
```

---

## When to Write

### Proactive triggers (write automatically):
- After creating any Google resource (doc, slides, Drive file)
- After completing a major pipeline phase (analysis, charting, doc creation)
- After any long stretch of tool calls in one workflow (the same trigger as "When to Apply" above)
- Before any operation that might run long (batch chart generation, etc.)

### Reactive triggers (write when prompted):
- User says "save state", "let's pause", "I'll come back later"
- Context compaction warning from the system
- `/resume-pipeline` is likely needed

---

## How to Resume

At session start, check for existing state:

1. Read `working/session_state.yaml` if it exists
2. Verify external resources still exist (quick API call to check doc/slides)
3. Check auth (run auth-preflight skill)
4. Report status to user:

```
Resuming from previous session:
- Google Doc: [title] — [status]
- Google Slides: [title] — [status]
- Charts: [N] uploaded to Drive
- Next step: [description]
- Auth: [OK/needs re-auth]
```

---

## Rules

1. **Write state after every external resource creation.** A Google Doc ID is
   impossible to recover if lost — save it immediately.

2. **Include URLs, not just IDs.** The user needs clickable links to verify
   their resources.

3. **Describe status in plain English.** "content complete, needs formatting
   review" is more useful than a boolean flag.

4. **Reference, don't copy.** Point at file paths instead of pasting narratives
   or data into the state file.

5. **Overwrite, don't append.** Each write is a complete snapshot. The file
   should reflect current state, not a history log.

6. **Auth email is critical state.** Always include the exact email used for
   Google Workspace MCP calls — this is the #1 source of auth failures. If the
   user hasn't mentioned their email, check for it in working files or previous
   MCP calls. If truly unknown, note "email unknown — verify at resume time".

