---
name: transcript-analysis
description: |
  Transcript and conversation analysis patterns.
  Use when extracting insights from session transcripts,
  analyzing conversations, or building learning loops.

allowed-tools:
  - Read
  - Grep
---

# Transcript Analysis Skill

## Transcript Location

Session transcripts stored at:
- Path provided in hook input: `transcript_path`
- Format: JSONL (one JSON object per line)

## Transcript Structure

```json
{"role": "user", "content": "...", "timestamp": "..."}
{"role": "assistant", "content": "...", "timestamp": "..."}
{"role": "tool_use", "tool": "Bash", "input": {...}}
{"role": "tool_result", "output": "..."}
```

## Analysis Patterns

### Extract Tool Usage

```python
def analyze_tool_usage(transcript):
    tools = [line for line in transcript if line["role"] == "tool_use"]
    return Counter(t["tool"] for t in tools)
```

### Find Errors

```python
def find_errors(transcript):
    return [line for line in transcript
            if "error" in line.get("output", "").lower()]
```

### Conversation Flow

```python
def analyze_flow(transcript):
    return [(line["role"], len(line.get("content", "")))
            for line in transcript]
```

## Learning Loop Integration

1. Analyze completed sessions
2. Identify patterns (success/failure)
3. Extract insights
4. Feed back to improve

## Best Practices

1. Parse JSONL line by line
2. Handle malformed lines
3. Extract actionable insights
4. Store learnings persistently
