Session Recovery logo

Session Recovery

Community
tamirdresher
session-recovery

Find and resume recently closed Copilot CLI sessions. Use when a session was accidentally closed, or to find past sessions by topic, working directory, or time range. Triggers on: recover session, find session, resume session, lost session, closed session, recent sessions.

Overview

Publishertamirdresher
Repositorysquad-skills
Skill namesession-recovery
Stars
44
Forks
9
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by tamirdresher on GitHub. Read the source before you install it.

Installation

Install the Session Recovery AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recovery
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/tamirdresher/squad-skills.git /tmp/squad-skills
mkdir -p .claude/skills
cp -r /tmp/squad-skills/plugins/session-recovery .claude/skills/session-recovery
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Session Recovery in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Session Recovery on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Session Recovery is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Session Recovery

When to Use

  • A Copilot CLI session was accidentally closed and needs to be resumed
  • You need to find a past session by topic (e.g., "monetization", "aspire", "podcast")
  • You want to see what sessions ran in a specific directory recently
  • You need to recover work from a session that was interrupted

When Not to Use

  • The session completed normally and work was committed
  • You're looking for git history (use git log instead)
  • The session is older than the retention period in session_store

How It Works

Copilot CLI stores session history in a SQLite database called session_store. This database is read-only and contains:

TableKey ColumnsPurpose
sessionsid, cwd, repository, branch, summary, created_at, updated_atSession metadata
turnssession_id, turn_index, user_message, assistant_response, timestampConversation history
checkpointssession_id, checkpoint_number, title, overviewProgress snapshots
session_filessession_id, file_path, tool_name, turn_indexFiles touched
session_refssession_id, ref_type, ref_valueLinked PRs/commits/issues
search_indexcontent, session_id, source_typeFTS5 full-text search

Core Queries

1. Find Recent Sessions (Last 24 Hours)

sql
SELECT
  s.id,
  s.summary,
  s.cwd,
  s.branch,
  s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-24 hours')
ORDER BY s.updated_at DESC;

2. Filter Out Ralph Sessions

Ralph (the work monitor) creates many sessions. Exclude them:

sql
SELECT
  s.id,
  s.summary,
  s.cwd,
  s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-24 hours')
  AND (s.summary IS NULL OR s.summary NOT LIKE '%ralph%')
  AND s.id NOT IN (
    SELECT DISTINCT t.session_id FROM turns t
    WHERE t.turn_index = 0
      AND (t.user_message LIKE '%ralph%' OR t.user_message LIKE '%keep-alive%')
  )
ORDER BY s.updated_at DESC;

3. Search by Topic (FTS5)

Use search_index for keyword search. FTS5 uses MATCH with OR for synonyms:

sql
SELECT DISTINCT s.id, s.summary, s.cwd, s.updated_at
FROM search_index si
JOIN sessions s ON si.session_id = s.id
WHERE search_index MATCH 'monetization OR monetize OR billing OR payment'
  AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC
LIMIT 10;

4. Find Sessions by Working Directory

sql
SELECT s.id, s.summary, s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.cwd LIKE '%tamresearch1%'
  AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC;

5. Get Session Details Before Resuming

sql
-- See what the session was doing
SELECT turn_index, substr(user_message, 1, 200) AS ask, timestamp
FROM turns
WHERE session_id = 'SESSION_ID_HERE'
ORDER BY turn_index;

-- See checkpoint progress
SELECT checkpoint_number, title, overview
FROM checkpoints
WHERE session_id = 'SESSION_ID_HERE'
ORDER BY checkpoint_number;

-- See files touched
SELECT file_path, tool_name
FROM session_files
WHERE session_id = 'SESSION_ID_HERE';

How to Resume a Session

Once you have the session ID:

powershell
agency copilot --resume SESSION_ID

Ready-to-Use Prompt Template

Paste this into agency copilot --yolo -p "..." to find and list recent non-Ralph sessions:

Find my recent Copilot CLI sessions from the last 48 hours. Use the sql tool with database session_store.

Run these queries:

1. First, find all recent sessions excluding Ralph:
SELECT s.id, s.summary, s.cwd, s.branch, s.updated_at,
  (SELECT title FROM checkpoints WHERE session_id = s.id ORDER BY checkpoint_number DESC LIMIT 1) AS last_checkpoint
FROM sessions s
WHERE s.updated_at >= datetime('now', '-48 hours')
  AND (s.summary IS NULL OR LOWER(s.summary) NOT LIKE '%ralph%')
  AND s.id NOT IN (
    SELECT DISTINCT t.session_id FROM turns t
    WHERE t.turn_index = 0
      AND (LOWER(t.user_message) LIKE '%ralph%' OR LOWER(t.user_message) LIKE '%keep-alive%' OR LOWER(t.user_message) LIKE '%heartbeat%')
  )
ORDER BY s.updated_at DESC
LIMIT 30;

2. Then show the FULL session IDs grouped by working directory, with summary and last checkpoint, formatted as a clean table.

3. Highlight any sessions that mention: monetization, aspire, podcast, or pending issues.

Show the results so I can pick which session to resume with: agency copilot --resume SESSION_ID

Convenience Script

A PowerShell script is available at scripts/recover-sessions.ps1 that automates the full workflow:

powershell
# Find sessions from the last 24 hours (default), excluding Ralph
.\scripts\recover-sessions.ps1

# Look back 48 hours
.\scripts\recover-sessions.ps1 -Hours 48

# Filter by keyword
.\scripts\recover-sessions.ps1 -Filter "monetization"

# Include Ralph sessions too
.\scripts\recover-sessions.ps1 -ExcludeRalph:$false

Tips

  • FTS5 query expansion: The search_index table uses keyword matching, not semantic search. Search for synonyms: 'auth OR login OR token OR JWT'
  • Time windows: Start with -24 hours, expand to -48 hours or -7 days if needed
  • Session IDs are UUIDs: Always copy the full ID for --resume
  • Check checkpoints first: They show what stage the session was at when it closed
  • Multiple keywords: Use MATCH 'word1 OR word2' in FTS5, or LIKE '%word%' for substring matching
  • Working directory matters: Filter by cwd to find sessions for a specific project

Anti-Patterns

  • Don't search by partial session IDs — always use full UUIDs
  • Don't try to resume sessions that completed successfully — they have no pending work
  • Don't use MATCH with special characters without escaping — wrap in double quotes: MATCH '"C:\path"'
  • Don't skip the Ralph filter — Ralph sessions are high-volume and will flood results

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Session Recovery AI skill do?

Find and resume recently closed Copilot CLI sessions. Use when a session was accidentally closed, or to find past sessions by topic, working directory, or time range. Triggers on: recover session, find session, resume session, lost session, closed session, recent sessions.

Why use Session Recovery on TypingMind?

Because you install it once and use it with any model. Session Recovery is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Session Recovery in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recovery. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Session Recovery?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Session Recovery?

As many as you like. As long as a model supports skills, you can use Session Recovery with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Session Recovery AI skill free?

Yes. It is published on GitHub by tamirdresher under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇