Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Claude Doctor Session Diagnostics

BSecurity

> 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`.

81 stars
0 votes
0 copies
0 views
Added 9/19/2026
developmenttypescriptgobashnodegitapi

Works with

claude codecliapi

Security Analysis

B84/100
mediumInstalls packages at runtime which could introduce malicious dependencies
mediumInstalls packages at runtime which could introduce malicious dependencies

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add reason-machines/trending-skills --skill claude-doctor-session-diagnostics --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Claude Doctor Session Diagnostics?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Claude Doctor Session Diagnostics
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/reason-machines-claude-doctor-session-diagnostics/badge)](https://www.skillsdirectory.com/skills/reason-machines-claude-doctor-session-diagnostics)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
```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
```

## Key Commands

```bash
# 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
```

## What It Detects

### Structural Signals

| 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 |

### Behavioral Signals

| 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.).

## Generating Rules (`--rules`)

The most actionable feature — scans your full history and outputs rules tuned to your actual patterns:

```bash
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`.

## Saving a Persistent Model (`--save`)

```bash
claude-doctor --save
```

Creates `.claude-doctor/` in the current directory with:

- `model.json` — signal baselines and project profiles
- `guidance.md` — agent-readable rules suitable for CLAUDE.md inclusion or hook injection

You can reference `guidance.md` from your `CLAUDE.md`:

```markdown
<!-- CLAUDE.md -->
# Project Rules

<!-- Auto-generated diagnostics -->
{{include .claude-doctor/guidance.md}}
```

Or source it in a hook script:

```bash
#!/bin/bash
# .claude/hooks/pre-session.sh
cat .claude-doctor/guidance.md
```

## JSON Output for Scripting

```bash
# 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:

```json
{
  "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"
  }
}
```

## Common Workflows

### Weekly session audit

```bash
# Full audit with saved model
claude-doctor --save

# Review guidance
cat .claude-doctor/guidance.md
```

### Project-specific rule generation

```bash
# 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
```

### Diagnose a single bad session

```bash
# 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
```

### CI integration — fail on high-severity signals

```bash
#!/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
```

## TypeScript API (programmatic use)

The package exposes internal modules if you want to integrate diagnostics into your own tooling:

```typescript
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);
```

```typescript
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}`);
}
```

## Development

```bash
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
```

## Troubleshooting

**No sessions found**
- Transcripts must exist at `~/.claude/`. Run at least one Claude Code session first.
- Check `ls ~/.claude/projects/` to confirm transcript directories exist.

**`--rules` produces generic output**
- More sessions = better rules. Aim for 50+ sessions before generating rules.
- Use `-p myproject` to scope rules to a specific project's patterns.

**Permission errors reading `~/.claude/`**
```bash
chmod -R u+r ~/.claude/
```

**JSON output is empty signals array**
- Your sessions may be too short (fewer than 3 turns). High-abandonment sessions still count in the `high-abandonment-rate` signal.

**TypeScript errors when importing**
```bash
# Ensure you're on a compatible Node version
node --version  # requires Node 18+
pnpm build      # rebuild after pulling updates
```
```

Attribution

reason-machinesreason-machines
View sourceMore from reason-machines →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →