Analyze session logs to discover automation opportunities. Use periodically to find patterns in your Claude Code usage that could be automated. Use periodically after multiple sessions to find automation opportunities.
Analyze session logs to discover automation opportunities. Use periodically to find patterns in your Claude Code usage that could be automated. Use periodically after multiple sessions to find automation opportunities.
argument-hint
[--project <name>] [--targets-only]
allowed-tools
Read, Write, Glob, Grep, Bash
Analyze recorded session data from ALL Claude Code projects to identify patterns and automation opportunities.
Arguments
--project <name> — Analyze only sessions from the named project (matches the project field, which is the basename of the working directory)
--targets-only — Exclude toolkit sessions; only analyze target projects
Data Location
Session logs are stored centrally in ~/.claude/logs/sessions.jsonl in JSONL format (one compact JSON object per line).
Read ~/.claude/logs/sessions.jsonl and parse all entries.
If --project <name> was given, filter to entries where project matches.
If --targets-only was given, identify toolkit projects (see step 3) and exclude them.
If the file doesn't exist or is empty:
NO SESSION DATA
===============
No sessions have been logged yet.
Session logging is installed at the user level (~/.claude/hooks/session-end-logger.sh).
Run a few Claude Code sessions in any project, then run /analyze-sessions again.
If the hook is not installed, run /install-hooks and select "session-end-logger".
2. Calculate Statistics (Grouped by Project)
SESSION ANALYSIS
================
Total sessions: {N}
Date range: {earliest} to {latest}
Unique projects: {count}
Sessions per project:
- {project1}: {count} sessions ({first_date} – {last_date})
- {project2}: {count} sessions ({first_date} – {last_date})
3. Identify Target Projects
Scan ~/Projects/ for directories containing .claude/toolkit-version.json.
These are toolkit target projects. All other projects are either the toolkit itself or standalone.
Project Classification:
Toolkit: {toolkit project name}
Target projects: {list of target project names}
Other: {list of other project names}
4. Analyze Transcripts (If Available)
For each session with an accessible transcript_path:
Read the transcript file
Look for these patterns:
Manual Interventions:
AskUserQuestion tool calls — Questions asked during sessions
Text containing "manually", "by hand", "human must"
Repeated similar questions across sessions
Common Blockers:
Text containing "BLOCKED", "blocked", "waiting for"
Error patterns that recur
Missing credentials/env vars
Tool Usage Patterns:
Count of each tool type used
Sequences of tools that repeat
Workflow Friction:
"cd" into directories (wrong directory issues)
Repeated file lookups (missing context)
Re-reading same files multiple times
5. Identify Automation Opportunities
Based on patterns found, identify:
High Impact (Repeated across 3+ sessions):
Manual steps that could be automated with curl/Bash