Diagnose self-improvement plugin health and configuration issues
/plugin marketplace add C0ntr0lledCha0s/claude-code-plugin-automations/plugin install self-improvement@claude-code-plugin-automationsclaude-haiku-4-5Run comprehensive diagnostics on the self-improvement plugin to identify configuration issues, validate data integrity, and verify automation is working correctly.
ā¹ļø Command Type: This command runs actual diagnostic checks using bash scripts. It provides actionable troubleshooting information for plugin issues.
Execute the diagnostic checks:
# Check database files
LOG_DIR="${HOME}/.claude/self-improvement"
echo "š„ Self-Improvement Plugin Health Check"
echo "========================================"
echo ""
# Check database files
echo "š Database Files:"
for db in patterns.json learnings.json metrics.json; do
if [[ -f "${LOG_DIR}/${db}" ]]; then
echo " ā
${db} exists"
# Validate JSON
if jq empty "${LOG_DIR}/${db}" 2>/dev/null; then
echo " ā
Valid JSON structure"
# Show record counts
case "${db}" in
patterns.json)
count=$(jq '.patterns | length' "${LOG_DIR}/${db}" 2>/dev/null || echo "0")
echo " š ${count} patterns tracked"
;;
learnings.json)
count=$(jq '.learnings | length' "${LOG_DIR}/${db}" 2>/dev/null || echo "0")
echo " š ${count} learnings stored"
;;
metrics.json)
count=$(jq '.sessions | length' "${LOG_DIR}/${db}" 2>/dev/null || echo "0")
echo " š¼ ${count} sessions analyzed"
;;
esac
else
echo " ā CORRUPTED JSON - needs repair"
fi
else
echo " ā ļø ${db} not found (not created yet)"
fi
done
echo ""
echo "š Transcript Storage:"
# Check Claude Code's actual transcript storage location
PROJECTS_DIR="${HOME}/.claude/projects"
if [[ -d "${PROJECTS_DIR}" ]]; then
echo " ā
Projects directory exists: ${PROJECTS_DIR}"
# Count JSONL files
jsonl_count=$(find "${PROJECTS_DIR}" -name "*.jsonl" 2>/dev/null | wc -l || echo "0")
echo " š Found ${jsonl_count} conversation transcript(s)"
# Show most recent
if [[ ${jsonl_count} -gt 0 ]]; then
recent=$(find "${PROJECTS_DIR}" -name "*.jsonl" -type f -printf '%T@ %p\n' 2>/dev/null | sort -n | tail -1 | cut -d' ' -f2- || true)
if [[ -n "${recent}" ]]; then
echo " š Most recent: ${recent}"
fi
fi
echo ""
echo " ā¹ļø Transcripts are provided via hook stdin payload (transcript_path field)"
echo " The SessionEnd hook receives the path automatically"
else
echo " ā ļø Projects directory not found: ${PROJECTS_DIR}"
echo " This is normal if Claude Code hasn't been used yet"
fi
echo ""
echo "šŖ Hook Execution:"
# Check analysis log
if [[ -f "${LOG_DIR}/analysis.log" ]]; then
echo " ā
Analysis log exists: ${LOG_DIR}/analysis.log"
echo ""
echo " š Last 5 analysis runs:"
tail -n 15 "${LOG_DIR}/analysis.log" | grep -E "\[.*\] ===" | tail -n 5 || echo " No analysis runs found"
echo ""
echo " š Recent activity (last 10 lines):"
tail -n 10 "${LOG_DIR}/analysis.log" | sed 's/^/ /'
else
echo " ā ļø No analysis log found"
echo " Either hooks haven't run yet, or there's a configuration issue"
fi
echo ""
echo "āļø Configuration:"
echo " CLAUDE_PLUGIN_ROOT: ${CLAUDE_PLUGIN_ROOT:-not set}"
echo " LOG_DIR: ${LOG_DIR}"
echo " PROJECTS_DIR: ${PROJECTS_DIR}"
echo ""
echo "š Summary Statistics:"
if [[ -f "${LOG_DIR}/patterns.json" ]]; then
echo ""
echo " š Top Patterns:"
jq -r '.patterns | sort_by(-.count) | .[:5] | .[] | " \(.severity | ascii_upcase): \(.type) (seen \(.count)x)"' "${LOG_DIR}/patterns.json" 2>/dev/null || echo " No patterns data"
fi
if [[ -f "${LOG_DIR}/learnings.json" ]]; then
echo ""
echo " š Recent Learnings:"
jq -r '.learnings | .[-5:] | .[] | " ⢠\(.text)"' "${LOG_DIR}/learnings.json" 2>/dev/null || echo " No learnings data"
fi
if [[ -f "${LOG_DIR}/metrics.json" ]]; then
echo ""
echo " š Metrics:"
total=$(jq '.sessions | length' "${LOG_DIR}/metrics.json" 2>/dev/null || echo "0")
avg=$(jq '[.sessions[].total_turns] | add / length | floor' "${LOG_DIR}/metrics.json" 2>/dev/null || echo "0")
echo " Total sessions: ${total}"
echo " Average conversation length: ${avg} turns"
fi
echo ""
echo "ā
Health check complete!"
echo ""
echo "š” Troubleshooting Tips:"
echo " ⢠Transcripts are provided automatically via hook stdin payload"
echo " ⢠If databases corrupted, delete them and they'll be recreated"
echo " ⢠If no analysis runs, check SessionEnd hook is properly configured"
echo " ⢠Check ${LOG_DIR}/analyze-debug.log for detailed debugging info"
echo " ⢠See: ${LOG_DIR}/analysis.log for analysis history"
All checks pass:
Action: No action needed. Plugin is working correctly.
Some issues detected:
Action: Follow troubleshooting tips in output.
Major problems:
Action: See repair instructions below.
Symptoms:
ā ļø No analysis log found
Possible Causes:
Fix Options:
Check hook configuration:
hooks/hooks.json has SessionEnd event (not Stop)Check dependencies:
which jq python3
Check debug log for errors:
cat ~/.claude/self-improvement/analyze-debug.log
Manual analysis only (alternative):
/quality-check and /review-my-work commands manuallySymptoms:
ā CORRUPTED JSON - needs repair
Fix:
# Backup corrupted file
mv ~/.claude/self-improvement/patterns.json ~/.claude/self-improvement/patterns.json.backup
# File will be recreated on next analysis
# Or manually recreate:
echo '{"patterns": []}' > ~/.claude/self-improvement/patterns.json
Symptoms:
ERROR: No transcript_path in hook payload
Possible Causes:
SessionEnd)transcript_pathFix:
# Check hooks.json configuration
cat ~/.claude/plugins/self-improvement/hooks/hooks.json | jq '.hooks'
# Verify SessionEnd event is configured (not Stop)
# The hook should receive transcript_path automatically
# Check debug log for received payload
cat ~/.claude/self-improvement/analyze-debug.log | grep "Received payload"
Symptoms:
š 0 patterns tracked
š 0 learnings stored
Explanation: This is normal if:
Not a problem: Data will accumulate over time.
# CAUTION: This deletes all tracked patterns, learnings, and metrics
cd ~/.claude/self-improvement
# Backup first
mkdir -p backups
cp patterns.json learnings.json metrics.json backups/ 2>/dev/null || true
# Reset databases
echo '{"patterns": []}' > patterns.json
echo '{"learnings": []}' > learnings.json
echo '{"sessions": []}' > metrics.json
echo "Databases reset. Fresh start!"
# Pretty-print patterns
jq '.' ~/.claude/self-improvement/patterns.json
# Pretty-print learnings
jq '.' ~/.claude/self-improvement/learnings.json
# Pretty-print metrics
jq '.' ~/.claude/self-improvement/metrics.json
Run this command when:
/self-improvement:show-patterns - View tracked patterns/self-improvement:show-learnings - View learning points/self-improvement:show-metrics - View conversation metricsDiagnostic tool for ensuring the self-improvement plugin is working correctly š„