introspect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIntrospect
自省分析
Extract actionable intelligence from Claude Code session logs. Analyze tool usage, reasoning patterns, errors, and conversation flow to improve workflows and debug issues.
从Claude Code会话日志中提取可落地的洞察信息。分析工具使用情况、推理模式、错误及对话流程,以优化工作流并排查问题。
Log File Structure
日志文件结构
~/.claude/
├── history.jsonl # Global: all user inputs across projects
├── projects/
│ └── {project-path}/ # e.g., X--Dev-claude-mods/
│ ├── sessions-index.json # Session metadata index
│ ├── {session-uuid}.jsonl # Full session transcript
│ └── agent-{short-id}.jsonl # Subagent transcripts~/.claude/
├── history.jsonl # 全局:跨项目的所有用户输入
├── projects/
│ └── {project-path}/ # 示例:X--Dev-claude-mods/
│ ├── sessions-index.json # 会话元数据索引
│ ├── {session-uuid}.jsonl # 完整会话记录
│ └── agent-{short-id}.jsonl # 子Agent会话记录Project Path Encoding
项目路径编码
Project paths use double-dash encoding: →
X:\Dev\claude-modsX--Dev-claude-modsbash
undefined项目路径使用双短横线编码: →
X:\Dev\claude-modsX--Dev-claude-modsbash
undefinedFind project directory for current path
查找当前路径对应的项目目录
project_dir=$(pwd | sed 's/[:\/]/-/g' | sed 's/--/-/g')
ls ~/.claude/projects/ | grep -i "${project_dir##-}"
undefinedproject_dir=$(pwd | sed 's/[:\/]/-/g' | sed 's/--/-/g')
ls ~/.claude/projects/ | grep -i "${project_dir##-}"
undefinedEntry Types in Session Files
会话文件中的条目类型
| Type | Contains | Key Fields |
|---|---|---|
| User messages | |
| Claude responses | |
| Reasoning blocks | |
| Tool invocations | |
| Tool outputs | |
| Conversation summaries | |
| File state checkpoints | File contents at point in time |
| System context | Initial context, rules |
| 类型 | 包含内容 | 关键字段 |
|---|---|---|
| 用户消息 | |
| Claude回复 | |
| 推理思考块 | |
| 工具调用记录 | |
| 工具输出结果 | |
| 对话摘要 | |
| 文件状态检查点 | 对应时间点的文件内容 |
| 系统上下文 | 初始上下文、规则 |
Core Analysis Patterns
核心分析模式
List Sessions for Current Project
列出当前项目的会话
bash
undefinedbash
undefinedGet sessions index
获取会话索引
cat ~/.claude/projects/X--Dev-claude-mods/sessions-index.json | jq '.'
cat ~/.claude/projects/X--Dev-claude-mods/sessions-index.json | jq '.'
List session files with sizes and dates
列出会话文件及其大小和日期
ls -lah ~/.claude/projects/X--Dev-claude-mods/*.jsonl | grep -v agent
undefinedls -lah ~/.claude/projects/X--Dev-claude-mods/*.jsonl | grep -v agent
undefinedSession Overview
会话概览
bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"Entry type distribution
条目类型分布
jq -r '.type' ~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c
jq -r '.type' ~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c
Session duration (first to last timestamp)
会话时长(从第一条到最后一条的时间戳)
jq -s '[.[].timestamp // .[].message.timestamp | select(.)] | [min, max] | map(. / 1000 | strftime("%Y-%m-%d %H:%M"))'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
jq -s '[.[].timestamp // .[].message.timestamp | select(.)] | [min, max] | map(. / 1000 | strftime("%Y-%m-%d %H:%M"))'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
Conversation summaries (quick overview)
对话摘要(快速概览)
jq -r 'select(.type == "summary") | .summary' ~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedjq -r 'select(.type == "summary") | .summary' ~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedTool Usage Statistics
工具使用统计
bash
PROJECT="X--Dev-claude-mods"bash
PROJECT="X--Dev-claude-mods"Tool frequency across all sessions
所有会话的工具使用频率
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' |
sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' |
sort | uniq -c | sort -rn
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' |
sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' |
sort | uniq -c | sort -rn
Tool frequency for specific session
特定会话的工具使用频率
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
Tools with their inputs (sampled)
带输入参数的工具示例
jq -c 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | {tool: .name, input: .input}'
~/.claude/projects/$PROJECT/$SESSION.jsonl | head -20
~/.claude/projects/$PROJECT/$SESSION.jsonl | head -20
undefinedjq -c 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | {tool: .name, input: .input}'
~/.claude/projects/$PROJECT/$SESSION.jsonl | head -20
~/.claude/projects/$PROJECT/$SESSION.jsonl | head -20
undefinedExtract Thinking Blocks
提取思考块
bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"All thinking blocks (reasoning trace)
所有思考块(推理轨迹)
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "thinking") | .thinking'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "thinking") | .thinking'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
Thinking blocks with context (which turn)
带上下文的思考块(对应对话轮次)
jq -r 'select(.type == "assistant") |
.message.content as $content |
($content | map(select(.type == "thinking")) | .[0].thinking) as $thinking |
($content | map(select(.type == "text")) | .[0].text | .[0:100]) as $response |
select($thinking) | "---\nThinking: ($thinking[0:500])...\nResponse: ($response)..."'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedjq -r 'select(.type == "assistant") |
.message.content as $content |
($content | map(select(.type == "thinking")) | .[0].thinking) as $thinking |
($content | map(select(.type == "text")) | .[0].text | .[0:100]) as $response |
select($thinking) | "---\n思考内容: ($thinking[0:500])...\n回复内容: ($response)..."'
~/.claude/projects/$PROJECT/$SESSION.jsonl
~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedError Analysis
错误分析
bash
PROJECT="X--Dev-claude-mods"bash
PROJECT="X--Dev-claude-mods"Find tool errors across sessions
跨会话查找工具错误
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | test("error|Error|ERROR|failed|Failed|FAILED"; "i")) | {tool_id: .tool_use_id, error: .content[0:200]}' 2>/dev/null | head -50
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | test("error|Error|ERROR|failed|Failed|FAILED"; "i")) | {tool_id: .tool_use_id, error: .content[0:200]}' 2>/dev/null | head -50
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | test("error|Error|ERROR|failed|Failed|FAILED"; "i")) | {tool_id: .tool_use_id, error: .content[0:200]}' 2>/dev/null | head -50
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | select(.content | test("error|Error|ERROR|failed|Failed|FAILED"; "i")) | {tool_id: .tool_use_id, error: .content[0:200]}' 2>/dev/null | head -50
Count errors by pattern
按错误模式统计数量
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null |
grep -i "error|failed|exception" |
sed 's/[0-9]+//g' | sort | uniq -c | sort -rn | head -20
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null |
grep -i "error|failed|exception" |
sed 's/[0-9]+//g' | sort | uniq -c | sort -rn | head -20
undefinedcat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null |
grep -i "error|failed|exception" |
sed 's/[0-9]+//g' | sort | uniq -c | sort -rn | head -20
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null |
grep -i "error|failed|exception" |
sed 's/[0-9]+//g' | sort | uniq -c | sort -rn | head -20
undefinedSearch Across Sessions
跨会话搜索
bash
PROJECT="X--Dev-claude-mods"bash
PROJECT="X--Dev-claude-mods"Search user messages
搜索用户消息
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
Search assistant responses
搜索Claude回复
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
cat ~/.claude/projects/$PROJECT/*.jsonl |
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text' |
grep -i "pattern"
Find sessions mentioning a file
查找提及特定文件的会话
for f in ~/.claude/projects/$PROJECT/*.jsonl; do
if grep -q "specific-file.ts" "$f"; then
echo "Found in: $(basename $f)"
fi
done
undefinedfor f in ~/.claude/projects/$PROJECT/*.jsonl; do
if grep -q "specific-file.ts" "$f"; then
echo "在以下文件中找到: $(basename $f)"
fi
done
undefinedConversation Flow Reconstruction
对话流重构
bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"Reconstruct conversation (user/assistant turns)
重构对话(用户/Claude轮次)
jq -r '
if .type == "user" then
.message.content[]? | select(.type == "text") | "USER: (.text[0:200])"
elif .type == "assistant" then
.message.content[]? | select(.type == "text") | "CLAUDE: (.text[0:200])"
else empty end
' ~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedjq -r '
if .type == "user" then
.message.content[]? | select(.type == "text") | "用户: (.text[0:200])"
elif .type == "assistant" then
.message.content[]? | select(.type == "text") | "CLAUDE: (.text[0:200])"
else empty end
' ~/.claude/projects/$PROJECT/$SESSION.jsonl
undefinedSubagent Analysis
子Agent分析
bash
PROJECT="X--Dev-claude-mods"bash
PROJECT="X--Dev-claude-mods"List subagent sessions
列出子Agent会话
ls ~/.claude/projects/$PROJECT/agent-*.jsonl 2>/dev/null
ls ~/.claude/projects/$PROJECT/agent-*.jsonl 2>/dev/null
Subagent tool usage
子Agent工具使用情况
for f in ~/.claude/projects/$PROJECT/agent-*.jsonl; do
echo "=== $(basename $f) ==="
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' "$f" |
sort | uniq -c | sort -rn | head -5 done
sort | uniq -c | sort -rn | head -5 done
undefinedfor f in ~/.claude/projects/$PROJECT/agent-*.jsonl; do
echo "=== $(basename $f) ==="
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' "$f" |
sort | uniq -c | sort -rn | head -5 done
sort | uniq -c | sort -rn | head -5 done
undefinedAdvanced Analysis
高级分析
Token/Cost Estimation
Token/成本估算
bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"Rough character count (tokens ≈ chars/4)
粗略字符数统计(Token数≈字符数/4)
jq -r '[
(select(.type == "user") | .message.content[]? | select(.type == "text") | .text | length),
(select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text | length)
] | add' ~/.claude/projects/$PROJECT/$SESSION.jsonl |
awk '{sum+=$1} END {print "Total chars:", sum, "Est tokens:", int(sum/4)}'
awk '{sum+=$1} END {print "Total chars:", sum, "Est tokens:", int(sum/4)}'
undefinedjq -r '[
(select(.type == "user") | .message.content[]? | select(.type == "text") | .text | length),
(select(.type == "assistant") | .message.content[]? | select(.type == "text") | .text | length)
] | add' ~/.claude/projects/$PROJECT/$SESSION.jsonl |
awk '{sum+=$1} END {print "总字符数:", sum, "估算Token数:", int(sum/4)}'
awk '{sum+=$1} END {print "总字符数:", sum, "估算Token数:", int(sum/4)}'
undefinedFile Modification Tracking
文件修改跟踪
bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"bash
SESSION="417ce03a-6fc7-4906-b767-6428338f34c3"
PROJECT="X--Dev-claude-mods"Files edited (Edit tool usage)
编辑过的文件(Edit工具使用记录)
jq -r 'select(.type == "assistant") | .message.content[]? |
select(.type == "tool_use" and .name == "Edit") | .input.file_path'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? |
select(.type == "tool_use" and .name == "Edit") | .input.file_path'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn
Files written
写入的文件
jq -r 'select(.type == "assistant") | .message.content[]? |
select(.type == "tool_use" and .name == "Write") | .input.file_path'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq
undefinedjq -r 'select(.type == "assistant") | .message.content[]? |
select(.type == "tool_use" and .name == "Write") | .input.file_path'
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq
undefinedSession Comparison
会话对比
bash
PROJECT="X--Dev-claude-mods"
SESSION1="session-id-1"
SESSION2="session-id-2"bash
PROJECT="X--Dev-claude-mods"
SESSION1="session-id-1"
SESSION2="session-id-2"Compare tool usage between sessions
对比两个会话的工具使用情况
echo "=== Session 1 ===" &&
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION1.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION1.jsonl | sort | uniq -c | sort -rn
echo "=== Session 2 ===" &&
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION2.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION2.jsonl | sort | uniq -c | sort -rn
undefinedecho "=== 会话1 ===" &&
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION1.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION1.jsonl | sort | uniq -c | sort -rn
echo "=== 会话2 ===" &&
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION2.jsonl | sort | uniq -c | sort -rn
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
~/.claude/projects/$PROJECT/$SESSION2.jsonl | sort | uniq -c | sort -rn
undefinedQuick Reference Commands
快速参考命令
| Task | Command Pattern |
|---|---|
| List sessions | |
| Entry types | |
| Tool stats | |
| Extract thinking | |
| Find errors | |
| Session summaries | |
| User messages | |
| 任务 | 命令模板 |
|---|---|
| 列出会话 | |
| 条目类型统计 | |
| 工具使用统计 | |
| 提取思考内容 | |
| 查找错误 | |
| 会话摘要 | |
| 用户消息 | |
Usage Examples
使用示例
"What tools did I use most in yesterday's session?"
"我昨天的会话中使用最多的工具是什么?"
bash
undefinedbash
undefinedFind yesterday's sessions by modification time
按修改时间查找昨天的会话
find ~/.claude/projects/X--Dev-claude-mods -name ".jsonl" -mtime -1 ! -name "agent-" |
xargs -I{} jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' {} |
sort | uniq -c | sort -rn
xargs -I{} jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' {} |
sort | uniq -c | sort -rn
undefinedfind ~/.claude/projects/X--Dev-claude-mods -name ".jsonl" -mtime -1 ! -name "agent-" |
xargs -I{} jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' {} |
sort | uniq -c | sort -rn
xargs -I{} jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' {} |
sort | uniq -c | sort -rn
undefined"Show me my reasoning when debugging the auth issue"
"展示我调试认证问题时的思考过程"
bash
undefinedbash
undefinedSearch for sessions mentioning auth, then extract thinking
搜索提及认证的会话,然后提取思考内容
for f in ~/.claude/projects/$PROJECT/*.jsonl; do
if grep -qi "auth" "$f"; then
echo "=== $(basename $f) ==="
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "thinking") | .thinking' "$f" |
grep -i -A5 -B5 "auth" fi done
grep -i -A5 -B5 "auth" fi done
undefinedfor f in ~/.claude/projects/$PROJECT/*.jsonl; do
if grep -qi "auth" "$f"; then
echo "=== $(basename $f) ==="
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "thinking") | .thinking' "$f" |
grep -i -A5 -B5 "auth" fi done
grep -i -A5 -B5 "auth" fi done
undefined"What errors occurred most frequently this week?"
"这周最频繁出现的错误是什么?"
bash
find ~/.claude/projects/ -name "*.jsonl" -mtime -7 | \
xargs cat 2>/dev/null | \
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null | \
grep -i "error\|failed" | \
sed 's/[0-9]\+//g' | sed 's/\/[^ ]*//g' | \
sort | uniq -c | sort -rn | head -10bash
find ~/.claude/projects/ -name "*.jsonl" -mtime -7 | \
xargs cat 2>/dev/null | \
jq -r 'select(.type == "user") | .message.content[]? | select(.type == "tool_result") | .content' 2>/dev/null | \
grep -i "error\|failed" | \
sed 's/[0-9]\+//g' | sed 's/\/[^ ]*//g' | \
sort | uniq -c | sort -rn | head -10Privacy Considerations
隐私注意事项
Session logs contain:
- Full conversation history including any sensitive data discussed
- File contents that were read or written
- Thinking/reasoning (internal deliberation)
- Tool inputs/outputs
Before sharing session exports:
- Review for credentials, API keys, personal data
- Consider redacting file paths if they reveal project structure
- Thinking blocks may contain candid assessments
会话日志包含:
- 完整对话历史,包括讨论过的敏感数据
- 读取或写入的文件内容
- 思考/推理过程(内部 deliberation)
- 工具输入/输出
在分享会话导出内容前:
- 检查是否包含凭证、API密钥、个人数据
- 考虑编辑文件路径以避免泄露项目结构
- 思考块可能包含未公开的评估内容
Export Formats
导出格式
Markdown Report
Markdown报告
bash
SESSION="session-id"
PROJECT="X--Dev-claude-mods"
echo "# Session Report: $SESSION"
echo ""
echo "## Summary"
jq -r 'select(.type == "summary") | "- \(.summary)"' ~/.claude/projects/$PROJECT/$SESSION.jsonl
echo ""
echo "## Tool Usage"
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' \
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn | \
awk '{print "| " $2 " | " $1 " |"}'bash
SESSION="session-id"
PROJECT="X--Dev-claude-mods"
echo "# 会话报告: $SESSION"
echo ""
echo "## 摘要"
jq -r 'select(.type == "summary") | "- \(.summary)"' ~/.claude/projects/$PROJECT/$SESSION.jsonl
echo ""
echo "## 工具使用情况"
jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name' \
~/.claude/projects/$PROJECT/$SESSION.jsonl | sort | uniq -c | sort -rn | \
awk '{print "| " $2 " | " $1 " |"}'JSON Export (for further processing)
JSON导出(用于进一步处理)
bash
jq -s '{
session_id: "'$SESSION'",
entries: length,
tools: [.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name] | group_by(.) | map({tool: .[0], count: length}),
summaries: [.[] | select(.type == "summary") | .summary]
}' ~/.claude/projects/$PROJECT/$SESSION.jsonlbash
jq -s '{
session_id: "'$SESSION'",
entries: length,
tools: [.[] | select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name] | group_by(.) | map({tool: .[0], count: length}),
summaries: [.[] | select(.type == "summary") | .summary]
}' ~/.claude/projects/$PROJECT/$SESSION.jsonl