chat-analysis
Skill2 starsChanged 4 months agoMITView on GitHub
Analyze Codex or Claude Code session transcripts for failure patterns and propose agent-instruction improvements. Runs the four-stage pipeline (parse → filter → label → compile) via scripts/chat_analysis.py. Use when the user says "analyze my chats", "run chat analysis", "review my sessions", "what am I doing wrong", "chat analysis", or "/chat-analysis".
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- JularDepick/ChatAnalysis.SKILLtheir own version, first seen Jun 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- JularDepick/ChatAnalysis.SKILL★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-coordinationSkill
- blog-image-genSkill
- bogdan-baciu-designSkill
- deep-decideSkill
- deep-research-agentsSkill
- grill-meSkill
- handoffSkill
- insight-lockSkill
- parallel-dispatchSkill
- quiz-meSkill
- skill-drift-scannerSkill
- table-system-migrationSkill
- weekly-updateSkill
- x-signal-researchSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 39
If ANTHROPIC_API_KEY is not set, remind the user it's required and stop.
- Distinctive: line 45
Always do a dry run to confirm there are friction sessions worth labeling:
- Very specific: line 90
After the script completes, read chat-analysis-review.md and summarize the top 3 findings to the user directly in the conversation:
- Distinctive: line 110
If the user says "accept all" or "apply them", ask them to confirm which specific items they want and make only those edits.
- Very specific: line 124
Use that report as an improvement backlog for skills, memory notes, and automation candidates.
- Very specific: line 175
Default scope is current project only — never --all without auditing
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Chat Analysis — Recursive Self-Improvement
Analyze session transcripts from Claude (~/.claude/projects/) or Codex
(~/.codex/sessions, ~/.codex/archived_sessions) to surface failure
patterns, rule violations, and candidate improvements to agent instructions.
The pipeline:
- Parse — read
.jsonlsession files - Filter — regex pre-filter drops clean sessions (no friction signals)
- Label — survivors go to Sonnet with a strict JSON schema
- Compile — aggregate into tables, proposed deltas written to a review file
When to use
- "Analyze my chats" / "run chat analysis"
- "What patterns are in my Claude/Codex sessions?"
- "What rules should I add to my agent instructions?"
- "How many sessions had verification failures?"
- Weekly improvement cadence: run on the last 50–100 sessions
- Monthly
/insightscadence: review recent sessions for skills, memory, and automation candidates rather than one-off bug fixes
Setup (verify once)
# Check API key
echo $ANTHROPIC_API_KEY | head -c 10
# Install dependency (if needed)
pip install anthropic
# or: .venv/bin/pip install anthropicIf ANTHROPIC_API_KEY is not set, remind the user it's required and stop.
Workflow
Step 1 — Dry run first
Always do a dry run to confirm there are friction sessions worth labeling:
python3 scripts/chat_analysis.py --dry-runThis parses and pre-filters without spending any API tokens. Report what the filter found. If zero friction sessions: tell the user and stop — the sessions look clean.
Step 2 — Cost check
Estimate cost before running. Each surviving session is one labeling API call.
The model is configurable with --model or CHAT_ANALYSIS_MODEL; check current
provider pricing before quoting a dollar estimate. For the default run (last 50
sessions), proceed unless the user has flagged the project as sensitive or
cost-constrained. For --all or --n values above 200, confirm with the user first.
Step 3 — Run the analysis
# Default: current project, last 50 sessions
python3 scripts/chat_analysis.py
# Codex sessions for the current working directory
python3 scripts/chat_analysis.py --source codex
# Last 100 sessions
python3 scripts/chat_analysis.py --n 100
# All projects
python3 scripts/chat_analysis.py --all
# Custom output path
python3 scripts/chat_analysis.py --output /tmp/review.md
# Heuristic-only — no API calls, nothing leaves the machine
python3 scripts/chat_analysis.py --no-labelStream output so the user sees progress. Report the final count:
X sessions parsed → Y passed filter → Z labeled.
Step 4 — Surface findings
After the script completes, read chat-analysis-review.md and summarize the
top 3 findings to the user directly in the conversation:
# The report is self-contained, but surface the headline numbers
head -80 chat-analysis-review.mdTell the user:
- The #1 failure mode by count
- The highest-cost failure mode (most rework cycles per incident)
- The most-violated rule (if any)
- How many candidate instruction deltas are in the review file
Step 5 — Review deltas (user decision)
The review file has a ## Proposed Agent-Instruction Deltas section with checkbox
items. Walk the user through them one at a time if they want, or point them
to the file. Never auto-apply any delta to agent instructions — the user decides.
If the user says "accept all" or "apply them", ask them to confirm which specific items they want and make only those edits. The model does not edit its own operating rules autonomously.
Monthly /insights cadence
In dans-brain, the Mac LaunchAgent
launchd/com.dansbrain.monthly-agent-insights.plist runs this pipeline monthly
against recent Codex sessions and writes:
state/monthly-agent-insights.mdUse that report as an improvement backlog for skills, memory notes, and automation candidates. Do not auto-apply proposed instruction deltas; Dan still decides which changes become durable operating rules.
Output file
chat-analysis-review.md (or the path passed via --output) contains:
- Summary stats table
- Top failure modes by count
- Highest-cost failure modes by avg rework cycles
- Communication antipatterns
- Rule violation rankings
- Proposed agent-instruction deltas (checkbox list, user must decide)
- Sample corrections and positive signals
- Per-session detail table
The file is ephemeral — not committed, not deployed. It's a scratchpad for the improvement session. Delete it when done.
What the pipeline looks for
Five friction patterns (from the blog post that describes this workflow):
- Corrections — "no", "wrong", "stop", "that's not right"
- Repeated instructions — same fix asked for across multiple turns
- Praise of non-obvious choices — "yes, exactly, keep doing that"
- Tool loops — same tool called 3+ times before switching
- Clarifying questions — model had to ask because context was incomplete
Privacy & data security
Transcripts can contain code, paths, customer data, and secrets. The pipeline is hardened against leakage:
Automatic redaction before any data leaves the machine:
- API keys (Anthropic
sk-ant-…, OpenAIsk-…, GitHubghp_/gho_/ghs_, AWSAKIA…, Slackxox[baprs]-…) - JWTs, Bearer tokens,
Authorization:headers password=,secret=,api_key=,access_token=assignments- Email addresses
- Absolute home paths (
/Users/<name>→/Users/[REDACTED]) - Credit-card-shaped numbers
Redaction runs in redact() (scripts/chat_analysis.py). Update the
REDACTION_RULES list to add patterns specific to your environment
(internal hostnames, customer IDs, project codenames, etc.).
Other safeguards:
- Session IDs in the report are SHA-256 hashed (8 chars), not raw filenames
- Sample corrections / positives are redacted AND truncated to 160 chars
- Default scope is current project only — never
--allwithout auditing --no-labelproduces a heuristic-only report with zero API calls; use this for any project with stricter confidentiality requirements- The output report is gitignored by default
Before running on a sensitive project, do a dry run and skim the friction
session list. If anything looks like it could leak, run with --no-label
or extend REDACTION_RULES first.
Troubleshooting
"Could not auto-detect project dir"
For Claude, the script maps CWD → ~/.claude/projects/ by hashing the path. If it
fails, pass the path explicitly:
ls ~/.claude/projects/ # find the right directory name
python3 scripts/chat_analysis.py --project ~/.claude/projects/<dir>For Codex, auto-detection reads recent sessions from ~/.codex/sessions and
~/.codex/archived_sessions, then filters by the session cwd. If the session
is older than the default window, use --source codex --all --n <larger N> or
pass a specific transcript directory with --project.
"ANTHROPIC_API_KEY not set"
export ANTHROPIC_API_KEY=sk-ant-...
python3 scripts/chat_analysis.py"anthropic package not installed"
pip install anthropicLabeling errors / JSON parse failures These are logged as warnings and skipped. The report includes only sessions that labeled successfully. A handful of failures is normal; if >20% fail, check the model response in debug mode.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

