skills/introspect/SKILL.md
Analyze Claude Code session logs and surface productivity improvements. Extracts thinking blocks, tool usage stats, error patterns, debug trajectories - then generates friendly, actionable recommendations. Triggers on: introspect, session logs, trajectory, analyze sessions, what went wrong, tool usage, thinking blocks, session history, my reasoning, past sessions, what did I do, how can I improve.
npx skillsauth add 0xDarkMatter/claude-mods introspectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Extract actionable intelligence from Claude Code session logs. For general JSONL analysis patterns (filtering, aggregation, cross-file joins), see the log-ops skill.
The scripts/cc-session script provides zero-dependency analysis (requires only jq + bash). Auto-resolves the current project and most recent session.
# Copy to PATH for global access
cp skills/introspect/scripts/cc-session ~/.local/bin/
# Or on Windows (Git Bash)
cp skills/introspect/scripts/cc-session ~/bin/
| Command | What It Does |
|---------|-------------|
| cc-session overview | Entry counts, timing, tool/thinking totals |
| cc-session tools | Tool usage frequency (sorted) |
| cc-session tool-chain | Sequential tool call trace with input summaries |
| cc-session thinking | Full thinking/reasoning blocks |
| cc-session thinking-summary | First 200 chars of each thinking block |
| cc-session errors | Tool results containing error patterns |
| cc-session conversation | Reconstructed user/assistant turns |
| cc-session files | Files read, edited, written (with counts) |
| cc-session turns | Per-turn breakdown (duration, tools used) |
| cc-session agents | Subagent spawns with type and prompt preview |
| cc-session cost | Rough token/cost estimation |
| cc-session timeline | Event timeline with timestamps |
| cc-session summary | Session summaries (compaction boundaries) |
| cc-session search <pattern> | Search across sessions (text content) |
--project, -p <name> Filter by project (partial match)
--dir, -d <pattern> Filter by directory pattern in project path
--all Search all projects (with search command)
--recent <n> Use nth most recent session (default: 1)
--json Output as JSON instead of text
cc-session overview # Current project, latest session
cc-session tools --recent 2 # Tools from second-latest session
cc-session tool-chain # Full tool call sequence
cc-session errors -p claude-mods # Errors in claude-mods project
cc-session thinking | grep -i "decision" # Search reasoning
cc-session search "auth" --all # Search all projects
cc-session turns --json | jq '.[] | select(.tools > 5)' # Complex turns
cc-session files --json | jq '.edited[:5]' # Top 5 edited files
cc-session overview --json # Pipe to other tools
What do you want to know?
|
|- "What happened in a session?"
| |- Quick overview ---- cc-session overview
| |- Full conversation -- cc-session conversation
| |- Timeline ---------- cc-session timeline
| |- Summaries --------- cc-session summary
|
|- "How was I using tools?"
| |- Frequency ---------- cc-session tools
| |- Call sequence ------- cc-session tool-chain
| |- Files touched ------- cc-session files
|
|- "What was I thinking?"
| |- Full reasoning ------ cc-session thinking
| |- Quick scan ---------- cc-session thinking-summary
| |- Topic search -------- cc-session thinking | grep -i "topic"
|
|- "What went wrong?"
| |- Tool errors --------- cc-session errors
| |- Debug trajectory ---- cc-session tool-chain (trace the sequence)
|
|- "Compare sessions"
| |- Tool usage diff ----- cc-session tools --recent 1 vs --recent 2
| |- Token estimation ---- cc-session cost
|
|- "Search across sessions"
| |- Current project ----- cc-session search "pattern"
| |- All projects -------- cc-session search "pattern" --all
~/.claude/
|- projects/
| |- {project-path}/ # e.g., X--Forge-claude-mods/
| |- sessions-index.json # Session metadata index
| |- {session-uuid}.jsonl # Full session transcript
| |- agent-{short-id}.jsonl # Subagent transcripts
Project paths use double-dash encoding: X:\Forge\claude-mods -> X--Forge-claude-mods
| Type | Role | Key Fields |
|------|------|------------|
| user | User messages + tool results | message.content[].type = "text" or "tool_result" |
| assistant | Claude responses | message.content[].type = "text", "tool_use", or "thinking" |
| system | Turn duration, compaction | subtype = "turn_duration" (has durationMs) or "compact_boundary" |
| progress | Hook/tool progress events | data.type, toolUseID, parentToolUseID |
| file-history-snapshot | File state checkpoints | snapshot, messageId, isSnapshotUpdate |
| queue-operation | Message queue events | operation, content |
| last-prompt | Last user prompt cache | lastPrompt |
| summary | Compaction summaries | summary, leafUuid |
| Block Type | Found In | Fields |
|-----------|----------|--------|
| text | user, assistant | .text |
| tool_use | assistant | .id, .name, .input |
| tool_result | user | .tool_use_id, .content |
| thinking | assistant | .thinking, .signature |
uuid, parentUuid, sessionId, timestamp, type,
cwd, gitBranch, version, isSidechain, userType
By default, Claude Code deletes sessions inactive for 30 days (on startup). Increase to preserve history for analysis.
// ~/.claude/settings.json
{
"cleanupPeriodDays": 90
}
Currently set to 90 days. Adjust based on disk usage (dust -d 1 ~/.claude/projects/).
For one-off queries when cc-session doesn't cover your need:
# Pipe through cat on Windows (jq file args can fail)
cat session.jsonl | jq -r 'select(.type == "assistant") | .message.content[]? | select(.type == "tool_use") | .name'
# Two-stage for large files
rg '"tool_use"' session.jsonl | jq -r '.message.content[]? | select(.type == "tool_use") | .name'
After running any analysis, always generate a "Session Insights" section with actionable recommendations. The tone should be friendly and mentoring - a helpful colleague who noticed some patterns, not a critic.
Scan the session data for these patterns and generate recommendations where relevant:
Tool usage improvements:
Bash(grep ...) or Bash(cat ...) instead of Grep/Read tools - suggest the dedicated toolsWorkflow patterns:
/save at session end - remind about session continuity/save/iterate could automate - mention the loop patternSkill and command awareness:
/review - mention the skill/testgen - mention the skill/atomise - mention it for hard problemsSession efficiency:
Permission recommendations: This is high-value - permission prompts break flow and cost context. Scan the session for:
Bash(<command>:*) allow rulesGenerate a ready-to-paste permissions.allow snippet for .claude/settings.local.json:
**Permissions**
Based on this session, these tools were used frequently and could be
pre-approved to reduce interruptions:
Add to `.claude/settings.local.json` under `permissions.allow`:
"Bash(uv:*)",
"Bash(pytest:*)",
"Bash(docker:*)",
"WebSearch",
"mcp__my-server__*"
This would have saved roughly ~N permission prompts in this session.
Only recommend commands that were actually used successfully - never suggest blanket Bash(*). But do encourage wildcard patterns where sensible - Bash(git:*) is better than listing Bash(git status), Bash(git add), Bash(git commit) separately. Common wildcard groups:
Bash(git:*) - all git operationsBash(npm:*), Bash(pnpm:*), Bash(uv:*) - package managersBash(pytest:*), Bash(jest:*) - test runnersBash(docker:*), Bash(cargo:*), Bash(go:*) - build/runtime toolsmcp__server-name__* - all tools from an MCP serverGroup recommendations by category for clarity. Reference /setperms for a full permissions setup if the list is long.
## Session Insights
Here are a few things I noticed that might help next time:
**[Category]**
- [Observation]: [What was seen in the data]
- [Suggestion]: [Friendly, specific recommendation]
**[Category]**
- ...
Scale the number of recommendations to the session size. A quick 10-minute session might warrant 1-2 observations. A sprawling multi-hour session with 100+ tool calls could easily have 10-15 actionable insights. Match the depth of analysis to the depth of the session.
Only mention patterns that are clearly present in the data - don't guess or stretch. If the session was clean and efficient, say so: "This was a well-structured session - nothing jumps out as needing improvement."
| File | Contents |
|------|----------|
| scripts/cc-session | CLI tool - session analysis with 14 commands, JSON output, project filtering |
| references/session-analysis.md | Raw jq recipes for custom analysis beyond cc-session |
tools
Behavioural-first software supply chain defense - catches poisoned npm/PyPI packages in the publish-to-advisory window that CVE tools miss. Use BEFORE every install or version bump (not only when an attack is suspected) - the 7-day cooldown gate + behavioural score catches freshly-published malware that CVE tools won't see for days. Socket.dev integration (free CLI + GitHub app + depscore MCP for Claude Code), stale-OIDC audit, dependency cooldown policy, publish-token rotation, VS Code extension audit, and a self-integrity scan that detects worm persistence hooks injected into Claude Code / VS Code settings. Triggers on: pip install, uv add, uv tool install, npm install, pnpm add, yarn add, cargo add, go get, composer require, gem install, upgrade dependency, dependency upgrade, version bump, bump version, bump package, adding dependency, new dependency, vetting a dependency, vet package, is this package safe, safe to install, should I install, before installing, pre-install check, preinstall scan, preinstall-check, PyPI cooldown, npm cooldown, release cooldown, minimumReleaseAge, score a package, package score, depscore, socket score, supply chain, supply chain attack, malicious package, poisoned dependency, npm worm, Shai-Hulud, behavioural scanning, Socket.dev, socket scan, dependency security, postinstall malware, OIDC token theft, compromised maintainer, typosquat, dependency confusion, package provenance, SLSA, persistence hook, malicious VS Code extension.
testing
GitHub remote operations — repo creation, metadata (description/homepage/topics), releases, README 'Recent Updates' enforcement, and issue / PR management with preview-before-send discipline. Companion to git-ops (local) and push-gate (pre-push safety). Three modes: new (first publish), update (subsequent release), audit (read-only checklist), plus atomic operations for issues and PRs. Triggers on: push to github, publish repo, ship release, cut release, gh release, set topics, repo description, github metadata, recent updates section, audit github repo, repo visibility, make repo public, gh repo create, gh issue, gh pr, create issue, comment on issue, close issue, triage issue, create PR, review PR, merge PR, pre-merge check, pr checks.
tools
Defend the agent's instruction surface against adversarial content - hidden-Unicode prompt injection (Trojan Source bidi reordering, U+E0000 tag-block ASCII smuggling, zero-width text), homoglyph confusables, and poisoned context that a human reviewer can't see but the model obeys. Scan CLAUDE.md / AGENTS.md / SKILL.md / .cursorrules and MCP tool descriptions; sanitize fetched web pages, issue/PR bodies, and dependency READMEs before they enter context. Triggers on: prompt injection, hidden unicode, invisible characters, zero-width space, bidi override, Trojan Source, ASCII smuggling, tag characters, homoglyph, confusable, unicode steganography, poisoned CLAUDE.md, malicious tool description, MCP tool poisoning, instruction injection, jailbreak in file, is this file safe, sanitize untrusted content, scan for hidden text.
tools
Set tool permissions for Claude Code. Configures allowed commands, rules, and preferences in .claude/ directory. Triggers on: setperms, init tools, configure permissions, setup project, set permissions, init claude.