Skip to content
Back to skills

Search Sessions

ASecurity

Search saved pi chats, pi conversations, pi sessions, Claude Code chats, Claude Code conversations, and Claude Code sessions. Triggers: "search pi chats", "search pi conversations", "search pi sessions", "find in pi chats", "search Claude Code sessions", "search Claude Code conversations", "search Claude chats", "find in Claude history", "where did we discuss", "search agent conversations".

  • 38 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 8, 2026
ai-agentsbash

Works with

  • claude code

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add richardgill/nix --skill search-sessions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Search Sessions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Search Sessions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/richardgill-search-sessions/badge)](https://www.skillsdirectory.com/skills/richardgill-search-sessions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: search-sessions
description: |
  Search saved pi chats, pi conversations, pi sessions, Claude Code chats, Claude Code conversations, and Claude Code sessions.
  Triggers: "search pi chats", "search pi conversations", "search pi sessions", "find in pi chats", "search Claude Code sessions", "search Claude Code conversations", "search Claude chats", "find in Claude history", "where did we discuss", "search agent conversations".
---

# Search Sessions

Use this skill when asked to search previous agent chats, conversations, session history, or saved JSONL transcripts for pi or Claude Code.

## Scope

- pi sessions: `~/.pi/agent/sessions`
- Claude Code sessions: `~/.claude/projects`
- Include Claude Code subagent sessions.
- If the user names pi or Claude Code, search only that store.
- If the user asks for this folder, current folder, current project, or this repo, derive the session directory from `$PWD` and search only that directory.
- If the user asks for both/all or does not specify, search pi first, then Claude Code, and report the results in separate groups.

## Pi current-folder search command

Replace `SEARCH TERMS` with the user's query.

```bash
q='SEARCH TERMS'
session_key=$(printf '%s' "$PWD" | sed 's#^/##; s#/#-#g')
rg -0 -l --no-messages --glob '*.jsonl' -i -F "$q" "$HOME/.pi/agent/sessions/--$session_key--" \
  | xargs -0 -r jq -r --arg q "$q" '
    def text:
      if type == "string" then .
      elif type == "array" then map(if type == "string" then . elif .type == "text" then .text else empty end) | join("\n")
      else empty end;
    . as $e
    | ($e.message? // $e) as $m
    | ($m.role? // empty) as $role
    | select($role == "user" or $role == "assistant")
    | (($m.content? // "") | text) as $text
    | select($text | ascii_downcase | contains($q | ascii_downcase))
    | "--- " + input_filename + " " + ($e.timestamp // "") + " " + $role + "\n" + $text + "\n"
  '
```

## Claude Code current-folder search command

Replace `SEARCH TERMS` with the user's query.

```bash
q='SEARCH TERMS'
session_key=$(printf '%s' "$PWD" | sed 's#^/##; s#/#-#g')
rg -0 -l --no-messages --glob '*.jsonl' -i -F "$q" "$HOME/.claude/projects/-$session_key" \
  | xargs -0 -r jq -r --arg q "$q" '
    def text:
      if type == "string" then .
      elif type == "array" then map(if type == "string" then . elif .type == "text" then .text else empty end) | join("\n")
      else empty end;
    . as $e
    | ($e.message? // $e) as $m
    | ($m.role? // empty) as $role
    | select($role == "user" or $role == "assistant")
    | (($m.content? // "") | text) as $text
    | select($text | ascii_downcase | contains($q | ascii_downcase))
    | "--- " + input_filename + " " + ($e.timestamp // "") + " " + $role + "\n" + $text + "\n"
  '
```

## Pi all-sessions search command

Replace `SEARCH TERMS` with the user's query.

```bash
q='SEARCH TERMS'
rg -0 -l --no-messages --glob '*.jsonl' -i -F "$q" "$HOME/.pi/agent/sessions" \
  | xargs -0 -r jq -r --arg q "$q" '
    def text:
      if type == "string" then .
      elif type == "array" then map(if type == "string" then . elif .type == "text" then .text else empty end) | join("\n")
      else empty end;
    . as $e
    | ($e.message? // $e) as $m
    | ($m.role? // empty) as $role
    | select($role == "user" or $role == "assistant")
    | (($m.content? // "") | text) as $text
    | select($text | ascii_downcase | contains($q | ascii_downcase))
    | "--- " + input_filename + " " + ($e.timestamp // "") + " " + $role + "\n" + $text + "\n"
  '
```

## Claude Code all-sessions search command

Replace `SEARCH TERMS` with the user's query.

```bash
q='SEARCH TERMS'
rg -0 -l --no-messages --glob '*.jsonl' -i -F "$q" "$HOME/.claude/projects" \
  | xargs -0 -r jq -r --arg q "$q" '
    def text:
      if type == "string" then .
      elif type == "array" then map(if type == "string" then . elif .type == "text" then .text else empty end) | join("\n")
      else empty end;
    . as $e
    | ($e.message? // $e) as $m
    | ($m.role? // empty) as $role
    | select($role == "user" or $role == "assistant")
    | (($m.content? // "") | text) as $text
    | select($text | ascii_downcase | contains($q | ascii_downcase))
    | "--- " + input_filename + " " + ($e.timestamp // "") + " " + $role + "\n" + $text + "\n"
  '
```

## Output

- Group results under `pi` and `Claude Code` when searching both.
- Show the matching file path, timestamp, role, and a short relevant excerpt.
- If there are many matches, show the best few and say how many files matched.
- To resume pi, use `pi --session <path-or-id>`.
- To inspect Claude Code history, open the matched JSONL file path.

$ARGUMENTS

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.