Command Palette

Search for a command to run...

Back to skills
skill № 92324

pi-sessions

Find, list, and analyse pi agent sessions with DuckDB. Use when the user asks about past pi conversations, session history, costs, what pi did, reviewing a…

FreeRuns bundled scripts
juanibiapinaby juanibiapina★ 33 GitHub stars

Install pi-sessions in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Pi Sessions

Pi stores conversation sessions as JSONL event streams. Each line is a JSON object with a type field. Query them with DuckDB.

Key structural fact: message fields are nested under a message struct — use message.role, message.content, message.usage. Bare role/content do not exist as top-level JSONL columns. Before writing any DuckDB query, read references/queries.md and adapt the closest example; do not improvise a schema.

Treat conversation inspection (what happened in one session) and cross-session analytics (counts, trends, costs) as separate branches. Start with the narrowest data that answers the request.

Scripts and reference queries live next to this file. Resolve paths relative to this skill directory.

File Location

~/.pi/agent/sessions/--<path>--/<timestamp>_<uuid>.jsonl

Directory names encode the working directory with / replaced by -.

Example: sessions for /Users/juan/workspace/juanibiapina/dotfiles live in:

~/.pi/agent/sessions/--Users-juan-workspace-juanibiapina-dotfiles--/

Filenames look like 2026-04-30T14-04-00-598Z_<uuid>.jsonl.

Finding Sessions

Start with dev pi recent. It reads a catalog of every session on this machine and prints JSON with each session's ID, title, first prompt, cwd, last activity, and transcript path, newest first. It answers in milliseconds, while scanning the raw transcripts reads gigabytes. Narrow it with --query <text> (title, first prompt, or cwd) and --limit <n>; dev pi recent --help describes the fields. Search the transcripts directly only for text the catalog lacks, such as later messages or a session ID, which is in the filename.

List all session directories (one per project):

ls ~/.pi/agent/sessions/

List sessions for a project (most recent last):

ls -t ~/.pi/agent/sessions/--<path>--/

Find sessions by date:

fd '^2026-03-18' ~/.pi/agent/sessions/

Find sessions containing specific text:

rg -l "search term" ~/.pi/agent/sessions/--<path>--/

Inspect a conversation

Use this branch when given a session file or asked what happened in a session.

1. Resolve one session

Use the supplied .jsonl path. If none is supplied, find it with dev pi recent using the project, time, or title from the request, or by its session ID in the filename (see Finding Sessions), then identify the chosen file before querying it.

Completion criterion: exactly one session file is selected, unless the request explicitly compares sessions.

2. Profile its contents

Count events by role and content type before extracting text. This reveals the amount of conversation, thinking, tool calls, and tool results without loading their payloads.

Use the profiling query in references/queries.md.

Completion criterion: the session's message and content composition is known.

3. Extract the text-only transcript

The default conversation projection is:

  • roles: user, assistant
  • content type: text
  • order: event timestamp, then content position

This selects conversational text while leaving tool calls, tool results, and thinking out of the transcript.

From this skill directory:

bash ./scripts/conversation-text.sh /absolute/path/to/session.jsonl \
  > /tmp/pi-conversation.csv

Read the complete output, in chunks when necessary. Preserve the transcript as evidence; summarize only after all extracted rows have been inspected.

Completion criterion: every text row in the selected conversation has been inspected, and the answer is grounded in those rows.

4. Broaden only for the question

If the transcript points to missing implementation or debugging evidence, query the relevant content explicitly — such as tool names, a specific tool result, or thinking blocks. Keep the text-only transcript as the primary narrative.

See references/queries.md for transcript variants, fragment search, cost, and tool queries. See references/schema.md when a content shape or event type is unclear.

Analyze sessions

Use this branch for counts, trends, project activity, time ranges, costs, or comparisons across sessions.

Create the bundled views in a DuckDB database:

duckdb pi_sessions.duckdb < ./scripts/create_views.sql

The views are:

  • pi_events — raw events with derived session_id and session_group
  • pi_messages — message events
  • pi_conversation — user/assistant text grouped into chronological message rows
  • pi_tool_calls — assistant tool calls

Run the relevant query from references/queries.md, narrowing by session, project, or time range as early as possible.

Completion criterion: the query covers the requested scope and the result has been checked for unexpected roles or content types.

JSONL record types

See references/schema.md for the full event

Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • references/queries.md
  • references/schema.md
  • scripts/conversation-text.sh
  • scripts/create_views.sql

FAQ

What does the pi-sessions skill do?

Find, list, and analyse pi agent sessions with DuckDB. Use when the user asks about past pi conversations, session history, costs, what pi did, reviewing a session, summarizing or extracting conversation text, or debugging agent behaviour.

How do I install the pi-sessions skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the pi-sessions skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare pi-sessions with