From claude-optimize
Use when running /optimize:audit, /optimize:skills, /optimize:hooks, or /optimize:discover to analyze recent Claude Code session logs for tool usage patterns, error frequency, repeated workflows, and automation opportunities. Do NOT trigger on general coding tasks.
npx claudepluginhub btcdlabs/btcd-cc-marketplace --plugin claude-optimizeThis skill uses the workspace's default tool permissions.
Analyzes recent Claude Code session logs (JSONL format) to extract usage patterns, identify automation opportunities, and detect recurring errors. Powers data-driven recommendations across multiple optimize modes.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Designs, implements, and audits WCAG 2.2 AA accessible UIs for Web (ARIA/HTML5), iOS (SwiftUI traits), and Android (Compose semantics). Audits code for compliance gaps.
Analyzes recent Claude Code session logs (JSONL format) to extract usage patterns, identify automation opportunities, and detect recurring errors. Powers data-driven recommendations across multiple optimize modes.
Session logs are stored in the project-specific Claude directory:
~/.claude/projects/
Use Glob to find the project directory matching the current working directory, then find *.jsonl files within it. Sort by modification time and analyze up to 30 most recent sessions. For /optimize:discover, at least 15 sessions are needed for bloat detection. For other modes, 10 sessions is sufficient.
ALWAYS use the bundled script — it extracts all metrics needed by discover, audit, skills, and hooks modes. Do NOT write your own analysis scripts or inline Python. The bundled script covers all required metrics.
python3 ${CLAUDE_PLUGIN_ROOT}/skills/session-analyzer/scripts/analyze_sessions.py --max-sessions 30
The script auto-detects the project directory from the current working directory. To override:
python3 ${CLAUDE_PLUGIN_ROOT}/skills/session-analyzer/scripts/analyze_sessions.py --project-dir <path> --max-sessions 30
The script outputs 14 structured sections: tool usage, bash commands (base + full), file edits, file reads, glob/grep patterns, MCP tool calls, ToolSearch queries, error patterns, branches, workflow bigrams/trigrams, and session distribution.
Which tools are used most? High Read/Grep usage suggests exploration-heavy work. High Edit/Write suggests active development. High Bash usage suggests CLI-heavy workflows.
Commands run 5+ times across sessions with similar arguments are automation candidates. Look for:
Files edited most frequently suggest:
Recurring errors suggest:
Approximate from first-to-last timestamps. Long sessions may indicate complex tasks that could benefit from decomposition or specialized agents.
## Session Analysis Report
**Sessions analyzed**: [count]
**Date range**: [oldest] to [newest]
### Tool Usage (Top 10)
| Tool | Count | % of Total |
|------|-------|------------|
| Read | XXX | XX% |
| Edit | XXX | XX% |
| ... | ... | ... |
### Bash Commands (Top 10)
| Command | Count | Automation Candidate? |
|---------|-------|-----------------------|
| npm test | XX | Yes - hook or skill |
| git diff | XX | No - exploratory |
| ... | ... | ... |
### Most Edited Files (Top 10)
| File | Edit Count | Pattern |
|------|------------|---------|
| src/api/routes.ts | XX | Active development |
| ... | ... | ... |
### Error Summary
| Error Type | Count | Suggested Fix |
|------------|-------|---------------|
| [pattern] | XX | [hook/skill/config] |
### Automation Opportunities
1. [Specific opportunity with evidence]
2. [Specific opportunity with evidence]