kergoth/dotfiles/find-session

Claude Code and agent skill by kergoth/dotfiles

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Find and resume a past Pi, Claude Code, Codex, or Cursor Agent conversation by searching session history files by keyword. Use this skill whenever the user wants to find a previous conversation, can't remember which directory or agent they were using, wants to look up work from a past session, needs to resume a session they can't locate with /resume, pi --session, codex resume, or agent --resume, or says something like "I know we discussed X somewhere" or "where was that session about Y". Infers search scope, agent, and keywords from the user's description and presents matching sessions with summaries before asking which to resume. Always use this skill rather than manually searching ~/.claude/, ~/.codex/, ~/.cursor/, or ~/.pi/agent/sessions/ yourself.

Install

npx vskill@latest install kergoth/dotfiles/find-session

SKILL.md

The same SKILL.md was published earlier as kergoth/dotfiles/find-session.

Find Session

Search past Pi, Claude Code, Codex, or Cursor Agent session history by keyword and present matching sessions for resumption.

Step 1: Infer scope and extract keywords

From the user's description:

Scope:

  • "in this project" / "here" / "in this repo" / "in this directory" → --scope project --cwd "$(pwd)"
  • User names a specific project or repo (e.g. "it was in my-api-project", "in the backend-service repo") → resolve the path (check ~/Workspace/, ~/Repos/) and use --scope project --cwd <resolved-path>
  • "somewhere" / "I can't remember" / "I was working on X" / no location specified → --scope global
  • When ambiguous, default to --scope global

Agent:

  • User says "Pi" or asks for a Pi session -> --agent pi
  • User says "Claude", "Claude Code", or asks for a Claude session -> --agent claude
  • User says "Codex" or asks for a Codex session -> --agent codex
  • User says "Cursor" or asks for a Cursor Agent session -> --agent cursor
  • User does not identify the agent -> --agent all

Keywords: Extract 2–4 specific, concrete terms. Prefer domain nouns over generic verbs.

  • "that session about the marketplace proposal" → marketplace proposal
  • "where we set up the mender deployment" → mender deploy

Step 2: Run the search script

bash
python ~/.agents/skills/find-session/scripts/search_sessions.py \
--agent <pi|claude|codex|cursor|all> \
--scope <project|global> \
--depth quick \
--cwd <path> \
[--exclude <session_id>] \
<keyword1> [keyword2 ...]

The script outputs a JSON object with total_matching (all files rg found) and sessions (up to --max-results, default 10, sorted by match_count desc then recency). Read the output directly. If you need to filter, slice, or extract fields, pipe to jq — never pipe through python, python3, or write intermediate files.

If a result is clearly the current session (the one you're running in right now), re-run with --exclude <session_id> to drop it from results. --exclude is repeatable.

Output schema:

text
{
"total_matching": number, // total files rg matched (may exceed sessions shown)
"sessions": [
{
"agent": "pi" | "claude" | "codex" | "cursor",
"session_id": string, // UUID
"session_name": string | null, // explicit /rename title if set; falls back to first prompt from history.jsonl (may be a slash-command when no other entries exist); null if neither available
"has_custom_name": boolean, // true only when session_name came from an explicit /rename; false for fallback names
"resume_command": string, // agent-specific resume command
"away_summary": string | null, // recap summary stored by Claude Code on session pause; null if none
"project_dir": string, // absolute path to project cwd; empty when unresolved
"project_slug": string, // Cursor only — ~/.cursor/projects/<slug> directory name
"first_timestamp": string, // ISO8601
"last_timestamp": string, // ISO8601
"match_count": number, // keyword hit count (relevance signal)
"match_source": "parent" | "subagent", // optional; Cursor only — where the keyword hit occurred
"first_exchanges": [ // up to 1 (quick) or 3 (thorough)
{ "user": {role, text, timestamp},
"assistant": {role, text, timestamp} | null }
],
"last_exchanges": [...], // same structure, from end of session
"match_contexts": [ // one entry per non-overlapping keyword hit
{ "match": {role, text, timestamp},
"context_before": [{role, text, timestamp}, ...],
"context_after": [{role, text, timestamp}, ...] }
]
}
]
}

To fetch thorough context for specific sessions by ID (bypassing keyword search):

bash
python ~/.agents/skills/find-session/scripts/search_sessions.py \
--agent <pi|claude|codex|cursor|all> \
--depth thorough \
--session-ids <id1> --session-ids <id2> \
<keyword1> [keyword2 ...]

Step 3: Refine and verify candidates

Run Step 3a after every quick search. Use Steps 3b–3c when the target is still missing, then check Step 3d before presenting a Claude or Cursor candidate. Don't skip to keyword changes before inspecting the earlier results.

Step 3a: Get thorough context for the top candidates

After every quick search, run a targeted thorough pass on the top candidates (those with the highest match_count, typically the top 2–3) before presenting results or drawing any conclusions. Use --session-ids so you only read those files — not all 28 matches.

Extract full session IDs from the quick search output — never truncate and then reconstruct:

bash
# Extract full IDs for the top 3 candidates
<quick_output> | jq -r '[.sessions[:3] | .[].session_id] | join(" ")'

WARNING: Session IDs are UUIDs. If you only extracted a prefix (e.g., first 8 chars), do NOT attempt to reconstruct the full ID — you will hallucinate the suffix. Either re-extract the full ID from the original output, or pass the prefix directly (--session-ids supports unambiguous prefixes).

bash
python ~/.agents/skills/find-session/scripts/search_sessions.py \
--agent <pi|claude|codex|cursor|all> \
--depth thorough \
--session-ids <id1> --session-ids <id2> \
<same keywords>

Thorough widens the context window around each keyword hit (2 messages → 5), which is usually enough to distinguish "this session is about X" from "this session mentioned X in passing." It also gives better first/last exchanges for writing accurate summaries.

A session is substantive when keywords appear in the middle of real discussion about the topic. It's incidental when keywords only appear in a filename, a path, or a brief aside while working on something else.

Only move on to 3b/3c if thorough contexts still don't identify the right session.

Step 3b: Cap was applied (total_matching > sessions shown)

The right session may have been ranked out of the top N. Narrow before expanding:

  1. Narrow scope — if you haven't already, re-run with --scope project --cwd <project-path>. If the user mentioned a project, use it. This is usually enough.
  2. Narrow keywords — try more specific terms (a filename, a Jira ticket ID, a distinctive phrase the user remembers).
  3. Increase cap as last resort — if narrowing isn't possible, retry with --max-results 30.

Never tell the user the session wasn't found when the cap was applied — you haven't seen all the results yet.

Step 3c: Zero or few results, cap not applied

The keywords genuinely didn't match. Try variations:

  • Split compound/hyphenated terms: app-deploy → try app deploy or deploy alone
  • Try synonyms or adjacent terms the session might have used
  • Reduce to a single highly distinctive keyword
Step 3d: Check for an associated Pi session when relevant

A Claude or Cursor result can be a backing conversation used by a Pi bridge or delegated worker, rather than the session the user wants to resume. Do not assume that every Claude or Cursor session on a Pi user's machine belongs to Pi.

Skip this check when ~/.pi/agent/sessions/ has no session files. Otherwise, look for substantive Pi matches in the search results. If the search excluded Pi, or its results were capped, run a targeted --agent pi search using a distinctive human prompt from the candidate. Use the same scope initially; try global scope if the user identifies Pi as the intended interface or the candidate shows work across projects. Fetch thorough context for candidates as in Step 3a.

If no relevant Pi history is found, continue with the original results and resume commands. Do not add bridge warnings, uncertainty notices, or extra questions merely because Pi is installed. An unrelated Pi session or an earlier session-search conversation does not make a substantive match.

When relevant Pi history exists, check the relationship before presenting:

  • Prefer explicit lineage metadata linking the backing session ID to a Pi

session ID. Inspect candidate Pi records directly when needed; the search script reads user/assistant messages, not lineage metadata or tool results. Cursor integrations may record cursor-sdk-agent-lineage entries. Use such entries only when they identify the candidate's backing conversation.

  • Without an explicit link, compare multiple distinctive exchanges and their

timing. Require evidence of the work itself, not just a copied summary, shared instructions, title, topic, or a reference to another session. A backing UUID may be absent from Pi history, so search by conversation text as well.

  • Do not classify a conversation from historical entrypoint: "cli" or

"sdk-ts" fields alone. Reconstructed history can mix both, and a conversation may later be resumed outside Pi.

For a verified association, check where the requested work appears. If it is in Pi, lead with the Pi session and its returned resume command; identify the backing conversation secondarily instead of listing it as an independent choice. If the requested work appears only in later standalone Claude or Cursor turns, lead with that interface's resume command and mention Pi secondarily. Honor an explicit request to resume the backing conversation instead.

If substantive matches exist in both interfaces but their association or the intended continuation is ambiguous, present them as separate candidates. In interactive mode, ask which interface to resume; do not silently prefer Pi. In non-interactive mode, provide the candidate resume commands without claiming an association. Mere failure to verify a link does not require a warning.

Step 4: Detect interactive vs. non-interactive mode

Use the current agent interface first:

  • If you can ask the user a follow-up, use interactive mode.
  • If this is a one-shot print/API run where no follow-up is possible, use non-interactive mode.

For Claude Code, the entrypoint can confirm this:

bash
printenv CLAUDE_CODE_ENTRYPOINT
  • cli -> interactive mode
  • sdk-cli -> non-interactive mode (-p/--print)
  • unset or unknown -> infer from whether this agent run can ask follow-up questions; in Codex, default to interactive mode unless the invocation is clearly one-shot

Step 5: Summarize and present

For each session write a short (≤10 word) summary label. Always include a Session ID column for unnamed sessions so the resume command can target the exact session without another lookup.

When match_source is "subagent", mention that the keyword match came from subagent work in that session; resume still uses the parent session_id.

text
Found N sessions matching "<keywords>":
# Agent Date Project Name Session ID Summary
1 codex 2026-06-15 dotfiles 019ecea4 Find-session Codex support design
2 claude 2026-03-30 backend-service a1b2c3d4 Auth token refresh design sync
3 cursor 2026-06-10 dotfiles f7e8d9c0 Cursor workspace path mapping (subagent match)

Agent: agent. Date: YYYY-MM-DD from last_timestamp. Project: basename(project_dir). Name: session_name when has_custom_name is true (set via /rename), blank otherwise. Do not invent or infer names. Session ID: first 8 characters of session_id when has_custom_name is false, blank for explicitly named sessions. Summary: Use away_summary when present — it's a full-arc recap generated by Claude Code and is more reliable than synthesizing from exchanges. Fall back to deriving from first_exchanges, last_exchanges, and match_contexts when away_summary is null.

Step 6: Provide resume command(s)

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
31
Repository forks
1
7-day trend score
17

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 9 Jul 2026, 4 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kergoth/dotfiles/find-session/badge)](https://verified-skill.com/skills/kergoth/dotfiles/find-session)

Something wrong with this skill or its page? Tell us.