session-analyzer
session-analyzer is a post-hoc validation tool that analyzes completed Claude Code sessions against their SKILL.md specifications to verify expected behavior, component invocations, artifact creation, and detect bugs. Use it when you need to review whether a skill executed correctly in a past session, check session logs for a specific session ID and skill path, or validate that SubAgents, Hooks, and Tools were invoked as documented.
git clone --depth 1 https://github.com/team-attention/plugins-for-claude-natives /tmp/session-analyzer && cp -r /tmp/session-analyzer/plugins/session-wrap/skills/session-analyzer ~/.claude/skills/session-analyzerSKILL.md
# Session Analyzer Skill
Post-hoc analysis tool for validating Claude Code session behavior against SKILL.md specifications.
## Purpose
Analyze completed sessions to verify:
1. **Expected vs Actual Behavior** - Did the skill follow SKILL.md workflow?
2. **Component Invocations** - Were SubAgents, Hooks, and Tools called correctly?
3. **Artifacts** - Were expected files created/deleted?
4. **Bug Detection** - Any unexpected errors or deviations?
---
## Input Requirements
| Parameter | Required | Description |
|-----------|----------|-------------|
| `sessionId` | YES | UUID of the session to analyze |
| `targetSkill` | YES | Path to SKILL.md to validate against |
| `additionalRequirements` | NO | Extra validation criteria |
---
## Phase 1: Locate Session Files
### Step 1.1: Find Session Files
Session files are located in `~/.claude/`:
```bash
# Main session log
~/.claude/projects/-{encoded-cwd}/{sessionId}.jsonl
# Debug log (detailed)
~/.claude/debug/{sessionId}.txt
# Agent transcripts (if subagents were used)
~/.claude/projects/-{encoded-cwd}/agent-{agentId}.jsonl
```
Use script to locate files:
```bash
${baseDir}/scripts/find-session-files.sh {sessionId}
```
### Step 1.2: Verify Files Exist
Check all required files exist before proceeding. If debug log is missing, analysis will be limited.
---
## Phase 2: Parse Target SKILL.md
### Step 2.1: Extract Expected Components
Read the target SKILL.md and identify:
**From YAML Frontmatter:**
- `hooks.PreToolUse` - Expected PreToolUse hooks and matchers
- `hooks.PostToolUse` - Expected PostToolUse hooks
- `hooks.Stop` - Expected Stop hooks
- `hooks.SubagentStop` - Expected SubagentStop hooks
- `allowed-tools` - Tools the skill is allowed to use
**From Markdown Body:**
- SubAgents mentioned (`Task(subagent_type="...")`)
- Skills called (`Skill("...")`)
- Artifacts created (`.dev-flow/drafts/`, `.dev-flow/plans/`, etc.)
- Workflow steps and conditions
### Step 2.2: Build Expected Behavior Checklist
Create checklist from SKILL.md analysis:
```markdown
## Expected Behavior
### SubAgents
- [ ] Explore agent called (parallel, run_in_background)
- [ ] gap-analyzer called before plan generation
- [ ] reviewer called after plan creation
### Hooks
- [ ] PreToolUse[Edit|Write] triggers plan-guard.sh
- [ ] Stop hook validates reviewer approval
### Artifacts
- [ ] Draft file created at .dev-flow/drafts/{name}.md
- [ ] Plan file created at .dev-flow/plans/{name}.md
- [ ] Draft file deleted after OKAY
### Workflow
- [ ] Interview Mode before Plan Generation
- [ ] User explicit request triggers plan generation
- [ ] Reviewer REJECT causes revision loop
```
---
## Phase 3: Analyze Debug Log
The debug log (`~/.claude/debug/{sessionId}.txt`) contains detailed execution traces.
### Step 3.1: Extract SubAgent Calls
Search patterns:
```
SubagentStart with query: {agent-name}
SubagentStop with query: {agent-id}
```
Use script:
```bash
${baseDir}/scripts/extract-subagent-calls.sh {debug-log-path}
```
### Step 3.2: Extract Hook Events
Search patterns:
```
Getting matching hook commands for {HookEvent} with query: {tool-name}
Matched {N} unique hooks for query "{query}"
Hooks: Processing prompt hook with prompt: {prompt}
Hooks: Prompt hook condition was met/not met
permissionDecision: allow/deny
```
Use script:
```bash
${baseDir}/scripts/extract-hook-events.sh {debug-log-path}
```
### Step 3.3: Extract Tool Calls
Search patterns:
```
executePreToolHooks called for tool: {tool-name}
File {path} written atomically
```
### Step 3.4: Extract Hook Results
For prompt-based hooks, find the model response:
```
Hooks: Model response: {
"ok": true/false,
"reason": "..."
}
```
---
## Phase 4: Verify Artifacts
### Step 4.1: Check File Creation
For each expected artifact:
1. Search debug log for `FileHistory: Tracked file modification for {path}`
2. Search for `File {path} written atomically`
3. Verify current filesystem state
### Step 4.2: Check File Deletion
For files that should be deleted:
1. Search for `rm` commands in Bash calls
2. Verify file no longer exists on filesystem
---
## Phase 5: Compare Expected vs Actual
### Step 5.1: Build Comparison Table
```markdown
| Component | Expected | Actual | Status |
|-----------|----------|--------|--------|
| Explore agent | 2 parallel calls | 2 calls at 09:39:26 | ✅ |
| gap-analyzer | Called before plan | Called at 09:43:08 | ✅ |
| reviewer | Called after plan | 2 calls (REJECT→OKAY) | ✅ |
| PreToolUse hook | Edit\|Write matcher | Triggered for Write | ✅ |
| Stop hook | Validates approval | Returned ok:true | ✅ |
| Draft file | Created then deleted | Created→Deleted | ✅ |
| Plan file | Created | Exists (10KB) | ✅ |
```
### Step 5.2: Identify Deviations
Flag any mismatches:
- Missing component calls
- Wrong order of operations
- Hook failures
- Missing artifacts
- Unexpected errors
---
## Phase 6: Generate Report
### Report Template
```markdown
# Session Analysis Report
## Session Info
- **Session ID**: {sessionId}
- **Target Skill**: {skillPath}
- **Analysis Date**: {date}
---
## 1. Expected Behavior (from SKILL.md)
[Summary of expected workflow]
---
## 2. Skill/SubAgent/Hook Verification
### SubAgents
| SubAgent | Expected | Actual | Time | Result |
|----------|----------|--------|------|--------|
| ... | ... | ... | ... | ✅/❌ |
### Hooks
| Hook | Matcher | Triggered | Result |
|------|---------|-----------|--------|
| ... | ... | ... | ✅/❌ |
---
## 3. Artifacts Verification
| Artifact | Path | Expected State | Actual State |
|----------|------|----------------|--------------|
| ... | ... | ... | ✅/❌ |
---
## 4. Issues/Bugs
| Severity | Description | Location |
|----------|-------------|----------|
| ... | ... | ... |
---
## 5. Overall Result
**Verdict**: ✅ PASS / ❌ FAIL
**Summary**: [1-2 sentence summary]
```
---
## Scripts Reference
| Script | Purpose |
|--------|---------|
| `find-session-files.sh` | Locate all files for a session ID |
| `extract-subCollect and synthesize opinions from multiple AI agents. Use when users say "summon the council", "ask other AIs", or want multiple AI perspectives on a question.
This skill should be used when the user is building, planning, or strategizing and the key question is whether to optimize content (what) or change form (how/medium). Trigger on "내용 vs 형식", "content vs form", "metamedium", "형식을 바꿔볼까", "새로운 포맷", "관점 전환", "perspective shift", "다른 방법 없을까", "같은 방식이 안 먹혀", "diminishing returns". Applies Alan Kay's metamedium concept to surface form-level alternatives. For requirement clarification use vague; for strategy blind spots use unknown.
This skill should be used when the user provides a strategy, plan, or decision document and wants to surface hidden assumptions and blind spots using the Known/Unknown 4-quadrant framework. Trigger on "known unknown", "4분면 분석", "blind spots", "뭘 놓치고 있지", "뭘 모르는지 모르겠어", "전략 점검", "전략 분석", "assumption check", "가정 점검", "quadrant analysis", "what am I missing". Strategy-level blind spot analysis with hypothesis-driven questioning. For requirement clarification use vague; for content-vs-form reframing use metamedium.
This skill should be used when the user's request or requirement is ambiguous and needs iterative questioning to become actionable. Trigger on "clarify requirements", "refine requirements", "요구사항 명확히", "요구사항 정리", "뭘 원하는 건지", "make this clearer", "spec this out", "scope this", "/clarify". Turns vague inputs into concrete specs. For strategy blind spots use unknown; for content-vs-form reframing use metamedium.
개발 커뮤니티에서 기술 주제에 대한 다양한 의견 수집. "개발자 반응", "커뮤니티 의견", "developer reactions" 요청에 사용. Reddit, HN, Dev.to, Lobsters 등 종합.
This skill should be used when the user asks to "기술 의사결정", "뭐 쓸지 고민", "A vs B", "비교 분석", "라이브러리 선택", "아키텍처 결정", "어떤 걸 써야 할지", "트레이드오프", "기술 선택", "구현 방식 고민", or needs deep analysis for technical decisions. Provides systematic multi-source research and synthesized recommendations.
This skill should be used when the user asks to "트윗 가져와", "트윗 번역", "X 게시글 읽어줘", "tweet fetch", "트윗 내용", "트윗 원문", or provides an X/Twitter URL (x.com, twitter.com) and wants to read, translate, or analyze the tweet content. Also useful when other skills need to fetch tweet text programmatically.
This skill should be used when the user asks to "check email", "read emails", "send email", "reply to email", "search inbox", or manages Gmail. Supports multi-account Gmail integration for reading, searching, sending, and label management.