insights
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInsights Skill
Insights Skill
When to Use This Skill
何时使用此Skill
IMPORTANT: You MUST activate this skill when you detect ANY of the following signals from the user. Do NOT ask for confirmation — just start executing the orchestration steps below.
重要提示:您必须激活此Skill,当您检测到用户发出以下任一信号时。无需请求确认——直接开始执行下方的编排步骤。
Trigger Phrases (any language)
触发短语(任意语言)
Use this skill when the user:
- Asks to analyze sessions: "analyze my sessions", "세션 분석해줘", "look at my sessions"
- Asks for a report: "generate a report", "리포트 만들어줘", "give me a report"
- Asks about usage patterns: "how have I been using you?", "사용 패턴 보여줘", "what are my patterns?"
- Asks about statistics: "show my stats", "통계 보여줘", "how many sessions?"
- Mentions workflow insights: "insights on my workflow", "워크플로우 분석", "what's working well?"
- Asks about productivity: "am I productive?", "내 생산성은?", "how efficient am I?"
- Uses keywords: "insights", "인사이트", "analytics", "분석", "report", "리포트", "stats", "통계", "sessions", "세션"
- Asks vaguely about history: "what have we been doing?", "그동안 뭐했지?", "show me my history"
当用户有以下需求时使用此Skill:
- 要求分析会话:"analyze my sessions"、"세션 분석해줘"、"look at my sessions"
- 要求生成报告:"generate a report"、"리포트 만들어줘"、"give me a report"
- 询问使用模式:"how have I been using you?"、"사용 패턴 보여줘"、"what are my patterns?"
- 询问统计数据:"show my stats"、"통계 보여줘"、"how many sessions?"
- 提及工作流洞察:"insights on my workflow"、"워크플로우 분석"、"what's working well?"
- 询问生产力:"am I productive?"、"내 생산성은?"、"how efficient am I?"
- 使用关键词:"insights"、"인사이트"、"analytics"、"분석"、"report"、"리포트"、"stats"、"통계"、"sessions"、"세션"
- 模糊询问历史记录:"what have we been doing?"、"그동안 뭐했지?"、"show me my history"
What NOT to Trigger On
请勿触发的场景
Do NOT use this skill when the user:
- Asks about a specific coding task (not session analysis)
- Wants to read a single session's content (use session tools directly)
- Asks about this skill's code itself (just read the files)
当用户有以下需求时,请勿使用此Skill:
- 询问特定编码任务(非会话分析)
- 想要查看单个会话的内容(直接使用会话工具)
- 询问此Skill的代码本身(直接读取文件即可)
Overview
概述
The insights skill generates a comprehensive HTML report analyzing your AI coding assistant usage patterns. It automatically detects which CLI you're using (Claude Code, OpenCode, or Codex), collects session data, performs 8 categories of analysis, and produces a styled HTML report with actionable insights.
What it produces:
- HTML report with 8 analysis sections
- Quantitative statistics (sessions, messages, duration, tools used)
- Qualitative insights (workflow patterns, friction points, suggestions)
- CLI-specific recommendations
- Self-contained file:// URL (no external dependencies)
Insights Skill会生成一份全面的HTML报告,分析您的AI编码助手使用模式。它会自动检测您使用的CLI(Claude Code、OpenCode或Codex),收集会话数据,执行8类分析,并生成带有可操作洞察的样式化HTML报告。
生成内容包括:
- 包含8个分析板块的HTML报告
- 量化统计数据(会话数、消息数、时长、使用的工具)
- 定性洞察(工作流模式、痛点、建议)
- 特定CLI的建议
- 独立的file:// URL(无外部依赖)
Prerequisites
前置条件
Required:
- bash 4+ (check: )
bash --version - jq (JSON processor)
Supported CLIs:
- Claude Code 2.1+
- OpenCode 1.1+
- Codex
Verify dependencies:
bash
./scripts/check-deps.shIf dependencies are missing, the script provides install instructions.
必需项:
- bash 4+(检查:)
bash --version - jq(JSON处理器)
支持的CLI:
- Claude Code 2.1+
- OpenCode 1.1+
- Codex
验证依赖项:
bash
./scripts/check-deps.sh如果缺少依赖项,脚本会提供安装说明。
Orchestration Steps
编排步骤
Follow these steps in order. Each step depends on the previous one.
请按顺序执行以下步骤,每一步都依赖于上一步的结果。
Step 1: Check Dependencies
步骤1:检查依赖项
Run:
scripts/check-deps.shPurpose: Verify jq and bash 4+ are installed.
Action:
- If exit code 0: Continue to Step 2
- If exit code 1: Show user the install instructions from stderr, then abort
Example:
bash
cd skills/insights
./scripts/check-deps.sh执行命令:
scripts/check-deps.sh目的: 验证jq和bash 4+是否已安装。
操作:
- 如果退出码为0:继续执行步骤2
- 如果退出码为1:向用户显示stderr中的安装说明,然后终止流程
示例:
bash
cd skills/insights
./scripts/check-deps.shStep 2: Detect CLI Type
步骤2:检测CLI类型
Run:
scripts/detect-cli.shPurpose: Auto-detect which AI coding CLI the user is running.
Output: Single line: , , , or
claude-codeopencodecodexunknownAction:
- Capture the output as
$CLI_TYPE - If output is : Ask user which CLI they're using, or abort
unknown - Otherwise: Continue to Step 3
Example:
bash
CLI_TYPE=$(./scripts/detect-cli.sh)
echo "Detected CLI: $CLI_TYPE"Override: User can specify CLI manually:
bash
CLI_TYPE=$(./scripts/detect-cli.sh --cli claude-code)执行命令:
scripts/detect-cli.sh目的: 自动检测用户正在运行的AI编码CLI。
输出: 单行内容:、、或
claude-codeopencodecodexunknown操作:
- 将输出捕获为
$CLI_TYPE - 如果输出为:询问用户使用的CLI类型,或终止流程
unknown - 否则:继续执行步骤3
示例:
bash
CLI_TYPE=$(./scripts/detect-cli.sh)
echo "Detected CLI: $CLI_TYPE"手动覆盖: 用户可以手动指定CLI:
bash
CLI_TYPE=$(./scripts/detect-cli.sh --cli claude-code)Step 3: Collect Session Metadata
步骤3:收集会话元数据
Run:
scripts/collect-sessions.sh --cli $CLI_TYPEPurpose: Collect session metadata from the CLI's storage directory.
Output: JSON array of session objects (stdout)
Action:
- Capture output as
$SESSIONS_JSON - Verify it's valid JSON:
echo "$SESSIONS_JSON" | jq . > /dev/null - If empty array : Inform user no sessions found, abort
[] - Otherwise: Continue to Step 4
Example:
bash
SESSIONS_JSON=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 50)
echo "$SESSIONS_JSON" | jq 'length' # Show session countOptions:
- : Limit to N most recent sessions (default: 50)
--limit N - : Override default session directory
--session-dir <path>
执行命令:
scripts/collect-sessions.sh --cli $CLI_TYPE目的: 从CLI的存储目录收集会话元数据。
输出: 会话对象的JSON数组(标准输出)
操作:
- 将输出捕获为
$SESSIONS_JSON - 验证其为有效JSON:
echo "$SESSIONS_JSON" | jq . > /dev/null - 如果为空数组:告知用户未找到会话,终止流程
[] - 否则:继续执行步骤4
示例:
bash
SESSIONS_JSON=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 50)
echo "$SESSIONS_JSON" | jq 'length' # 显示会话数量可选参数:
- :限制为最近的N个会话(默认值:50)
--limit N - :覆盖默认会话目录
--session-dir <path>
Step 4: Aggregate Statistics
步骤4:聚合统计数据
Run: (reads from stdin)
scripts/aggregate-stats.shPurpose: Compute quantitative statistics from session metadata.
Input: Session metadata JSON array (from Step 3)
Output: Aggregated stats JSON object (stdout)
Action:
- Pipe to aggregate-stats.sh
$SESSIONS_JSON - Capture output as
$STATS_JSON - Verify valid JSON
- Continue to Step 5
Example:
bash
STATS_JSON=$(echo "$SESSIONS_JSON" | ./scripts/aggregate-stats.sh)
echo "$STATS_JSON" | jq '.total_sessions, .total_messages'Stats included:
- total_sessions, total_messages, total_duration_hours
- date_range (start, end)
- tool_counts, languages, projects
- git_commits, git_pushes
- days_active, messages_per_day
- message_hours (24-element array)
执行命令: (从标准输入读取数据)
scripts/aggregate-stats.sh目的: 根据会话元数据计算量化统计数据。
输入: 会话元数据JSON数组(来自步骤3)
输出: 聚合后的统计数据JSON对象(标准输出)
操作:
- 将通过管道传递给aggregate-stats.sh
$SESSIONS_JSON - 将输出捕获为
$STATS_JSON - 验证为有效JSON
- 继续执行步骤5
示例:
bash
STATS_JSON=$(echo "$SESSIONS_JSON" | ./scripts/aggregate-stats.sh)
echo "$STATS_JSON" | jq '.total_sessions, .total_messages'包含的统计数据:
- total_sessions、total_messages、total_duration_hours
- date_range(开始时间、结束时间)
- tool_counts、languages、projects
- git_commits、git_pushes
- days_active、messages_per_day
- message_hours(24元素数组)
Step 5: Extract Session Facets (Optional but Recommended)
步骤5:提取会话维度(可选但推荐)
Purpose: Extract qualitative facets from individual sessions for richer analysis.
Limit: Up to 20 sessions (to manage token cost)
Prompt: Use the facet extraction prompt from
references/facet-extraction.mdAction:
- Select up to 20 sessions from (prioritize recent, diverse sessions)
$SESSIONS_JSON - For each session:
- Read the full session data (messages, tool calls, outcomes)
- Execute the facet extraction prompt with session context
- Parse the JSON response
- Aggregate facets into
$FACETS_JSON
Facet fields:
- goal_categories (debugging, feature_implementation, refactoring, etc.)
- user_satisfaction_counts (happy, satisfied, frustrated, etc.)
- friction_counts (misunderstood_request, buggy_code, etc.)
- outcome_level (success, partial_success, blocked, abandoned)
Cache: Store extracted facets in to avoid re-extraction.
~/.agent-insights/cache/facets/<session-id>.jsonExample:
bash
undefined目的: 从单个会话中提取定性维度,以获得更丰富的分析结果。
限制: 最多20个会话(以控制令牌成本)
提示词: 使用中的维度提取提示词
references/facet-extraction.md操作:
- 从中选择最多20个会话(优先选择近期、多样化的会话)
$SESSIONS_JSON - 对于每个会话:
- 读取完整会话数据(消息、工具调用、结果)
- 结合会话上下文执行维度提取提示词
- 解析JSON响应
- 将维度聚合为
$FACETS_JSON
维度字段:
- goal_categories(调试、功能实现、重构等)
- user_satisfaction_counts(满意、较满意、沮丧等)
- friction_counts(请求被误解、代码有bug等)
- outcome_level(成功、部分成功、受阻、已放弃)
缓存: 将提取的维度存储在中,避免重复提取。
~/.agent-insights/cache/facets/<session-id>.json示例:
bash
undefinedPseudo-code (agent executes this logic)
伪代码(由Agent执行此逻辑)
for session in (first 20 sessions):
cache_file="~/.agent-insights/cache/facets/${session.session_id}.json"
if cache_file exists:
facet = read cache_file
else:
facet = execute_facet_extraction_prompt(session)
write facet to cache_file
facets.append(facet)
undefinedfor session in (前20个会话):
cache_file="~/.agent-insights/cache/facets/${session.session_id}.json"
if cache_file exists:
facet = 读取缓存文件
else:
facet = 执行维度提取提示词(session)
将facet写入缓存文件
facets.append(facet)
undefinedStep 6: Run 8 Analysis Prompts
步骤6:运行8个分析提示词
Purpose: Generate qualitative insights across 8 categories.
Prompts: All 8 prompts are in
references/analysis-prompts.mdContext: Provide each prompt with:
- (aggregated statistics)
$STATS_JSON - (extracted facets, if available)
$FACETS_JSON - (for CLI-specific suggestions)
$CLI_TYPE
Prompts to execute:
- project_areas - What the user works on (4-5 areas)
- interaction_style - How the user interacts (narrative + key_pattern)
- what_works - Impressive workflows (3 items)
- friction_analysis - Pain points (3 categories × 2 examples)
- suggestions - CLI-agnostic + CLI-specific features (use )
references/suggestions-by-cli.md - on_the_horizon - Future opportunities (3 items with copyable_prompt)
- fun_ending - Memorable moment (headline + detail)
- at_a_glance - Executive summary (4 fields: whats_working, whats_hindering, quick_wins, ambitious_workflows)
Execution:
- Run all 8 prompts in parallel if possible (faster)
- Each prompt returns a JSON object
- Combine all 8 responses into
$INSIGHTS_JSON
Example:
json
{
"project_areas": {...},
"interaction_style": {...},
"what_works": {...},
"friction_analysis": {...},
"suggestions": {...},
"on_the_horizon": {...},
"fun_ending": {...},
"at_a_glance": {...}
}Important: Each prompt includes "RESPOND WITH ONLY A VALID JSON OBJECT" instruction. Parse responses carefully.
目的: 生成8个类别的定性洞察。
提示词: 所有8个提示词都在中
references/analysis-prompts.md上下文: 为每个提示词提供以下内容:
- (聚合统计数据)
$STATS_JSON - (提取的维度,如果有的话)
$FACETS_JSON - (用于特定CLI的建议)
$CLI_TYPE
需要执行的提示词:
- project_areas - 用户的工作内容(4-5个领域)
- interaction_style - 用户的交互方式(叙述+关键模式)
- what_works - 有效的工作流(3项)
- friction_analysis - 痛点(3个类别×2个示例)
- suggestions - 独立于CLI和特定于CLI的功能(使用)
references/suggestions-by-cli.md - on_the_horizon - 未来机会(3项,包含可复制的提示词)
- fun_ending - 难忘时刻(标题+细节)
- at_a_glance - 执行摘要(4个字段:whats_working、whats_hindering、quick_wins、ambitious_workflows)
执行方式:
- 如果可能,并行运行所有8个提示词(速度更快)
- 每个提示词返回一个JSON对象
- 将所有8个响应合并为
$INSIGHTS_JSON
示例:
json
{
"project_areas": {...},
"interaction_style": {...},
"what_works": {...},
"friction_analysis": {...},
"suggestions": {...},
"on_the_horizon": {...},
"fun_ending": {...},
"at_a_glance": {...}
}重要提示: 每个提示词都包含“仅返回有效的JSON对象”的指令,请仔细解析响应。
Step 7: Generate HTML Report
步骤7:生成HTML报告
Run:
scripts/generate-report.sh --stats <stats-file> --cli $CLI_TYPE --output <path>Purpose: Inject JSON data into HTML template and create final report.
Input:
- (from Step 6, via stdin)
$INSIGHTS_JSON - (from Step 4, via --stats file)
$STATS_JSON - (via --cli flag)
$CLI_TYPE
Output: Path to generated HTML file (stdout)
Action:
- Write to a temp file
$STATS_JSON - Pipe to generate-report.sh
$INSIGHTS_JSON - Capture output path as
$REPORT_PATH - Continue to Step 8
Example:
bash
STATS_FILE=$(mktemp)
echo "$STATS_JSON" > "$STATS_FILE"
REPORT_PATH=$(echo "$INSIGHTS_JSON" | ./scripts/generate-report.sh \
--stats "$STATS_FILE" \
--cli "$CLI_TYPE" \
--language "${LANGUAGE:-en}" \
--output ~/.agent-insights/reports/report-$(date +%Y-%m-%d).html)
echo "Report generated: $REPORT_PATH"Default output:
./insights-report.htmlRecommended output:
~/.agent-insights/reports/report-YYYY-MM-DD.html执行命令:
scripts/generate-report.sh --stats <stats-file> --cli $CLI_TYPE --output <path>目的: 将JSON数据注入HTML模板并生成最终报告。
输入:
- (来自步骤6,通过标准输入)
$INSIGHTS_JSON - (来自步骤4,通过--stats文件)
$STATS_JSON - (通过--cli参数)
$CLI_TYPE
输出: 生成的HTML文件路径(标准输出)
操作:
- 将写入临时文件
$STATS_JSON - 将通过管道传递给generate-report.sh
$INSIGHTS_JSON - 将输出路径捕获为
$REPORT_PATH - 继续执行步骤8
示例:
bash
STATS_FILE=$(mktemp)
echo "$STATS_JSON" > "$STATS_FILE"
REPORT_PATH=$(echo "$INSIGHTS_JSON" | ./scripts/generate-report.sh \
--stats "$STATS_FILE" \
--cli "$CLI_TYPE" \
--language "${LANGUAGE:-en}" \
--output ~/.agent-insights/reports/report-$(date +%Y-%m-%d).html)
echo "Report generated: $REPORT_PATH"默认输出路径:
./insights-report.html推荐输出路径:
~/.agent-insights/reports/report-YYYY-MM-DD.htmlStep 8: Present to User
步骤8:向用户展示结果
Purpose: Show summary and provide file:// URL.
Action:
- Read key stats from :
$STATS_JSON- total_sessions
- total_messages
- total_duration_hours
- date_range
- Read at-a-glance summary from
$INSIGHTS_JSON - Present to user:
Example output:
✅ Insights Report Generated
📊 Summary:
- Sessions analyzed: 42
- Total messages: 1,247
- Time period: 2026-01-15 to 2026-02-06
- Total duration: 18.5 hours
🎯 At a Glance:
- What's working: You're effectively using Claude for rapid prototyping...
- What's hindering: Frequent context resets when switching between projects...
- Quick wins: Try using /compact to reduce token usage...
- Ambitious workflows: Explore multi-file refactoring with LSP tools...
📄 Full report: file://$REPORT_PATH
Open the report in your browser to see detailed insights across 8 categories.目的: 显示摘要并提供file:// URL。
操作:
- 从中读取关键统计数据:
$STATS_JSON- total_sessions
- total_messages
- total_duration_hours
- date_range
- 从中读取执行摘要
$INSIGHTS_JSON - 向用户展示:
示例输出:
✅ 洞察报告已生成
📊 摘要:
- 分析的会话数:42
- 总消息数:1,247
- 时间范围:2026-01-15 至 2026-02-06
- 总时长:18.5小时
🎯 执行摘要:
- 有效做法:您能有效利用Claude进行快速原型开发...
- 待改进点:切换项目时频繁重置上下文...
- 快速优化建议:尝试使用/compact减少令牌消耗...
- 进阶工作流:探索使用LSP工具进行多文件重构...
📄 完整报告:file://$REPORT_PATH
在浏览器中打开报告,查看8个类别的详细洞察。Output Format
输出格式
The generated HTML report includes:
Header:
- Title: "Insights Report"
- CLI type badge
- Generation date
- Stats bar (sessions · messages · hours · commits)
8 Sections:
- At a Glance - 4-item executive summary
- What You Work On - Project areas with session counts
- Your Style - Interaction style narrative
- What's Working Well - Impressive workflows
- Friction Points - Categorized pain points
- Suggestions - Features and usage patterns to try
- On the Horizon - Future opportunities with copyable prompts
- Fun Moment - Memorable headline
Features:
- Self-contained (no external resources)
- Dark/light theme support (auto-detects via )
prefers-color-scheme - Responsive design (mobile-friendly)
- Print-friendly styles
生成的HTML报告包含以下内容:
页眉:
- 标题:"Insights Report"
- CLI类型标识
- 生成日期
- 统计栏(会话数 · 消息数 · 时长 · 提交数)
8个板块:
- 执行摘要 - 4项内容的高管摘要
- 您的工作领域 - 带有会话数的项目领域
- 您的使用风格 - 交互风格叙述
- 有效做法 - 高效工作流
- 痛点 - 分类后的问题点
- 建议 - 可尝试的功能和使用模式
- 未来展望 - 包含可复制提示词的未来机会
- 难忘时刻 - 引人注目的标题
特性:
- 独立运行(无外部资源)
- 支持深色/浅色主题(通过自动检测)
prefers-color-scheme - 响应式设计(适配移动端)
- 适合打印的样式
Reference Files
参考文件
All supporting documentation is in :
references/- analysis-prompts.md - Complete text of all 8 analysis prompts with expected JSON schemas
- facet-extraction.md - Session facet extraction prompt and enums
- schema.md - JSON schemas for session metadata, stats, facets, and insights
- cli-formats.md - Detailed documentation of session storage formats for each CLI
- suggestions-by-cli.md - CLI-specific feature suggestions (MCP servers, custom skills, hooks, etc.)
所有支持文档都在目录中:
references/- analysis-prompts.md - 所有8个分析提示词的完整文本及预期JSON schema
- facet-extraction.md - 会话维度提取提示词及枚举值
- schema.md - 会话元数据、统计数据、维度和洞察的JSON schema
- cli-formats.md - 各CLI的会话存储格式详细文档
- suggestions-by-cli.md - 特定于CLI的功能建议(MCP服务器、自定义Skill、钩子等)
Troubleshooting
故障排除
"jq: command not found"
"jq: command not found"
Solution: Install jq:
- macOS:
brew install jq - Linux: or
apt install jqyum install jq
解决方案: 安装jq:
- macOS:
brew install jq - Linux:或
apt install jqyum install jq
"Bash version too old"
"Bash version too old"
Solution: Upgrade to bash 4+:
- macOS: (then restart terminal)
brew install bash - Linux: Usually already 4+
解决方案: 升级到bash 4+:
- macOS:(然后重启终端)
brew install bash - Linux:通常已预装4+版本
"No sessions found"
"No sessions found"
Possible causes:
- CLI not detected correctly
- Run:
./scripts/detect-cli.sh - Override:
./scripts/detect-cli.sh --cli claude-code
- Run:
- Session directory empty
- Check: (Claude Code)
ls ~/.claude/projects/ - Check: (OpenCode)
ls ~/.local/share/opencode/storage/session/ - Check: (Codex)
ls ~/.codex/sessions/
- Check:
- Sessions filtered out (<2 messages, <1 minute)
- Review filtering logic in
scripts/collect-sessions.sh
- Review filtering logic in
可能原因:
- CLI检测错误
- 执行:
./scripts/detect-cli.sh - 手动覆盖:
./scripts/detect-cli.sh --cli claude-code
- 执行:
- 会话目录为空
- 检查:(Claude Code)
ls ~/.claude/projects/ - 检查:(OpenCode)
ls ~/.local/share/opencode/storage/session/ - 检查:(Codex)
ls ~/.codex/sessions/
- 检查:
- 会话被过滤掉(消息数<2,时长<1分钟)
- 查看中的过滤逻辑
scripts/collect-sessions.sh
- 查看
"Report generation fails"
"Report generation fails"
Possible causes:
- Invalid JSON from analysis prompts
- Verify:
echo "$INSIGHTS_JSON" | jq . - Check: Each prompt response is valid JSON
- Verify:
- Missing template file
- Verify:
ls scripts/templates/report.html
- Verify:
- Python not available
- generate-report.sh uses Python for JSON injection
- Verify:
python3 --version
可能原因:
- 分析提示词返回无效JSON
- 验证:
echo "$INSIGHTS_JSON" | jq . - 检查:每个提示词的响应是否为有效JSON
- 验证:
- 缺少模板文件
- 验证:
ls scripts/templates/report.html
- 验证:
- Python不可用
- generate-report.sh使用Python注入JSON
- 验证:
python3 --version
"Analysis prompts return non-JSON"
"Analysis prompts return non-JSON"
Solution: Ensure each prompt includes "RESPOND WITH ONLY A VALID JSON OBJECT" instruction. If the model returns markdown code blocks, strip them:
bash
response=$(echo "$response" | sed 's/^```json//; s/^```//; s/```$//')解决方案: 确保每个提示词都包含“仅返回有效的JSON对象”的指令。如果模型返回markdown代码块,请移除:
bash
response=$(echo "$response" | sed 's/^```json//; s/^```//; s/```$//')Examples
示例
Basic Usage
基本用法
bash
cd skills/insightsbash
cd skills/insights1. Check dependencies
1. 检查依赖项
./scripts/check-deps.sh || exit 1
./scripts/check-deps.sh || exit 1
2. Detect CLI
2. 检测CLI
CLI_TYPE=$(./scripts/detect-cli.sh)
CLI_TYPE=$(./scripts/detect-cli.sh)
3. Collect sessions
3. 收集会话
SESSIONS=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 50)
SESSIONS=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 50)
4. Aggregate stats
4. 聚合统计数据
STATS=$(echo "$SESSIONS" | ./scripts/aggregate-stats.sh)
STATS=$(echo "$SESSIONS" | ./scripts/aggregate-stats.sh)
5. Extract facets (agent logic, not shown)
5. 提取维度(Agent逻辑,未展示)
6. Run analysis prompts (agent logic, not shown)
6. 运行分析提示词(Agent逻辑,未展示)
7. Generate report
7. 生成报告
STATS_FILE=$(mktemp)
echo "$STATS" > "$STATS_FILE"
REPORT=$(echo "$INSIGHTS" | ./scripts/generate-report.sh --stats "$STATS_FILE" --cli "$CLI_TYPE")
STATS_FILE=$(mktemp)
echo "$STATS" > "$STATS_FILE"
REPORT=$(echo "$INSIGHTS" | ./scripts/generate-report.sh --stats "$STATS_FILE" --cli "$CLI_TYPE")
8. Present
8. 展示结果
echo "Report: file://$REPORT"
undefinedecho "Report: file://$REPORT"
undefinedOverride CLI Detection
手动覆盖CLI检测
bash
undefinedbash
undefinedForce Claude Code
强制使用Claude Code
CLI_TYPE=$(./scripts/detect-cli.sh --cli claude-code)
undefinedCLI_TYPE=$(./scripts/detect-cli.sh --cli claude-code)
undefinedLimit Sessions
限制会话数量
bash
undefinedbash
undefinedAnalyze only last 10 sessions
仅分析最近10个会话
SESSIONS=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 10)
undefinedSESSIONS=$(./scripts/collect-sessions.sh --cli "$CLI_TYPE" --limit 10)
undefinedCustom Output Path
自定义输出路径
bash
undefinedbash
undefinedSave to specific location
保存到指定位置
mkdir -p ~/reports
REPORT=$(echo "$INSIGHTS" | ./scripts/generate-report.sh
--stats stats.json
--cli claude-code
--output ~/reports/insights-$(date +%Y%m%d).html)
--stats stats.json
--cli claude-code
--output ~/reports/insights-$(date +%Y%m%d).html)
undefinedmkdir -p ~/reports
REPORT=$(echo "$INSIGHTS" | ./scripts/generate-report.sh
--stats stats.json
--cli claude-code
--output ~/reports/insights-$(date +%Y%m%d).html)
--stats stats.json
--cli claude-code
--output ~/reports/insights-$(date +%Y%m%d).html)
undefinedNotes
注意事项
- Token cost: Facet extraction (Step 5) and analysis prompts (Step 6) consume tokens. Limit facet extraction to 20 sessions.
- Caching: Cache extracted facets in to avoid re-extraction on subsequent runs.
~/.agent-insights/cache/facets/ - Parallelization: Run the 8 analysis prompts in parallel for faster execution.
- Privacy: All data stays local. No external API calls. Report is self-contained HTML.
- Extensibility: To add a new CLI, create an adapter in following the existing pattern.
collect-sessions.sh
- 令牌成本: 维度提取(步骤5)和分析提示词(步骤6)会消耗令牌。请将维度提取限制为20个会话。
- 缓存: 将提取的维度缓存到中,避免后续运行时重复提取。
~/.agent-insights/cache/facets/ - 并行化: 并行运行8个分析提示词以加快执行速度。
- 隐私: 所有数据都保存在本地,无外部API调用。报告是独立的HTML文件。
- 可扩展性: 要添加新的CLI,请按照现有模式在中创建适配器。
collect-sessions.sh
Language Support
语言支持
The insights skill supports multi-language report generation.
Insights Skill支持多语言报告生成。
Supported Languages
支持的语言
- Built-in: English (), Korean (
en)ko - Dynamic: Any language via AI translation
- 内置: 英语()、韩语(
en)ko - 动态: 通过AI翻译支持任意语言
How to Specify Language
指定语言的方式
- CLI flag: (e.g.,
--language <code>)--language ko - Environment variable: or
LANG(e.g.,LC_ALL)LANG=ko_KR.UTF-8 - Default: English ()
en
- CLI参数: (例如:
--language <code>)--language ko - 环境变量: 或
LANG(例如:LC_ALL)LANG=ko_KR.UTF-8 - 默认值: 英语()
en
What Gets Translated
翻译内容
- HTML report UI strings: Section titles, labels (26 strings)
- Analysis content: Insights JSON values (via prompt instruction)
- HTML报告UI字符串: 板块标题、标签(26个字符串)
- 分析内容: 洞察JSON值(通过提示词指令)
What Stays in English
保留英文的内容
- JSON keys: Always English for consistency
- Shell script output: Help messages, errors
- JSON键: 始终使用英文以保持一致性
- Shell脚本输出: 帮助信息、错误信息
Version
版本
This skill targets:
- Claude Code 2.1+
- OpenCode 1.1+
- Codex (latest)
For older versions, session formats may differ. Check for compatibility notes.
references/cli-formats.md此Skill针对以下版本:
- Claude Code 2.1+
- OpenCode 1.1+
- Codex(最新版)
对于旧版本,会话格式可能不同。请查看中的兼容性说明。
references/cli-formats.md