Critical: Never bulk-read full .jsonl files. Use sampling strategy below
to respect context budget.
Workflow
Discover session files — Glob ~/.claude/projects/*/*.jsonl. Filter by
mtime within time-range. Select up to 10 files, preferring recent.
Sample each file — Read first 20 lines + last 20 lines per file.
This captures session setup (tools, config) and final outcomes (errors,
completions). Skip files smaller than 5 lines.
Extract patterns from sampled lines:
Error-fix sequences: Tool call with error response followed by a
successful retry or different approach. Look for type: "tool_error" or
error messages in tool results, then the next tool call on the same target.
Tool failure rates: Count tool calls and failures per tool type
(Bash, Edit, Read, Grep, Glob, Write). A failure is any tool result
containing error indicators.
Cost signals: Estimate token usage per session from message counts
and approximate message sizes. Map to task complexity (small/medium/large)
based on message count thresholds: <20 small, 20-80 medium, >80 large.
Format findings — Structure as tables per Output Format below.
Every row must suggest a concrete improvement or be omitted.
Write output — Write to output-path. Create parent directories
if needed.
Output Format
# Session Patterns — <start-date> to <end-date>
## Error-Fix Sequences
| Error Pattern | Recovery Strategy | Frequency | Candidate Learning |
|---------------|-------------------|-----------|-------------------|
| <tool>: <error summary> | <what worked> | N occurrences | <rule or skill suggestion> |
## Tool Failure Rates
| Tool | Calls | Failures | Rate | Common Cause |
|------|-------|----------|------|--------------|
| Bash | N | N | N% | <top failure reason> |
## Cost Signals
| Session | Messages | Est. Tokens | Task Complexity |
|---------|----------|-------------|-----------------|
| <uuid-short> | N | ~Nk | small/medium/large |
## Recommended Actions
- <Concrete improvement derived from patterns above>
Quality Check
Every table row is actionable — suggests a specific improvement
Findings trace to specific session files (cite UUID prefix)
Output stays under ~100 lines — summarize, don't dump
Correct > Complete > Minimal (ACE-FCA)
If no meaningful patterns found, say so explicitly rather than padding
Common Pitfalls
Reading full transcripts: Sample only. First 20 + last 20 lines.
Max 10 files: Don't exceed. Prefer recent files over completeness.
False patterns: 1-2 occurrences are anecdotes, not patterns. Minimum 3
occurrences before reporting as a pattern.
Data dumps: Interpret the data. Raw counts without analysis are noise.
1---2name: mining-session-patterns3description: Session Pattern Mining4---56# Session Pattern Mining78**Target**: $ARGUMENTS910Mines Claude Code session transcripts for recurring patterns that feed11compound learning. Converts raw session data into actionable improvements.1213## Arguments1415| Position | Name | Required | Default | Description |16|----------|------|----------|---------|-------------|17| 1 | `time-range` | no | `7d` | Period to scan. E.g. `7d`, `30d`, `this-week`. |18| 2 | `output-path` | no | `docs/patterns/session-patterns.md` | Where to write findings. |1920**Examples:**2122```23/mining-session-patterns # Last 7 days, default output24/mining-session-patterns 30d # Last 30 days25/mining-session-patterns 7d ./patterns.md # Custom output path26```2728## Data Source2930```31~/.claude/projects/*/*.jsonl # Session transcripts32```3334**Critical**: Never bulk-read full `.jsonl` files. Use sampling strategy below35to respect context budget.3637## Workflow38391. **Discover session files** — Glob `~/.claude/projects/*/*.jsonl`. Filter by40 mtime within `time-range`. Select up to **10 files**, preferring recent.41422. **Sample each file** — Read **first 20 lines** + **last 20 lines** per file.43 This captures session setup (tools, config) and final outcomes (errors,44 completions). Skip files smaller than 5 lines.45463. **Extract patterns** from sampled lines:4748 - **Error-fix sequences**: Tool call with error response followed by a49 successful retry or different approach. Look for `type: "tool_error"` or50 error messages in tool results, then the next tool call on the same target.51 - **Tool failure rates**: Count tool calls and failures per tool type52 (Bash, Edit, Read, Grep, Glob, Write). A failure is any tool result53 containing error indicators.54 - **Cost signals**: Estimate token usage per session from message counts55 and approximate message sizes. Map to task complexity (small/medium/large)56 based on message count thresholds: <20 small, 20-80 medium, >80 large.57584. **Format findings** — Structure as tables per Output Format below.59 Every row must suggest a concrete improvement or be omitted.60615. **Write output** — Write to `output-path`. Create parent directories62 if needed.6364## Output Format6566```markdown67# Session Patterns — <start-date> to <end-date>6869## Error-Fix Sequences70| Error Pattern | Recovery Strategy | Frequency | Candidate Learning |71|---------------|-------------------|-----------|-------------------|72| <tool>: <error summary> | <what worked> | N occurrences | <rule or skill suggestion> |7374## Tool Failure Rates75| Tool | Calls | Failures | Rate | Common Cause |76|------|-------|----------|------|--------------|77| Bash | N | N | N% | <top failure reason> |7879## Cost Signals80| Session | Messages | Est. Tokens | Task Complexity |81|---------|----------|-------------|-----------------|82| <uuid-short> | N | ~Nk | small/medium/large |8384## Recommended Actions85- <Concrete improvement derived from patterns above>86```8788## Quality Check8990- Every table row is **actionable** — suggests a specific improvement91- Findings trace to specific session files (cite UUID prefix)92- Output stays under ~100 lines — summarize, don't dump93- Correct > Complete > Minimal (ACE-FCA)94- If no meaningful patterns found, say so explicitly rather than padding9596## Common Pitfalls9798- **Reading full transcripts**: Sample only. First 20 + last 20 lines.99- **Max 10 files**: Don't exceed. Prefer recent files over completeness.100- **False patterns**: 1-2 occurrences are anecdotes, not patterns. Minimum 3101 occurrences before reporting as a pattern.102- **Data dumps**: Interpret the data. Raw counts without analysis are noise.
Run npx skillmds@latest add qte77/mining-session-patterns in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Session Pattern Mining It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
qte77 (@qte77) published this skill. Their other Agent Skills are listed on their SkillMD profile.