session-analyzer by ai-native-camp/camp-2
npx skills add https://github.com/ai-native-camp/camp-2 --skill session-analyzer用于根据 SKILL.md 规范验证 Claude Code 会话行为的后验分析工具。
分析已完成的会话以验证:
| 参数 | 是否必需 | 描述 |
|---|---|---|
sessionId | 是 | 要分析的会话的 UUID |
targetSkill | 是 | 用于验证的 SKILL.md 文件路径 |
additionalRequirements |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 否 |
| 额外的验证标准 |
会话文件位于 ~/.claude/ 目录下:
# 主会话日志
~/.claude/projects/-{encoded-cwd}/{sessionId}.jsonl
# 调试日志(详细)
~/.claude/debug/{sessionId}.txt
# 代理记录(如果使用了子代理)
~/.claude/projects/-{encoded-cwd}/agent-{agentId}.jsonl
使用脚本定位文件:
${baseDir}/scripts/find-session-files.sh {sessionId}
在继续之前,检查所有必需的文件是否存在。如果缺少调试日志,分析将受到限制。
读取目标 SKILL.md 并识别:
从 YAML Frontmatter 中提取:
hooks.PreToolUse - 预期的 PreToolUse 钩子和匹配器hooks.PostToolUse - 预期的 PostToolUse 钩子hooks.Stop - 预期的 Stop 钩子hooks.SubagentStop - 预期的 SubagentStop 钩子allowed-tools - 技能允许使用的工具从 Markdown 正文中提取:
Task(subagent_type="..."))Skill("...")).dev-flow/drafts/、.dev-flow/plans/ 等)根据 SKILL.md 分析创建检查清单:
## 预期行为
### SubAgents
- [ ] Explore agent 被调用(并行,run_in_background)
- [ ] gap-analyzer 在计划生成前被调用
- [ ] reviewer 在计划创建后被调用
### Hooks
- [ ] PreToolUse[Edit|Write] 触发 plan-guard.sh
- [ ] Stop 钩子验证 reviewer 批准
### 产物
- [ ] 在 .dev-flow/drafts/{name}.md 处创建草稿文件
- [ ] 在 .dev-flow/plans/{name}.md 处创建计划文件
- [ ] 草稿文件在 OKAY 后被删除
### 工作流程
- [ ] 计划生成前进入 Interview Mode
- [ ] 用户明确请求触发计划生成
- [ ] Reviewer REJECT 导致修订循环
调试日志(~/.claude/debug/{sessionId}.txt)包含详细的执行跟踪。
搜索模式:
SubagentStart with query: {agent-name}
SubagentStop with query: {agent-id}
使用脚本:
${baseDir}/scripts/extract-subagent-calls.sh {debug-log-path}
搜索模式:
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
使用脚本:
${baseDir}/scripts/extract-hook-events.sh {debug-log-path}
搜索模式:
executePreToolHooks called for tool: {tool-name}
File {path} written atomically
对于基于提示的钩子,查找模型响应:
Hooks: Model response: {
"ok": true/false,
"reason": "..."
}
对于每个预期的产物:
FileHistory: Tracked file modification for {path}File {path} written atomically对于应被删除的文件:
rm 命令| 组件 | 预期 | 实际 | 状态 |
|-----------|----------|--------|--------|
| Explore agent | 2 次并行调用 | 在 09:39:26 有 2 次调用 | ✅ |
| gap-analyzer | 在计划前调用 | 在 09:43:08 调用 | ✅ |
| reviewer | 在计划后调用 | 2 次调用(REJECT→OKAY) | ✅ |
| PreToolUse 钩子 | Edit\|Write 匹配器 | 为 Write 触发 | ✅ |
| Stop 钩子 | 验证批准 | 返回 ok:true | ✅ |
| 草稿文件 | 创建后删除 | 创建→删除 | ✅ |
| 计划文件 | 创建 | 存在(10KB) | ✅ |
标记任何不匹配项:
# 会话分析报告
## 会话信息
- **会话 ID**: {sessionId}
- **目标技能**: {skillPath}
- **分析日期**: {date}
---
## 1. 预期行为(来自 SKILL.md)
[预期工作流程摘要]
---
## 2. 技能/SubAgent/钩子验证
### SubAgents
| SubAgent | 预期 | 实际 | 时间 | 结果 |
|----------|----------|--------|------|--------|
| ... | ... | ... | ... | ✅/❌ |
### Hooks
| 钩子 | 匹配器 | 是否触发 | 结果 |
|------|---------|-----------|--------|
| ... | ... | ... | ✅/❌ |
---
## 3. 产物验证
| 产物 | 路径 | 预期状态 | 实际状态 |
|----------|------|----------------|--------------|
| ... | ... | ... | ✅/❌ |
---
## 4. 问题/错误
| 严重性 | 描述 | 位置 |
|----------|-------------|----------|
| ... | ... | ... |
---
## 5. 总体结果
**判定**: ✅ 通过 / ❌ 失败
**摘要**: [1-2 句话摘要]
| 脚本 | 用途 |
|---|---|
find-session-files.sh | 根据会话 ID 定位所有文件 |
extract-subagent-calls.sh | 从调试日志中解析子代理调用 |
extract-hook-events.sh | 从调试日志中解析钩子事件 |
User: "Analyze session 3cc71c9f-d27a-4233-9dbc-c4f07ea6ec5b against .claude/skills/specify/SKILL.md"
1. 查找会话文件
2. 解析 SKILL.md → 预期:Explore, gap-analyzer, reviewer, hooks
3. 分析调试日志 → 提取实际调用
4. 验证产物 → 检查 .dev-flow/
5. 比较 → 构建验证表
6. 生成报告 → 附带详情的通过/失败
references/analysis-patterns.md - 用于日志分析的详细 grep 模式references/common-issues.md - 已知问题和故障排除scripts/find-session-files.sh - 会话文件定位器scripts/extract-subagent-calls.sh - SubAgent 调用提取器scripts/extract-hook-events.sh - 钩子事件提取器每周安装量
125
仓库
GitHub 星标数
9
首次出现
6 天前
安全审计
安装于
claude-code123
opencode7
gemini-cli6
github-copilot6
codex6
amp6
Post-hoc analysis tool for validating Claude Code session behavior against SKILL.md specifications.
Analyze completed sessions to verify:
| 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 |
Session files are located in ~/.claude/:
# 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:
${baseDir}/scripts/find-session-files.sh {sessionId}
Check all required files exist before proceeding. If debug log is missing, analysis will be limited.
Read the target SKILL.md and identify:
From YAML Frontmatter:
hooks.PreToolUse - Expected PreToolUse hooks and matchershooks.PostToolUse - Expected PostToolUse hookshooks.Stop - Expected Stop hookshooks.SubagentStop - Expected SubagentStop hooksallowed-tools - Tools the skill is allowed to useFrom Markdown Body:
Task(subagent_type="..."))Skill("...")).dev-flow/drafts/, .dev-flow/plans/, etc.)Create checklist from SKILL.md analysis:
## 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
The debug log (~/.claude/debug/{sessionId}.txt) contains detailed execution traces.
Search patterns:
SubagentStart with query: {agent-name}
SubagentStop with query: {agent-id}
Use script:
${baseDir}/scripts/extract-subagent-calls.sh {debug-log-path}
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:
${baseDir}/scripts/extract-hook-events.sh {debug-log-path}
Search patterns:
executePreToolHooks called for tool: {tool-name}
File {path} written atomically
For prompt-based hooks, find the model response:
Hooks: Model response: {
"ok": true/false,
"reason": "..."
}
For each expected artifact:
FileHistory: Tracked file modification for {path}File {path} written atomicallyFor files that should be deleted:
rm commands in Bash calls| 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) | ✅ |
Flag any mismatches:
# 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]
| Script | Purpose |
|---|---|
find-session-files.sh | Locate all files for a session ID |
extract-subagent-calls.sh | Parse subagent invocations from debug log |
extract-hook-events.sh | Parse hook events from debug log |
User: "Analyze session 3cc71c9f-d27a-4233-9dbc-c4f07ea6ec5b against .claude/skills/specify/SKILL.md"
1. Find session files
2. Parse SKILL.md → Expected: Explore, gap-analyzer, reviewer, hooks
3. Analyze debug log → Extract actual calls
4. Verify artifacts → Check .dev-flow/
5. Compare → Build verification table
6. Generate report → PASS/FAIL with details
references/analysis-patterns.md - Detailed grep patterns for log analysisreferences/common-issues.md - Known issues and troubleshootingscripts/find-session-files.sh - Session file locatorscripts/extract-subagent-calls.sh - SubAgent call extractorscripts/extract-hook-events.sh - Hook event extractorWeekly Installs
125
Repository
GitHub Stars
9
First Seen
6 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code123
opencode7
gemini-cli6
github-copilot6
codex6
amp6
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
138,300 周安装
Google Ads Manager 技能:广告系列管理、关键词研究、出价优化与效果分析
311 周安装
Telegram机器人开发教程:构建AI助手、通知系统与群组自动化工具
311 周安装
AI图像生成提示词优化指南:DALL-E、Midjourney、Stable Diffusion提示工程技巧
311 周安装
AI协作头脑风暴工具 - 将想法转化为完整设计规范,支持代码模板与项目管理
311 周安装
解决 Docker 沙盒 npm 安装崩溃:sandbox-npm-install 技能详解与使用指南
311 周安装
网页设计方法论:生产级HTML/CSS构建模式与BEM命名规范
311 周安装