Community生产力与协作github.com

Jamie-BitFlight/transcript-analysis

该技能用于分析 Claude Code 会话转录,审查 Agent 性能,发现反模式或工具误用,挖掘工作流模式,执行改善分析,调试 Agent 行为,或进行会话取证。

transcript-analysis 是什么?

该技能专注于对 Claude Code 生成的 JSONL 格式会话转录文件进行深度分析,以识别反模式、低效操作和工作流改进机会。它支持在本地磁盘上的 `~/.claude/projects/` 目录下定位会话文件,并利用 DuckDB 的 SQL 能力直接查询这些 JSONL 文件(通过 `kaizen-analysis` 和 `kaizen-duckdb` MCP 服务器),从而提取工具误用模式(如用 Bash 执行 `grep` 或 `cat`)、重复错误、缺失的工具化机会、子代理委派模式、最短路径分析、红鲱鱼检测、系统进程中断以及缺失的钩子等。此外,该技能还提供了过程挖掘方法论(如工具序列提取、过程发现、一致性检查等),能够将分析结果以结构化 Markdown 形式输出到 `.planning/kaizen/` 目录中。其核心价值在于通过数据驱动的方式,系统性地提升 Claude Code Agent 的可靠性和效率,适用于 Cursor、Codex、Claude Code 等 AI 辅助开发平台。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Jamie-BitFlight/claude_skills/tree/main/plugins/agentskill-kaizen/skills/transcript-analysis

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

转录分析

分析 Claude Code JSONL 会话转录,以检测反模式、低效操作和工作流改进机会。

数据位置

转录文件位于 ~/.claude/projects/ 下以项目路径命名的目录中(斜杠替换为连字符)。

DuckDB 的作用: 通过 kaizen-analysis 的 get_transcript_jsonl_schema 或 MCP 的 resources/read kaizen://session-log/schema 加载完整的字段/路径参考,然后使用 kaizen-duckdb 的 execute_query 对文件运行 任意 DuckDB SQL(示例和任意查询工作流请参见 DuckDB 查询模式)。会话历史保留在磁盘上的 JSONL 文件中。DuckDB MCP 的路径规则(使用绝对路径,SQL 中不能使用 ~)。

~/.claude/projects/{project-key}/
├── {uuid}.jsonl              # 主会话转录
├── agent-{id}.jsonl          # 孤立 Agent 转录
└── {uuid}/
    ├── subagents/
    │   └── agent-{id}.jsonl  # 子 Agent 转录
    └── tool-results/
        └── {tool-use-id}.txt # 异步任务输出

JSONL 记录类型

每个 JSONL 行是一个 JSON 对象,由 type 字段区分。

主要分析记录类型:

  • assistant — 包含工具调用和文本的 LLM 响应轮次
  • user — 人类输入和工具结果
  • system — 元数据事件(stop_hook_summary、turn_duration、compact_boundary、api_error、local_command)
  • progress — 钩子执行和子 Agent 流式传输
  • file-history-snapshot — 文件编辑追踪
  • summary — 会话标题/摘要

有关包括每种记录类型的 JSON 结构在内的完整模式详细信息,请参见 JSONL 模式参考。

信号目录

以下每个分析维度都有其自己的提取方法。

1. 工具误用检测

从 assistant.message.content[] 中提取 name == "Bash" 的部分。解析 input.command 中应使用内置工具的文件操作模式。有关 SQL 提取查询,请参见 DuckDB 查询模式。

解析与以下内容匹配的 Bash 命令的 tool_use 块:

  • grep → 应使用 Grep 工具
  • find -name → 应使用 Glob 工具
  • cat、head、tail → 应使用 Read 工具
  • ls → 应使用 Glob 或带有描述的 Bash(ls)
  • sed、awk → 应使用 Edit 工具

排除管道中的合法使用(git ... | grep、uv run ... | head)。

2. 重复错误

从 is_error: true 的工具结果中提取。分类错误类型:

  • “文件尚未读取” — 先编辑后读取的反模式
  • “未找到要替换的字符串” — 过时的编辑目标
  • “用户拒绝工具使用” — 权限/信任问题
  • 预提交钩子失败(退出码 1)
  • 缺少二进制文件 / 命令未找到

3. 缺失工具化机会

通过跨会话的工具序列三元组分析识别重复的多步骤手动工作流。高频三元组如 Bash → Bash → Bash 或 Read → Read → Read 提示缺少脚本或技能。

4. 子代理委派模式

从 Task 工具的 tool_use 块中提取。跟踪 subagent_type、description、model。标记在存在专门 Agent 时仍使用 general-purpose 的情况。

5. 最短路径分析

比较同一目标成功与失败的尝试。测量从目标陈述(用户轮次)到成功结果(最终助手轮次)之间的工具调用次数。相似目标的跨会话高方差指示浪费的步骤。

6. 红鲱鱼检测

跟踪被放弃的调查分支。信号:一系列针对某个主题的 Read/Grep/Bash 调用,随后出现 compact_boundary 或方向改变而未解决。相同放弃路径的跨会话频率揭示系统性的红鲱鱼。

7. 系统进程中断

提取 system.compact_boundary、system.api_error 以及与钩子相关的 progress 事件。映射它们相对于活动工作的位置,以识别系统进程何时破坏了正确的执行路径。

8. 缺失的钩子

识别跨会话重复出现的手动修正。当同一修正出现 3 次或以上时,适合通过 PreToolUse 钩子(拒绝 + 重定向)或 SubagentStart 钩子(注入上下文)实现自动化预防。

9. DuckDB SQL 查询

使用 kaizen-analysis 的 get_transcript_jsonl_schema 或资源 kaizen://session-log/schema 获取完整路径参考,然后使用 kaizen-duckdb 的 execute_query 对 JSONL 运行 任意 SQL(使用 read_ndjson_auto 和 绝对 路径)。您不必局限于配方查询。

有关任意查询工作流和示例,请参见 DuckDB 查询模式。

过程挖掘方法

使用 kaizen-analysis MCP 服务器工具执行 SQL 无法表达的分析:

  • extract_tool_sequences — 将 JSONL 转换为每个会话的有序工具调用数组
  • discover_process_model — 基于工具调用序列的轻量级转换模型
  • check_conformance — 将会话与参考过程模型进行比较
  • find_frequent_patterns — PrefixSpan 序列模式挖掘
  • cluster_sessions — 按行为相似性进行轨迹聚类

分析工作流

flowchart TD
    Start([接收分析任务]) --> Scope{已定义范围?}
    Scope -->|--project 标志| Project[过滤到项目转录]
    Scope -->|无标志| Default[使用当前项目]
    Project --> Discover[SQL — 统计会话数、日期范围、记录类型]
    Default --> Discover
    Discover --> Dimensions{哪些维度?}
    Dimensions -->|全部| RunAll[运行所有维度]
    Dimensions -->|指定| RunSelected[运行选定维度]
    RunAll --> Aggregate[汇总发现]
    RunSelected --> Aggregate
    Aggregate --> Write[写入 .planning/kaizen/analysis-日期.md]

输出格式

将分析发现写入 .planning/kaizen/ 目录,格式为结构化 Markdown,包含:

  • 每个发现的会话 ID 和日期
  • 严重性(严重 / 警告 / 信息)
  • 证据 — 精确的 JSON 字段路径和值
  • 频率 — 出现该模式的会话数量
  • 建议类型 — 钩子、技能补丁、Agent 提示修复、CLAUDE.md 更新

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Jamie-BitFlight/agentskill-kaizen-meta-docs

Agentskill kaizen plugin documentation index. Load when needing to read about cross-platform notes, improvement plans, or DuckDB integration.

Jamie-BitFlight/bash-51-features

Bash 5.1 release features and improvements with practical examples. Use when working with Bash 5.1 features, epoch time variables, redirection enhancements, or when user asks about Bash 5.1 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-52-features

Bash 5.2 release features and improvements with practical examples. Use when working with Bash 5.2 features, variable handling enhancements, readline improvements, or when user asks about Bash 5.2 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-53-features

Bash 5.3 release features and improvements with practical examples. Use when working with Bash 5.3 features, new command substitution, GLOBSORT, loadable builtins, or when user asks about Bash 5.3 changes, new features, or version-specific capabilities.

Jamie-BitFlight/bash-development

This skill should be used when the user asks to "write a bash script", "create a shell script", "implement bash function", "parse arguments in bash", "handle errors in bash", or mentions bash development, shell scripting, script templates, or modern bash patterns.

Jamie-BitFlight/bash-lint

This skill should be used when the user asks to "lint bash script", "run shellcheck", "format shell script", "use shfmt", "fix shellcheck errors", or mentions shell script linting, formatting, code quality, or pre-commit hooks for bash.

Jamie-BitFlight/bash-logging

This skill should be used when the user asks to "add logging to bash script", "colorize output", "implement log levels", "CI/CD sections", "terminal colors in bash", or mentions logging functions, emoji output, collapsible CI sections, or shlocksmith.

Jamie-BitFlight/bash-portability

This skill should be used when the user asks about "POSIX compatibility", "portable shell scripts", "cross-shell compatibility", "bashisms", "shebang selection", or mentions writing scripts that work on different shells (bash, sh, dash, zsh) or different systems.

Jamie-BitFlight/bash-testing

This skill should be used when the user asks to "test bash script", "write shell tests", "use shunit2", "use shellspec", "create test suite for bash", or mentions unit testing, test frameworks, mocking, or test-driven development for shell scripts.

Jamie-BitFlight/brainstorming-skill

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or when users request help with ideation, marketing, and strategic planning. Explores user intent, requirements, and design before implementation using research-validated prompt patterns.

Jamie-BitFlight/clang-format

Configure clang-format code formatting. Use when: user mentions clang-format or .clang-format, analyzing code style/patterns, creating/modifying formatting config, troubleshooting formatting, brace styles/indentation/spacing/alignment/pointer alignment, or codifying conventions.

Jamie-BitFlight/commitlint

When setting up commit message validation for a project. When project has commitlint.config.js or .commitlintrc files. When configuring CI/CD to enforce commit format. When extracting commit rules for LLM prompt generation. When debugging commit message rejection errors.

Jamie-BitFlight/conventional-commits

When writing a git commit message. When task completes and changes need committing. When project uses semantic-release, commitizen, git-cliff. When choosing between feat/fix/chore/docs types. When indicating breaking changes. When generating changelogs from commit history.

Jamie-BitFlight/dasel-reference

Use when querying, modifying, or converting JSON, YAML, TOML, XML, CSV, HCL, or INI with dasel v3. Complete reference for selectors, functions, conditionals, variables, spread operator, type casting, and format-specific patterns.

Jamie-BitFlight/data-exploration

Use when exploring unknown structured data files with dasel v3 — discover schema, list keys, find nested values, sample arrays, identify data types across JSON, YAML, TOML, XML, CSV, HCL, INI formats

Jamie-BitFlight/data-transformation

Use when modifying, converting, or transforming structured data with dasel v3 — in-place mutations, format conversion, batch operations, array manipulation, object construction, and merge patterns across JSON, YAML, TOML, XML, CSV, HCL, INI

Jamie-BitFlight/delegate

Decompose substantive work into phases, dispatch each phase to a sub-agent, and adjudicate what comes back. Use whenever a request asks for implementation, investigation, a fix, a review, or any change to files — including small ones — and whenever you are about to read source or run a diagnostic yourself instead of handing it off. Also use when a report from a sub-agent needs judging, when a phase needs re-dispatching, or when a user names one instance of a pattern. Does not apply when your own prompt begins "Your ROLE_TYPE is sub-agent." — then follow references/sub-agent-contract.md instead.

Jamie-BitFlight/enterprise-hibernate-hbm

Dasel v3 query patterns for Hibernate .hbm.xml mapping files — entity-table binding, Java property-to-column extraction, one-to-many set/list/bag relationship tracing, many-to-one foreign key discovery, batch scanning across 60+ HBM files. Use when querying Hibernate ORM class mappings, extracting schema metadata from Java persistence layer, or auditing entity-column relationships in enterprise legacy codebases.

Jamie-BitFlight/enterprise-installanywhere

Dasel v3 query patterns for InstallAnywhere .iap_xml installer definitions — use when querying action sequences, discovering variables, resolving platform conditions, navigating panels, or comparing installer variants. Files are 2.5+ MB, 65,000+ lines — too large for context reads, requires structural dasel queries.

Jamie-BitFlight/enterprise-maven-pom

Dasel v3 selector patterns for Maven POM XML files — use when querying dependency versions, filtering by groupId or scope, extracting module hierarchy from parent POMs, or detecting version conflicts across enterprise multi-module Java projects. Load this skill when working with pom.xml files using dasel.

相关技能