AgentSkillsCN

session-bridge

通过在 claude-mem 中搜索未完成的任务、过往决策以及会话上下文,自动恢复先前的工作。适用于开始新会话、继续原有工作,或当用户说“恢复”、“继续”、“上次”、“再开”、“接着”、“我刚才在做什么”,或询问关于先前工作的内容时使用。

SKILL.md
--- frontmatter
name: session-bridge
description: Automatically resume previous work by searching claude-mem for incomplete tasks, past decisions, and session context. Use when starting a session, continuing work, or when user says "resume", "continue", "前回", "再開", "続き", "what was I working on", or asks about previous work.
allowed-tools:
  - Bash
  - Read

Session Bridge

Seamless session continuity through automatic resume detection, smart context inheritance, and session snapshots.

Prerequisites

Required:

  • MCP server: claude-mem with search tools (search, timeline, get_observations)
  • Script: .claude/skills/session-bridge/scripts/collect_context.sh

Error if missing: Report which component is unavailable and provide setup instructions.

Quick Start

Resume Previous Work

bash
# Collect current project context
bash .claude/skills/session-bridge/scripts/collect_context.sh

Then search memory using the 3-layer protocol (see References).

Check Session Status

Ask: "前回の作業を確認して" or "What was I working on?"

Trigger Conditions

This skill activates when:

  • Starting a new session in a project with history
  • Keywords: "resume", "continue", "前回", "再開", "続き", "what was I working on"
  • Detecting uncommitted changes or in-progress work
  • SessionStart hook provides context (if configured)

Core Workflows

1. Auto Resume Detection

  1. Run context collector:

    bash
    bash .claude/skills/session-bridge/scripts/collect_context.sh
    
  2. Search memory using MCP tools:

    • search() → Get ID index
    • timeline() → Get context around results
    • get_observations() → Fetch full details

    See memory-search-protocol.md for detailed usage.

2. Smart Context Injection

Retrieve relevant learning from past sessions:

Query PatternUse Case
"bugfix <project>"Past bug fixes and solutions
"decision <project>"Architectural decisions
"<error message>"Similar error resolutions
"<feature name>"Implementation history

Type filters: session-request, bugfix, decision, discovery, feature

3. Session Snapshot

Save current state for later recovery. See snapshot-specification.md for format.

SessionStart Hook (Optional)

Auto-inject context at session start.

Quick Setup:

bash
claude hooks add SessionStart "bash .claude/skills/session-bridge/scripts/collect_context.sh"

Manual Setup - Edit ~/.claude/settings.json:

json
{
  "hooks": {
    "SessionStart": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "bash .claude/skills/session-bridge/scripts/collect_context.sh",
        "timeout": 10
      }]
    }]
  }
}

Common Patterns

PatternSteps
Resume Interrupted Workcollect_context → search recent sessions → find incomplete tasks → present options
Context-Aware Bug Fixuser reports bug → search similar bugs → inject solutions → apply patterns
Decision Recalluser asks "why X?" → search decisions → fetch observation → present context

Error Handling

IssueSolution
No memory resultsBroaden dateStart, try different keywords, remove type filter
Too many resultsAdd project filter, narrow date range, use specific query
Script not foundCreate script or use manual memory search
MCP server unavailableReport error, suggest checking MCP configuration

Best Practices

  1. Always use 3-layer protocol - search → timeline → get_observations
  2. Filter aggressively - Use project and date filters
  3. Fetch selectively - Only get_observations for relevant IDs
  4. Save snapshots - Before ending complex work sessions

References