Plugin Plan: agentskill-kaizen
Status: Phase 3 — Detailed Design (in progress)
Date: 2026-02-18
Phase 1: Discovery
Purpose: Analyze Claude Code agent session transcripts to identify inefficiencies, anti-patterns, repeated mistakes, missing tooling opportunities, and user frustration signals — enabling continuous improvement (kaizen) of agents, skills, and workflows.
Problem: Agents make the same mistakes across sessions, repeat multi-step workflows that could be scripts, and frustrate users by ignoring instructions. No systematic way to detect these patterns. Data exists in ~1,700+ local JSONL transcripts. No existing tool does cross-session analysis.
Target users: Plugin developers and power users maintaining agent/skill definitions.
Plugin type: Analysis toolkit
Analysis Dimensions (10)
- Tool misuse / inefficiency (Bash ls instead of Glob, etc.)
- Repeated errors across sessions
- User frustration signals (corrections, interrupts, "no don't do that")
- Missing tooling opportunities (repeated manual workflows → scripts/skills)
- Subagent delegation patterns (410 Task calls, 30+ agent types)
- Shortest path to outcome — where are steps being wasted?
- Red herrings — distractions chased across sessions that never lead to the solution
- System process interruptions — hooks, permission prompts, compaction interrupting correct paths
- Missing hooks — behavioral corrections done manually that should be automated
- MCP-based DuckDB querying — MotherDuck MCP for direct SQL access to transcripts
Research Documents
.claude/kaizen-data-analysis.md — JSONL schema, signal catalog, pipeline architecture (764 lines)
.claude/kaizen-external-research.md — existing tools, frameworks, academic papers, confirmed gaps
.claude/kaizen-references.md — hooks API, headless mode, MotherDuck MCP, expanded dimensions
Key Research Findings
- ~500MB corpus, ~57k JSONL records, 13 record types, 687 subagent transcripts
- 593 Bash file-op violations already quantified (215× ls, 182× grep, 105× head/tail/cat)
- 106 user interrupts, ~43 real correction utterances
- PM4Py (process mining) + SPMF (sequential pattern mining) are the proven toolchain
- COMPASS paper (2025) validated process mining on LLM agent traces
- No existing tool does cross-session analysis — confirmed gap
Phase 2: Component Plan
| Component Type |
Count |
Purpose |
| Skills |
2 |
transcript-analysis (methodology, signal catalog), kaizen-improvement (turning findings into outputs) |
| Commands |
4 |
/kaizen:analyze, /kaizen:explore, /kaizen:report, /kaizen:generate-hooks |
| Agents |
2 |
transcript-analyst, improvement-generator |
| Hooks |
0 |
Deferred — start with batch analysis, add real-time capture later |
| MCP |
2 |
MotherDuck DuckDB (SQL querying), custom FastMCP (process mining, pattern mining, frustration detection) |
| Scripts |
3-4 |
Supporting the custom MCP server |
Architecture Flow
/kaizen:analyze (autonomous pipeline)
→ transcript-analyst agent spawns
→ queries JSONL via DuckDB MCP (execute_query)
→ calls custom MCP tools for deeper analysis (process mining, pattern mining)
→ writes findings to .planning/kaizen/
/kaizen:explore (interactive mode)
→ transcript-analyst agent in interactive mode
→ user steers investigation
→ same tools available
/kaizen:report
→ reads existing analysis in .planning/kaizen/
→ generates summary report
/kaizen:generate-hooks
→ reads analysis findings
→ improvement-generator agent produces hook proposals
→ default: draft proposals with rationale
→ --install flag: writes directly to settings
Phase 3: Detailed Design Decisions
Resolved via User Input
- Analysis scope: User chooses at runtime via
--project flag, defaults to current project
- Output format: Markdown files in
.planning/kaizen/
- Hook generation: Draft proposals by default,
--install flag writes to settings
- Custom MCP language: Python (FastMCP) — natural fit for PM4Py, SPMF, pandas
- Agent mode:
/kaizen:analyze runs autonomous pipeline, /kaizen:explore enables interactive mode
- SessionEnd hook: Deferred — start with batch analysis, add real-time metrics later
- Query approach: Dynamic query generation — agent writes SQL on the fly
- Patch format: Instruction sets for other agents — follows delegation pattern (outcome-focused prompts for contextual-ai-documentation-optimizer, skill-creator, etc.)
Component Specifications
Skill: transcript-analysis
- Triggers: "analyze transcripts", "session analysis", "find anti-patterns", "kaizen"
- Content: JSONL schema reference, signal catalog with field paths, extraction methodology
- References: SQL query patterns, PM4Py usage, frustration signal taxonomy
- No utility scripts — analysis runs through MCP tools
Skill: kaizen-improvement
- Triggers: "generate hooks from findings", "improve agent", "fix anti-pattern"
- Content: How to translate findings into actionable outputs (hooks, agent patches, skill improvements)
- References: Hook API patterns, agent frontmatter format, delegation prompt templates
Command: /kaizen:analyze
- Arguments:
--project <name> (scope), --dimensions <list> (which analysis dimensions)
- Tools: DuckDB MCP, custom kaizen MCP, Read, Write, Glob
- Output: Writes analysis report to
.planning/kaizen/analysis-{date}.md
Command: /kaizen:explore
- Arguments:
--project <name> (scope)
- Tools: Same as analyze
- Mode: Interactive — presents initial findings, user steers deeper
Command: /kaizen:report
- Arguments:
--latest (most recent analysis), --all (aggregate)
- Tools: Read, Write
- Output: Summary report in
.planning/kaizen/report-{date}.md
Command: /kaizen:generate-hooks
- Arguments:
--install (write to settings), --from <analysis-file> (source findings)
- Tools: Read, Write, Edit
- Output: Hook proposals in
.planning/kaizen/hooks/ or directly to settings with --install
Agent: transcript-analyst
- Model: sonnet
- Tools: DuckDB MCP (execute_query), custom kaizen MCP, Read, Glob, Grep, Bash
- Skills: transcript-analysis
- Trigger: Spawned by /kaizen:analyze and /kaizen:explore commands
- Output: Structured analysis findings written to .planning/kaizen/
Agent: improvement-generator
- Model: sonnet
- Tools: Read, Write, Glob, Grep
- Skills: kaizen-improvement
- Trigger: Spawned by /kaizen:generate-hooks or after analysis completes
- Output: Outcome-focused instruction sets delegatable to other agents (optimizer, skill-creator)
MCP: MotherDuck DuckDB
- Config:
uvx mcp-server-motherduck --db-path :memory: --read-write
- Purpose: Direct SQL querying of JSONL transcript files
- Tools exposed: execute_query, list_tables, list_columns
MCP: Custom Kaizen Analysis Server (FastMCP)
- Language: Python with FastMCP
- Tools to expose:
discover_process_model — PM4Py Heuristic Miner on tool-call sequences
check_conformance — PM4Py conformance checking against reference model
find_frequent_patterns — SPMF PrefixSpan on tool-call sequences
detect_frustration_signals — NLP extraction from user turns
cluster_sessions — PM4Py trace clustering by behavioral similarity
extract_tool_sequences — JSONL → ordered tool-call arrays per session
- Dependencies: pm4py, spmf-py, pandas, fastmcp
Phase 4-8: Not yet started
- Phase 4: Plugin structure creation
- Phase 5: Component implementation
- Phase 6: Validation & quality check
- Phase 7: Testing & verification
- Phase 8: Documentation & next steps
1---2name: 2613-kaizen-plugin-plan-f282a64b3description: Plugin Plan: agentskill-kaizen4---5# Plugin Plan: agentskill-kaizen67**Status:** Phase 3 — Detailed Design (in progress)8**Date:** 2026-02-18910## Phase 1: Discovery1112**Purpose:** Analyze Claude Code agent session transcripts to identify inefficiencies, anti-patterns, repeated mistakes, missing tooling opportunities, and user frustration signals — enabling continuous improvement (kaizen) of agents, skills, and workflows.1314**Problem:** Agents make the same mistakes across sessions, repeat multi-step workflows that could be scripts, and frustrate users by ignoring instructions. No systematic way to detect these patterns. Data exists in ~1,700+ local JSONL transcripts. No existing tool does cross-session analysis.1516**Target users:** Plugin developers and power users maintaining agent/skill definitions.1718**Plugin type:** Analysis toolkit1920### Analysis Dimensions (10)21221. Tool misuse / inefficiency (Bash ls instead of Glob, etc.)232. Repeated errors across sessions243. User frustration signals (corrections, interrupts, "no don't do that")254. Missing tooling opportunities (repeated manual workflows → scripts/skills)265. Subagent delegation patterns (410 Task calls, 30+ agent types)276. Shortest path to outcome — where are steps being wasted?287. Red herrings — distractions chased across sessions that never lead to the solution298. System process interruptions — hooks, permission prompts, compaction interrupting correct paths309. Missing hooks — behavioral corrections done manually that should be automated3110. MCP-based DuckDB querying — MotherDuck MCP for direct SQL access to transcripts3233### Research Documents3435- `.claude/kaizen-data-analysis.md` — JSONL schema, signal catalog, pipeline architecture (764 lines)36- `.claude/kaizen-external-research.md` — existing tools, frameworks, academic papers, confirmed gaps37- `.claude/kaizen-references.md` — hooks API, headless mode, MotherDuck MCP, expanded dimensions3839### Key Research Findings4041- ~500MB corpus, ~57k JSONL records, 13 record types, 687 subagent transcripts42- 593 Bash file-op violations already quantified (215× ls, 182× grep, 105× head/tail/cat)43- 106 user interrupts, ~43 real correction utterances44- PM4Py (process mining) + SPMF (sequential pattern mining) are the proven toolchain45- COMPASS paper (2025) validated process mining on LLM agent traces46- No existing tool does cross-session analysis — confirmed gap4748---4950## Phase 2: Component Plan5152| Component Type | Count | Purpose |53|----------------|-------|---------|54| Skills | 2 | `transcript-analysis` (methodology, signal catalog), `kaizen-improvement` (turning findings into outputs) |55| Commands | 4 | `/kaizen:analyze`, `/kaizen:explore`, `/kaizen:report`, `/kaizen:generate-hooks` |56| Agents | 2 | `transcript-analyst`, `improvement-generator` |57| Hooks | 0 | Deferred — start with batch analysis, add real-time capture later |58| MCP | 2 | MotherDuck DuckDB (SQL querying), custom FastMCP (process mining, pattern mining, frustration detection) |59| Scripts | 3-4 | Supporting the custom MCP server |6061### Architecture Flow6263```text64/kaizen:analyze (autonomous pipeline)65 → transcript-analyst agent spawns66 → queries JSONL via DuckDB MCP (execute_query)67 → calls custom MCP tools for deeper analysis (process mining, pattern mining)68 → writes findings to .planning/kaizen/6970/kaizen:explore (interactive mode)71 → transcript-analyst agent in interactive mode72 → user steers investigation73 → same tools available7475/kaizen:report76 → reads existing analysis in .planning/kaizen/77 → generates summary report7879/kaizen:generate-hooks80 → reads analysis findings81 → improvement-generator agent produces hook proposals82 → default: draft proposals with rationale83 → --install flag: writes directly to settings84```8586---8788## Phase 3: Detailed Design Decisions8990### Resolved via User Input91921. **Analysis scope**: User chooses at runtime via `--project` flag, defaults to current project932. **Output format**: Markdown files in `.planning/kaizen/`943. **Hook generation**: Draft proposals by default, `--install` flag writes to settings954. **Custom MCP language**: Python (FastMCP) — natural fit for PM4Py, SPMF, pandas965. **Agent mode**: `/kaizen:analyze` runs autonomous pipeline, `/kaizen:explore` enables interactive mode976. **SessionEnd hook**: Deferred — start with batch analysis, add real-time metrics later987. **Query approach**: Dynamic query generation — agent writes SQL on the fly998. **Patch format**: Instruction sets for other agents — follows delegation pattern (outcome-focused prompts for contextual-ai-documentation-optimizer, skill-creator, etc.)100101### Component Specifications102103#### Skill: transcript-analysis104105- **Triggers**: "analyze transcripts", "session analysis", "find anti-patterns", "kaizen"106- **Content**: JSONL schema reference, signal catalog with field paths, extraction methodology107- **References**: SQL query patterns, PM4Py usage, frustration signal taxonomy108- **No utility scripts** — analysis runs through MCP tools109110#### Skill: kaizen-improvement111112- **Triggers**: "generate hooks from findings", "improve agent", "fix anti-pattern"113- **Content**: How to translate findings into actionable outputs (hooks, agent patches, skill improvements)114- **References**: Hook API patterns, agent frontmatter format, delegation prompt templates115116#### Command: /kaizen:analyze117118- **Arguments**: `--project <name>` (scope), `--dimensions <list>` (which analysis dimensions)119- **Tools**: DuckDB MCP, custom kaizen MCP, Read, Write, Glob120- **Output**: Writes analysis report to `.planning/kaizen/analysis-{date}.md`121122#### Command: /kaizen:explore123124- **Arguments**: `--project <name>` (scope)125- **Tools**: Same as analyze126- **Mode**: Interactive — presents initial findings, user steers deeper127128#### Command: /kaizen:report129130- **Arguments**: `--latest` (most recent analysis), `--all` (aggregate)131- **Tools**: Read, Write132- **Output**: Summary report in `.planning/kaizen/report-{date}.md`133134#### Command: /kaizen:generate-hooks135136- **Arguments**: `--install` (write to settings), `--from <analysis-file>` (source findings)137- **Tools**: Read, Write, Edit138- **Output**: Hook proposals in `.planning/kaizen/hooks/` or directly to settings with --install139140#### Agent: transcript-analyst141142- **Model**: sonnet143- **Tools**: DuckDB MCP (execute_query), custom kaizen MCP, Read, Glob, Grep, Bash144- **Skills**: transcript-analysis145- **Trigger**: Spawned by /kaizen:analyze and /kaizen:explore commands146- **Output**: Structured analysis findings written to .planning/kaizen/147148#### Agent: improvement-generator149150- **Model**: sonnet151- **Tools**: Read, Write, Glob, Grep152- **Skills**: kaizen-improvement153- **Trigger**: Spawned by /kaizen:generate-hooks or after analysis completes154- **Output**: Outcome-focused instruction sets delegatable to other agents (optimizer, skill-creator)155156#### MCP: MotherDuck DuckDB157158- **Config**: `uvx mcp-server-motherduck --db-path :memory: --read-write`159- **Purpose**: Direct SQL querying of JSONL transcript files160- **Tools exposed**: execute_query, list_tables, list_columns161162#### MCP: Custom Kaizen Analysis Server (FastMCP)163164- **Language**: Python with FastMCP165- **Tools to expose**:166 - `discover_process_model` — PM4Py Heuristic Miner on tool-call sequences167 - `check_conformance` — PM4Py conformance checking against reference model168 - `find_frequent_patterns` — SPMF PrefixSpan on tool-call sequences169 - `detect_frustration_signals` — NLP extraction from user turns170 - `cluster_sessions` — PM4Py trace clustering by behavioral similarity171 - `extract_tool_sequences` — JSONL → ordered tool-call arrays per session172- **Dependencies**: pm4py, spmf-py, pandas, fastmcp173174---175176## Phase 4-8: Not yet started177178- Phase 4: Plugin structure creation179- Phase 5: Component implementation180- Phase 6: Validation & quality check181- Phase 7: Testing & verification182- Phase 8: Documentation & next steps