Session Recoveryのロゴ

Session Recovery

コミュニティ
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.

概要

公開者tamirdresher
リポジトリsquad-skills
スキル名session-recovery
スター
44
フォーク
9
同梱ファイル
2
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    tamirdresherがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Session Recovery」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recovery
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでSession Recoveryを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にSession Recoveryを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Session Recoveryは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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.

TypingMindでSession Recoveryを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Session Recoveryはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにSession Recoveryをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/tamirdresher/squad-skills/tree/main/plugins/session-recoveryを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Session Recoveryを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Session Recoveryで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもSession Recoveryを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Session Recovery」は無料ですか?

はい。tamirdresherがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇