session-recovery
Skill227 starsChanged 9 months agoApache-2.0View on GitHub
Find and resume interrupted Copilot CLI sessions using session_store queries
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 62
Use the search_index FTS5 table for keyword search.
- Distinctive: line 89
Before resuming, inspect what the session was doing:
- Distinctive: line 139
Check its last checkpoint — was the code committed?
- Distinctive: line 143
Use FTS5 search with feature keywords
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context
Squad agents run in Copilot CLI sessions that can be interrupted — terminal crashes, network drops, machine restarts, or accidental window closes. When this happens, in-progress work may be left in a partially-completed state: branches with uncommitted changes, issues marked in-progress with no active agent, or checkpoints that were never finalized.
Copilot CLI stores session history in a SQLite database called session_store (read-only, accessed via the sql tool with database: "session_store"). This skill teaches agents how to query that store to detect interrupted sessions and resume work.
Patterns
1. Find Recent Sessions
Query the sessions table filtered by time window. Include the last checkpoint to understand where the session stopped:
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 Automated Sessions
Automated agents (monitors, keep-alive, heartbeat) create high-volume sessions that obscure human-initiated work. Exclude them:
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.id NOT IN (
SELECT DISTINCT t.session_id FROM turns t
WHERE t.turn_index = 0
AND (LOWER(t.user_message) LIKE '%keep-alive%'
OR LOWER(t.user_message) LIKE '%heartbeat%')
)
ORDER BY s.updated_at DESC;3. Search by Topic (FTS5)
Use the search_index FTS5 table for keyword search. Expand queries with synonyms since this is keyword-based, not semantic:
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 'auth OR login OR token OR JWT'
AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC
LIMIT 10;4. Search by Working Directory
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 '%my-project%'
AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC;5. Get Full Session Context Before Resuming
Before resuming, inspect what the session was doing:
-- Conversation turns
SELECT turn_index, substr(user_message, 1, 200) AS ask, timestamp
FROM turns WHERE session_id = 'SESSION_ID' ORDER BY turn_index;
-- Checkpoint progress
SELECT checkpoint_number, title, overview
FROM checkpoints WHERE session_id = 'SESSION_ID' ORDER BY checkpoint_number;
-- Files touched
SELECT file_path, tool_name
FROM session_files WHERE session_id = 'SESSION_ID';
-- Linked PRs/issues/commits
SELECT ref_type, ref_value
FROM session_refs WHERE session_id = 'SESSION_ID';6. Detect Orphaned Issue Work
Find sessions that were working on issues but may not have completed:
SELECT DISTINCT s.id, s.branch, s.summary, s.updated_at,
sr.ref_type, sr.ref_value
FROM sessions s
JOIN session_refs sr ON s.id = sr.session_id
WHERE sr.ref_type = 'issue'
AND s.updated_at >= datetime('now', '-48 hours')
ORDER BY s.updated_at DESC;Cross-reference with gh issue list --label "status:in-progress" to find issues that are marked in-progress but have no active session.
7. Resume a Session
Once you have the session ID:
# Resume directly
copilot --resume SESSION_IDExamples
Recovering from a crash during PR creation:
- Query recent sessions filtered by branch name
- Find the session that was working on the PR
- Check its last checkpoint — was the code committed? Was the PR created?
- Resume or manually complete the remaining steps
Finding yesterday's work on a feature:
- Use FTS5 search with feature keywords
- Filter to the relevant working directory
- Review checkpoint progress to see how far the session got
- Resume if work remains, or start fresh with the context
Anti-Patterns
- ❌ Searching by partial session IDs — always use full UUIDs
- ❌ Resuming sessions that completed successfully — they have no pending work
- ❌ Using
MATCHwith special characters without escaping — wrap paths in double quotes - ❌ Skipping the automated-session filter — high-volume automated sessions will flood results
- ❌ Assuming FTS5 is semantic search — it's keyword-based; always expand queries with synonyms
- ❌ Ignoring checkpoint data — checkpoints show exactly where the session stopped
Other versions8 projects use a version of this.
Word for word · 7
- github/gh-aw★ 5.5k100% same
- microsoft/Generative-AI-for-beginners-dotnet★ 3.2k100% same
- microsoft/waza★ 1.5k100% same
- kubefleet-dev/kubefleet★ 162100% same
- Azure/apiops-cli★ 32100% same
- microsoft/github-vteam-industry-demos★ 2100% same
- microsoft/fsi-banking-payments-dispute-resolution-accelerator★ 0100% same
Edited · 0
None found.
Wrote their own version · 1
- Songhonglei/better-agent-skills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use squad-commands, architectural-proposals and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillsquad-commands
Categorized catalog of common Squad operations. Coordinator reads this file and presents it as an interactive menu when the user asks for available commands or help.
Also in 5 projects that use this
MicrosoftSkillarchitectural-proposals
How to write comprehensive architectural proposals that drive alignment before code is written
Also in 4 projects that use this
- +10 more from microsoft
In this repository21 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- agent-collaborationSkill
- coordinator-init-modeSkill
- coordinator-response-modeSkill
- coordinator-source-of-truthSkill
- cross-squad-communicationSkill
- cross-squadSkill
- error-recoverySkill
- git-workflowSkill
- iterative-retrievalSkill
- reflectSkill
- reviewer-protocolSkill
- secret-handlingSkill
- squad-conventionsSkill
- squad-helpSkill
- squadSkill
- squad-version-checkSkill
- test-disciplineSkill
- tiered-memorySkill
- humanizerSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

