analyze-sessions

Analyze pi agent session logs for cost, prompts, and transcript search.

Updated Aug 19, 2025
One-click install
npx skills add https://github.com/loganmancuso-scout/dotfiles --skill analyze-sessions-loganmancuso-scout
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: analyze-sessions
Source: https://github.com/loganmancuso-scout/dotfiles/tree/main/dot_pi/agent/skills/analyze-sessions
Command: npx skills add https://github.com/loganmancuso-scout/dotfiles --skill analyze-sessions-loganmancuso-scout

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Pi agent sessions accumulate as JSONL transcripts under ~/.pi/agent/sessions, making it hard to answer questions about API spend, prompting habits, or past work without manually digging through raw log files. ## Core Features & Use Cases - Cost rollups: Sum usage.cost data across sessions grouped by day, project, model, or session, with subagent costs included by default so totals reflect real spend. - Prompt mining: Dump user prompts (filtered by length and topic) to spot recurring patterns worth turning into global instructions. - Session rendering and search: Render any session as readable markdown with truncation controls, or search across all transcripts with substring or regex matching. - Use Case: Run a 30-day cost breakdown by project to see which codebase consumes the most model spend, then search transcripts for a past discussion about a specific bug. ## Quick Start Ask the agent to show my total pi session cost for the last 30 days broken down by project.

Frequently Asked Questions about analyze-sessions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check my pi agent API costs per project?

Run cost.py with --by project and a time filter like --since 30d to get a spend breakdown per project. Subagent costs are included by default so totals reflect actual spend, and --json gives machine-readable output.

How to search past AI agent session transcripts?

Use search.py with a substring pattern, or --regex for regular expressions with smart-case matching. Scope results with --in user or --in assistant, and each hit prints a show_session.py command to drill into the full session.

Does this require installing Python packages?

No, all scripts use only the Python 3 standard library with zero external dependencies. They read JSONL session files directly from ~/.pi/agent/sessions and never modify them.

Are subagent sessions included in cost totals?

Yes, cost.py includes subagent transcripts by default so totals match real spend; use --no-subagents to exclude them or --show-subagents to see the subagent share. The other scripts exclude subagents by default.

Why are long prompts missing from the prompts dump?

prompts.py drops prompts longer than --max-chars (default 2000) because they are usually pasted context rather than actual prompting. Pass --max-chars 0 to disable the limit and include everything.