Community生產力與協作github.com

Jamie-BitFlight/transcript-analysis

此技能應於分析 Claude Code 工作階段記錄、檢視代理效能、發現反模式或工具誤用、挖掘工作流程模式、執行改善分析、除錯代理行為或執行工作階段鑑識時使用。

transcript-analysis 是什麼?

此技能旨在分析 Claude Code 的 JSONL 工作階段記錄,用於偵測反模式、效率低下以及工作流程改善機會。它支援多種分析維度,包括工具誤用偵測、重複錯誤分類、缺失工具機會識別、子代理委派模式分析、最短路徑分析、誤導偵測、系統流程中斷追蹤以及缺失鉤子識別。技能使用 DuckDB 進行任意 SQL 查詢,並透過 kaizen-analysis MCP 伺服器進行流程探勘,如工具序列提取和聚類。它支援所有 Claude Code 平台,並將分析結果輸出為結構化的 Markdown 文件,位於 .planning/kaizen/ 目錄下,包含嚴重性等級與改善建議類型。

相容平台✓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 的作用: 透過 get_transcript_jsonl_schema 或 MCP resources/read kaizen://session-log/schema 載入來自 kaizen-analysis 的完整欄位/路徑參考,然後使用 kaizen-duckdb execute_query 對這些檔案執行任何 DuckDB SQL(請參閱 DuckDB 查詢模式 以取得範例和任意查詢工作流程)。工作階段歷史記錄以 JSONL 格式保留在磁碟上。DuckDB MCP 的路徑規則請參閱跨平台備註(使用絕對路徑,SQL 中不要使用 ~)。

~/.claude/projects/{project-key}/
├── {uuid}.jsonl              # 主要工作階段記錄
├── agent-{id}.jsonl          # 孤立代理記錄
└── {uuid}/
    ├── subagents/
    │   └── agent-{id}.jsonl  # 子代理記錄
    └── 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 — 鉤子執行和子代理串流
  • file-history-snapshot — 檔案編輯追蹤
  • summary — 工作階段標題/摘要

有關每種記錄類型的完整 JSON 結構等詳細資訊,請參閱 JSONL 結構參考。

訊號目錄

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

1. 工具誤用偵測

從 assistant.message.content[] 中提取 name == "Bash" 的項目。解析 input.command 中應使用內建工具的檔案操作模式。關於 SQL 提取查詢,請參閱 DuckDB 查詢模式。

解析 tool_use 區塊中的 Bash 指令,比對:

  • 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 的工具結果中提取。分類錯誤類型:

  • "File has not been read yet" — 先編輯後讀取的反模式
  • "String to replace not found" — 過時的編輯目標
  • "User denied tool use" — 權限/信任問題
  • 提交前鉤子失敗 (exit code 1)
  • 缺少二進位檔 / 找不到指令

3. 缺失工具機會

透過工具序列三元組分析,識別跨工作階段重複的多步驟手動工作流程。高頻率的三元組,例如 Bash → Bash → Bash 或 Read → Read → Read,表示缺少腳本或技能。

4. 子代理委派模式

從 Task 的 tool_use 區塊中提取。追蹤 subagent_type、description、model。當有專門代理可用卻使用 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-DATE.md]

輸出格式

將分析發現寫入 .planning/kaizen/ 目錄下,格式為結構化的 Markdown,包含:

  • 每個發現的工作階段 ID 和日期
  • 嚴重性 (critical / warning / info)
  • 證據 — 確切的 JSON 欄位路徑和值
  • 頻率 — 表現出該模式的工作階段數量
  • 建議類型 — 鉤子、技能修補、代理提示修正、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.

相關技能