SuperAPI AI Directory

mbticlaude

General & other

View repository

Updated 10-16 09:05

About this skill

MBTIClaude

Infer MBTI personality types by analyzing user prompts across multiple AI tools (Claude Code, Codex, Gemini, OpenCode, OpenClaw).

Infer MBTI personality types by analyzing user prompts across multiple AI tools (Claude Code, Codex, Gemini, OpenCode, OpenClaw).

Features | Features

  • Automatically extract user prompt history from five AI tools | Automatically extract user prompt history from five AI tools
  • Analyze communication style, information processing, decision-making patterns, and lifestyle | Analyze communication style, information processing, decision-making patterns, and lifestyle
  • Infer MBTI type based on behavioral patterns | Infer MBTI type based on behavioral patterns
  • Provide detailed feature analysis and recommendations | Provide detailed feature analysis and recommendations

Usage | Usage

/mbticlaude

Analysis Dimensions | Analysis Dimensions

1. Communication Style (E vs I) | Communication Style

  • Prompt length and detail level | Prompt length and detail level
  • Social expression vs task-oriented | Social expression vs task-oriented
  • Richness of background information | Richness of background information

2. Information Processing (S vs N) | Information Processing

  • Focus on concrete details vs abstract concepts | Focus on concrete details vs abstract concepts
  • Implementation-oriented vs concept-oriented | Implementation-oriented vs concept-oriented
  • Expression of creative thinking | Expression of creative thinking

3. Decision Making (T vs F) | Decision Making

  • Logical vs emotional | Logical vs emotional
  • Task-oriented vs interpersonal considerations | Task-oriented vs interpersonal considerations
  • Technical language vs emotional expression | Technical language vs emotional expression

4. Lifestyle (J vs P) | Lifestyle

  • Planning vs flexibility | Planning vs flexibility
  • Structured vs exploratory | Structured vs exploratory
  • Rapid iteration vs systematic planning | Rapid iteration vs systematic planning

Data Sources | Data Sources

  • Claude Code: ~/.claude/history.jsonl
  • Codex: ~/.codex/history.jsonl
  • Gemini: ~/.gemini/tmp/*/chats/*.json
  • OpenCode: ~/.local/state/opencode/prompt-history.jsonl
  • OpenClaw: ~/.openclaw/agents/*/sessions/*.jsonl

Important Notes | Important Notes

⚠️ Important Reminders | Important Reminders:

  1. Sample based on work scenarios, may not reflect true personality | Sample based on work scenarios, may not reflect true personality
  2. MBTI itself has scientific controversies, for reference only | MBTI itself has scientific controversies, for reference only
  3. This is behavioral pattern inference, not professional psychological assessment | This is behavioral pattern inference, not professional psychological assessment
  4. Requires sufficient historical data for accurate conclusions | Requires sufficient historical data for accurate conclusions

Implementation | Implementation

#!/usr/bin/env python3
import json
import os
from pathlib import Path
from collections import Counter

def extract_claude_code_prompts(limit=100):
    """提取 Claude Code 用户提示词"""
    history_file = Path.home() / ".claude" / "history.jsonl"
    prompts = []
    
    if history_file.exists():
        with open(history_file, 'r') as f:
            for line in f:
                try:
                    data = json.loads(line)
                    if data.get('display'):
                        prompts.append(data['display'])
                except:
                    continue
    
    return prompts[-limit:] if prompts else []

def extract_codex_prompts(limit=100):
    """提取 Codex 用户提示词"""
    history_file = Path.home() / ".codex" / "history.jsonl"
    prompts = []
    
    if history_file.exists():
        with open(history_file, 'r') as f:
            for line in f:
                try:
                    data = json.loads(line)
                    if data.get('text'):
                        prompts.append(data['text'])
                except:
                    continue
    
    return prompts[-limit:] if prompts else []

def extract_gemini_prompts(limit=100):
    """提取 Gemini 用户提示词"""
    gemini_dir = Path.home() / ".gemini" / "tmp"
    prompts = []
    
    if gemini_dir.exists():
        for session_file in gemini_dir.rglob("session-*.json"):
            try:
                with open(session_file, 'r') as f:
                    data = json.load(f)
                    messages = data.get('messages', [])
                    for msg in messages:
                        if msg.get('role') == 'user':
                            content = msg.get('content', '')
                            if content:
                                prompts.append(content)
            except:
                continue
    
    return prompts[-limit:] if prompts else []

def extract_opencode_prompts(limit=100):
    """提取 OpenCode 用户提示词"""
    history_file = Path.home() / ".local" / "state" / "opencode" / "prompt-history.jsonl"
    prompts = []
    
    if history_file.exists():
        with open(history_file, 'r') as f:
            for line in f:
                try:
                    data = json.loads(line)
                    if data.get('input'):
                        prompts.append(data['input'])
                except:
                    continue
    
    return prompts[-limit:] if prompts else []

def extract_openclaw_prompts(limit=100):
    """提取 OpenClaw 用户提示词"""
    agents_dir = Path.home() / ".openclaw" / "agents"
    prompts = []
    
    if agents_dir.exists():
        for session_file in agents_dir.rglob("*.jsonl"):
            try:
                with open(session_file, 'r') as f:
                    for line in f:
                        try:
                            data = json.loads(line)
                            if data.get('type') == 'message' and data.get('message', {}).get('role') == 'user':
                                content = data['message'].get('content', [])
                                for item in content:
                                    if item.get('type') == 'text':
                                        text = item.get('text', '')
                                        # 过滤系统消息
                                        if not any(x in text for x in ['Sender (untrusted', 'Conversation info', 
                                                                       'Health check', 'Queued', 'Continue where',
                                                                       'subagent task', 'Pre-compaction']):
                                            prompts.append(text)
                        except:
                            continue
            except:
                continue
    
    return prompts[-limit:] if prompts else []

def analyze_communication_style(prompts):
    """分析沟通风格 (E vs I) - 优化版"""
    if not prompts:
        return "I"
    
    avg_length = sum(len(p) for p in prompts) / len(prompts)
    short_prompts = sum(1 for p in prompts if len(p) < 15)  # 降低阈值从20到15
    short_ratio = short_prompts / len(prompts)
    
    # 计算详细度得分
    detailed_prompts = sum(1 for p in prompts if len(p) > 100)
    detailed_ratio = detailed_prompts / len(prompts)
    
    # 检查是否有问号(提问倾向)
    question_count = sum(1 for p in prompts if '?' in p or '?' in p or 'how' in p.lower() or 'why' in p.lower() or '如何' in p or '为什么' in p)
    question_ratio = question_count / len(prompts)
    
    # 综合判断:提高 E 型出现概率
    e_score = 0
    if avg_length > 40:  # 降低阈值从50到40
        e_score += 1
    if short_ratio < 0.4:  # 提高阈值从0.3到0.4
        e_score += 1
    if detailed_ratio > 0.15:  # 有15%以上的详细提示词
        e_score += 1
    if question_ratio > 0.2:  # 有20%以上的提问
        e_score += 1
    
    return "E" if e_score >= 2 else "I"

def analyze_information_processing(prompts):
    """分析信息处理 (S vs N) - 优化版,支持英文"""
    if not prompts:
        return "S"
    
    # 扩展关键词,增加英文支持和权重
    abstract_keywords = {
        # 中文(权重2)
        '概念': 2, '系统': 2, '架构': 3, '方案': 2, '思路': 2, '抽象': 3,
        '模式': 2, '框架': 2, '理念': 2, '愿景': 2, '战略': 2,
        # 英文(权重2)
        'concept': 2, 'system': 2, 'architecture': 3, 'solution': 2, 'approach': 2,
        'pattern': 2, 'framework': 2, 'strategy': 2, 'vision': 2, 'abstract': 3
    }
    
    concrete_keywords = {
        # 中文(权重1)
        '具体': 1, '实现': 1, '细节': 1, '步骤': 1, '操作': 1,
        '按钮': 1, '颜色': 1, '间距': 1, '像素': 1, '字体': 1,
        # 英文(权重1)
        'specific': 1, 'implement': 1, 'detail': 1, 'step': 1, 'operation': 1,
        'button': 1, 'color': 1, 'spacing': 1, 'pixel': 1, 'font': 1
    }
    
    abstract_score = sum(weight for p in prompts for kw, weight in abstract_keywords.items() if kw in p.lower())
    concrete_score = sum(weight for p in prompts for kw, weight in concrete_keywords.items() if kw in p.lower())
    
    # 降低 N 型判定门槛
    return "N" if abstract_score > concrete_score * 0.8 else "S"

def analyze_decision_making(prompts):
    """分析决策方式 (T vs F) - 优化版,支持英文"""
    if not prompts:
        return "T"
    
    # 扩展关键词,增加英文支持
    logical_keywords = [
        # 中文
        '优化', '效率', '性能', '统计', '分析', '测试', '修复', '实现',
        '算法', '数据', '指标', '评估', '验证', '检查', '对比',
        # 英文
        'optimize', 'efficiency', 'performance', 'statistics', 'analyze', 'test', 'fix', 'implement',
        'algorithm', 'data', 'metric', 'evaluate', 'verify', 'check', 'compare'
    ]
    
    emotional_keywords = [
        # 中文
        '感觉', '喜欢', '希望', '想要', '谢谢', '辛苦', '帮忙', '麻烦',
        '期待', '担心', '开心', '满意', '友好', '舒服', '美观',
        # 英文
        'feel', 'like', 'hope', 'want', 'thanks', 'thank', 'please', 'appreciate',
        'expect', 'worry', 'happy', 'satisfied', 'friendly', 'comfortable', 'beautiful'
    ]
    
    logical_count = sum(1 for p in prompts for kw in logical_keywords if kw in p.lower())
    emotional_count = sum(1 for p in prompts for kw in emotional_keywords if kw in p.lower())
    
    # 降低 T 型判定门槛,让 F 型更容易出现
    return "T" if logical_count > emotional_count * 1.5 else "F"

def analyze_lifestyle(prompts):
    """分析生活方式 (J vs P) - 优化版,支持英文"""
    if not prompts:
        return "P"
    
    # 扩展关键词,增加英文支持
    planning_keywords = [
        # 中文
        '计划', '方案', '设计', 'PRD', '文档', '规划', '安排', '流程',
        '步骤', '阶段', '里程碑', '时间表', 'roadmap',
        # 英文
        'plan', 'design', 'schedule', 'organize', 'structure', 'process',
        'procedure', 'milestone', 'timeline', 'roadmap', 'workflow'
    ]
    
    flexible_keywords = [
        # 中文
        '试试', '测试', '优化', '调整', '改', '换', '尝试', '探索',
        '实验', '迭代', '看看', '试一下', '改进',
        # 英文
        'try', 'test', 'experiment', 'adjust', 'change', 'modify', 'explore',
        'iterate', 'adapt', 'improve', 'refine', 'tweak'
    ]
    
    planning_count = sum(1 for p in prompts for kw in planning_keywords if kw in p.lower())
    flexible_count = sum(1 for p in prompts for kw in flexible_keywords if kw in p.lower())
    
    # 保持原有逻辑
    return "P" if flexible_count > planning_count else "J"

def analyze_mbti():
    """主函数:分析 MBTI"""
    print("🔍 正在提取用户提示词...")
    
    # 提取所有工具的提示词
    claude_prompts = extract_claude_code_prompts()
    codex_prompts = extract_codex_prompts()
    gemini_prompts = extract_gemini_prompts()
    opencode_prompts = extract_opencode_prompts()
    openclaw_prompts = extract_openclaw_prompts()
    
    # 统计
    print(f"\n📊 数据统计:")
    print(f"  Claude Code: {len(claude_prompts)} 条")
    print(f"  Codex: {len(codex_prompts)} 条")
    print(f"  Gemini: {len(gemini_prompts)} 条")
    print(f"  OpenCode: {len(opencode_prompts)} 条")
    print(f"  OpenClaw: {len(openclaw_prompts)} 条")
    
    all_prompts = claude_prompts + codex_prompts + gemini_prompts + opencode_prompts + openclaw_prompts
    total = len(all_prompts)
    
    print(f"  总计: {total} 条\n")
    
    if total < 10:
        print("⚠️  数据量太少,无法进行准确分析")
        return
    
    # 分析四个维度
    print("🧠 正在分析 MBTI 维度...\n")
    
    e_or_i = analyze_communication_style(all_prompts)
    s_or_n = analyze_information_processing(all_prompts)
    t_or_f = analyze_decision_making(all_prompts)
    j_or_p = analyze_lifestyle(all_prompts)
    
    mbti_type = f"{e_or_i}{s_or_n}{t_or_f}{j_or_p}"
    
    # 输出结果
    print("=" * 50)
    print(f"🎯 你的 MBTI 类型:{mbti_type}")
    print("=" * 50)
    
    mbti_names = {
        "INTJ": "建筑师", "INTP": "逻辑学家", "ENTJ": "指挥官", "ENTP": "辩论家",
        "INFJ": "提倡者", "INFP": "调停者", "ENFJ": "主人公", "ENFP": "竞选者",
        "ISTJ": "物流师", "ISFJ": "守卫者", "ESTJ": "总经理", "ESFJ": "执政官",
        "ISTP": "鉴赏家", "ISFP": "探险家", "ESTP": "企业家", "ESFP": "表演者"
    }
    
    print(f"\n类型名称:{mbti_names.get(mbti_type, '未知')}\n")
    
    print("📋 维度分析:")
    print(f"  {e_or_i} - {'内向' if e_or_i == 'I' else '外向'}:简洁高效沟通" if e_or_i == 'I' else f"  {e_or_i} - 外向:详细表达")
    print(f"  {s_or_n} - {'直觉' if s_or_n == 'N' else '感觉'}:{'抽象思维,系统化方案' if s_or_n == 'N' else '关注具体细节'}")
    print(f"  {t_or_f} - {'思考' if t_or_f == 'T' else '情感'}:{'纯理性,关注效率' if t_or_f == 'T' else '考虑情感因素'}")
    print(f"  {j_or_p} - {'判断' if j_or_p == 'J' else '知觉'}:{'计划性强' if j_or_p == 'J' else '灵活探索,快速迭代'}")
    
    print("\n⚠️  重要提醒:")
    print("  1. 基于工作场景的行为推测,可能不反映真实性格")
    print("  2. MBTI 本身科学性存疑,仅供参考")
    print("  3. 这是基于行为模式的推测,非专业心理测评")

if __name__ == "__main__":
    analyze_mbti()

Example output

🔍 正在提取用户提示词...

📊 数据统计:
  Claude Code: 100 条
  Codex: 100 条
  Gemini: 62 条
  OpenCode: 2 条
  OpenClaw: 100 条
  总计: 364 条

🧠 正在分析 MBTI 维度...

==================================================
🎯 你的 MBTI 类型:INTP
==================================================

类型名称:逻辑学家

📋 维度分析:
  I - 内向:简洁高效沟通
  N - 直觉:抽象思维,系统化方案
  T - 思考:纯理性,关注效率
  P - 知觉:灵活探索,快速迭代

⚠️  重要提醒:
  1. 基于工作场景的行为推测,可能不反映真实性格
  2. MBTI 本身科学性存疑,仅供参考
  3. 这是基于行为模式的推测,非专业心理测评

License

MIT