From aradotso-trending-skills-37
Analyzes Claude Code session transcripts for behavioral anti-patterns like edit thrashing, error loops, and correction-heavy interactions, then generates CLAUDE.md rules to prevent them.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aradotso-trending-skills-37:claude-doctor-session-diagnosticsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```markdown
---
name: claude-doctor-session-diagnostics
description: Diagnose Claude Code sessions for behavioral anti-patterns and auto-generate CLAUDE.md rules from transcript history
triggers:
- analyze my claude sessions
- diagnose claude code behavior
- generate CLAUDE.md rules from history
- check for edit thrashing in my sessions
- why does claude keep making the same mistakes
- audit my claude transcript history
- find anti-patterns in my AI coding sessions
- create rules from my claude session history
---
# claude-doctor Session Diagnostics
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
`claude-doctor` reads your `~/.claude/` JSONL transcripts, scores them for structural and behavioral anti-patterns, and generates ready-to-paste rules for `CLAUDE.md` or `AGENTS.md`.
## Install
```bash
# Global install
npm i -g claude-doctor
# Or run without installing
npx claude-doctor
# Analyze all sessions (default)
claude-doctor
# Analyze a specific session by ID
claude-doctor <session-id>
# Analyze a specific JSONL file directly
claude-doctor path/to/session.jsonl
# Filter to a named project
claude-doctor -p myproject
# Generate rules for CLAUDE.md / AGENTS.md
claude-doctor --rules
# Save model and guidance to .claude-doctor/
claude-doctor --save
# Output results as JSON (for piping/scripting)
claude-doctor --json
# Combine flags
claude-doctor -p myproject --rules --json
| Signal | Meaning |
|---|---|
edit-thrashing | Same file edited 5+ times in one session |
error-loop | 3+ consecutive tool failures without approach change |
excessive-exploration | Read-to-edit ratio above 10:1 |
restart-cluster | Multiple sessions started within 30 minutes |
high-abandonment-rate | Most sessions have fewer than 3 user messages |
| Signal | Meaning |
|---|---|
correction-heavy | 20%+ of user messages start with "no", "wrong", "wait" |
keep-going-loop | User repeatedly says "keep going" / "continue" |
repeated-instructions | Same instruction rephrased within 5 turns (Jaccard >60%) |
negative-drift | Messages get shorter and more corrective over time |
rapid-corrections | User responds within 10s of agent output |
high-turn-ratio | User sends 1.5x+ messages per agent response |
Lexical scoring uses AFINN-165 sentiment with custom agent tokens (undo, revert, wrong, broken, etc.).
--rules)The most actionable feature — scans your full history and outputs rules tuned to your actual patterns:
claude-doctor --rules
Example output:
## Rules (auto-generated by claude-doctor)
Based on analysis of 838 sessions. Paste into your CLAUDE.md or AGENTS.md.
- Read the full file before editing. Plan all changes, then make ONE complete edit.
- After 2 consecutive tool failures, stop and change your approach entirely.
- When the user corrects you, stop and re-read their message.
- Complete the FULL task before stopping.
- Every few turns, re-read the original request to make sure you haven't drifted.
Paste the output directly into your project's CLAUDE.md or AGENTS.md.
--save)claude-doctor --save
Creates .claude-doctor/ in the current directory with:
model.json — signal baselines and project profilesguidance.md — agent-readable rules suitable for CLAUDE.md inclusion or hook injectionYou can reference guidance.md from your CLAUDE.md:
<!-- CLAUDE.md -->
# Project Rules
<!-- Auto-generated diagnostics -->
{{include .claude-doctor/guidance.md}}
Or source it in a hook script:
#!/bin/bash
# .claude/hooks/pre-session.sh
cat .claude-doctor/guidance.md
# Pipe into jq for signal filtering
claude-doctor --json | jq '.signals[] | select(.severity == "high")'
# Save report
claude-doctor --json > session-report.json
# Check a specific project's signals
claude-doctor -p myproject --json | jq '.signals[].name'
Example JSON shape:
{
"sessions": 838,
"project": "myproject",
"signals": [
{
"name": "edit-thrashing",
"severity": "high",
"count": 14,
"description": "Same file edited 5+ times in one session"
},
{
"name": "correction-heavy",
"severity": "medium",
"count": 23,
"description": "20%+ of user messages are corrections"
}
],
"sentiment": {
"score": -0.42,
"label": "negative"
}
}
# Full audit with saved model
claude-doctor --save
# Review guidance
cat .claude-doctor/guidance.md
# Generate rules scoped to one project
claude-doctor -p myproject --rules > /tmp/new-rules.md
# Append to existing CLAUDE.md
echo "" >> CLAUDE.md
cat /tmp/new-rules.md >> CLAUDE.md
# Find recent session IDs in ~/.claude/
ls ~/.claude/
# Analyze one session
claude-doctor abc123-session-id
# Or point at the file directly
claude-doctor ~/.claude/projects/myproject/abc123.jsonl
#!/bin/bash
# scripts/check-sessions.sh
SIGNALS=$(claude-doctor --json | jq '[.signals[] | select(.severity == "high")] | length')
if [ "$SIGNALS" -gt 0 ]; then
echo "High-severity session signals detected:"
claude-doctor --json | jq '.signals[] | select(.severity == "high")'
exit 1
fi
The package exposes internal modules if you want to integrate diagnostics into your own tooling:
import { analyzeSessions, generateRules } from 'claude-doctor';
// Analyze all sessions
const report = await analyzeSessions({
project: 'myproject', // optional filter
jsonl: undefined, // optional path to specific file
});
console.log(report.signals);
console.log(report.sentiment);
// Generate CLAUDE.md rules from report
const rules = generateRules(report);
console.log(rules);
import { analyzeFile } from 'claude-doctor';
// Analyze a single JSONL transcript
const result = await analyzeFile('~/.claude/projects/myproject/session.jsonl');
for (const signal of result.signals) {
console.log(`${signal.name} (${signal.severity}): ${signal.description}`);
}
git clone https://github.com/millionco/claude-doctor
cd claude-doctor
pnpm install
pnpm build
pnpm test
# Run locally against your own sessions
node dist/cli.js --rules
No sessions found
~/.claude/. Run at least one Claude Code session first.ls ~/.claude/projects/ to confirm transcript directories exist.--rules produces generic output
-p myproject to scope rules to a specific project's patterns.Permission errors reading ~/.claude/
chmod -R u+r ~/.claude/
JSON output is empty signals array
high-abandonment-rate signal.TypeScript errors when importing
# Ensure you're on a compatible Node version
node --version # requires Node 18+
pnpm build # rebuild after pulling updates
npx claudepluginhub joshuarweaver/cascade-ai-ml-agents-misc-1 --plugin aradotso-trending-skills-37Analyzes Claude Code sessions using MCP classifiers to detect usage patterns like correction spirals, rates severity, and provides concrete workflow improvements with metrics and advice.
Analyzes Claude Code session logs to extract tool usage stats, thinking blocks, error patterns, debug trajectories, and generate actionable productivity recommendations. Provides cc-session CLI for overviews, timelines, searches.
Generates an in-chat session report from Claude Code transcripts, showing every tool call, sub-agent delegation, and file edit with diagnostics for missed parallelism and redundant work.