Session analyzer

From ferologics/pi-skills · View interactive version

Session analyzer is an AI agent skill from the GitHub repository ferologics/pi-skills. Analyze pi session transcripts for repeated instructions and corrections, and route each to the cheapest layer that holds it (repo check, repo skill, AGENTS.md, prompt template, or skill).

How to use this skill

Skill file

Session Analyzer

Extracts and analyzes your pi session transcripts to find recurring patterns that could be automated.

Usage

# Extract transcripts for current directory
{baseDir}/analyze.js

# Extract transcripts for specific directory
{baseDir}/analyze.js /path/to/project

# Match multiple dirs by pattern (worktrees, variants, etc.)
{baseDir}/analyze.js --pattern orders-app

# Extract + analyze with subagents
{baseDir}/analyze.js --analyze

# Pattern + analyze (finds all matching session dirs)
{baseDir}/analyze.js --pattern orders-app --analyze

# Custom output directory
{baseDir}/analyze.js --output ./my-analysis --analyze

What It Does

  1. Extract: Reads all session files for the given working directory from ~/.pi/agent/sessions/
  1. Split: Chunks transcripts into ~100k char files (fits in context window)
  2. Analyze (optional): Spawns pi subagents that find repeated patterns and route each one per Routing, then aggregates them into one summary grouped by layer

Routing

Route each pattern to the first layer that can hold it. Early layers are enforced or load only when needed. Late layers cost context on every turn.

| Layer | TYPE | Use for |

| ----- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| 1 | repo-check | A mechanical rule (banned API or pattern, file location, format, a command that must run) as a lint rule, hook, CI job, type, or test whose failure names the fix |

| 2 | repo-skill | An occasional multi-step workflow in one repo |

| 3 | repo-agents-md | A judgment call needed on most tasks in one repo |

| 4 | prompt-template | A request the user types again and again |

| 5 | personal-skill | A cross-repo workflow the model should pick up when a task matches (pi-shit) |

| 6 | global-agents-md | Taste or a hard rule for every task in every repo (~/AGENTS.md) |

A pattern counts once it has happened twice. A correction that an existing rule already covers is a repeat: route it to a stronger layer than the rule that failed.

For each pattern, state why no earlier layer can hold it.

Applying findings

Findings are proposals. Apply only the ones the user picks.

Output

Without --analyze:

session-transcripts/
├── session-transcripts-000.txt
├── session-transcripts-001.txt
└── ...

With --analyze:

session-transcripts/
├── session-transcripts-000.txt
├── session-transcripts-000.summary.txt  # Pattern analysis
├── session-transcripts-001.txt
├── session-transcripts-001.summary.txt
└── FINAL-SUMMARY.txt                    # Aggregated findings

Setup

Install dependencies (run once):

cd {baseDir}
npm install

When to Use


_Adapted from badlogic/pi-mono gist_

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.