| name | post-session |
| description | Analyze last session transcript for error patterns and user corrections, then improve the harness or add rules. Run after any session with notable errors, corrections, or repeated mistakes. |
| disable-model-invocation | true |
Post-Session Analysis
Analyze the last session and patch the harness.
Phase 1: Find Transcript
Session transcripts live at:
~/.claude/projects/<sanitized-path>/*.jsonl
where <sanitized-path> = CWD with leading / stripped and remaining / replaced by -.
Run:
ls -t ~/.claude/projects/$(pwd | sed 's|^/||; s|/|-|g')/*.jsonl | head -1
If $ARGUMENTS is a file path — use that instead.
If no JSONL found — ask the user to describe errors directly and skip to Phase 3.
Phase 2: Extract Signal
Read the JSONL file. Each line is a JSON object. Scan for:
Tool errors — objects where:
type == "tool_result" and is_error == true
- Any tool result content containing "Error:", "error:", "exception", "not found", "permission denied", "traceback", "exit code [^0]"
User corrections — type == "user" messages (after at least one assistant turn) containing:
- Negations: "no", "нет", "don't", "не надо", "stop", "wrong", "неправильно"
- Redirects: "instead", "вместо", "actually", "на самом деле", "you should", "нужно было"
- Re-stating the same request as a prior turn
Retry patterns — the same tool called with near-identical arguments within 4 exchanges (Claude got stuck or produced a wrong result and retried).
Rule violations — read .claude/rules/*.md and CLAUDE.md. Find assistant actions that contradict a rule defined there.
Produce a signal table:
Signal | Type | Count | Location
──────────────────────────────────────────────────────────────────────────────
Bash: "command not found: rg" | Tool error | ×1 | line 47
User: "no, use the Read tool" | User correction | ×3 | lines 12,89,134
Same Grep call retried | Retry pattern | ×2 | lines 56–62
Used `cat` instead of Read | Rule violation | ×2 | rules/use-tools.md
If the signal table is empty:
No errors or corrections found in this session.
Nothing to patch.
Stop here.
Phase 3: Classify + Patch
Apply harness-refine logic from .claude/skills/harness-refine/SKILL.md Phase 2 onwards, using the signal table as input.
Map signals to classes:
| Signal type | Class (from harness-refine) |
|---|
| Tool error ×1 | Missing verify step / API gap |
| User correction ×1 | Inherent complexity (document only) |
| User correction ×2+ | Repeated anti-pattern → new rule |
| Retry pattern | Missing workflow step |
| Rule violation | Rule exists but violated |
Single occurrences default to "inherent complexity" unless there is a clear structural root cause (wrong tool, wrong API, missing step). Apply judgment — don't over-patch one-off errors.
Follow harness-refine's Phase 2–5 exactly: classification table → targeted research (Agent V if needed) → report → surgical patch → append to harness-research.md.
Phase 4: Update Project Wiki
Read project-wiki.md in CWD. If it doesn't exist, create it:
# Project Wiki
<!-- Maintained by /post-session. Append-only — never delete entries, mark stale instead. -->
## Reuse Map
Existing implementations — check before building anything:
| What | Path | Notes | Added |
|------|------|-------|-------|
## Anti-Patterns
Project-specific patterns that fail in THIS codebase (generic ones go to `.claude/rules/`):
| Pattern | Why it fails here | Better approach | Added |
|---------|------------------|-----------------|-------|
## Tips
Approaches confirmed to work well in this project:
| Tip | Context | Added |
|-----|---------|-------|
## Gotchas
Non-obvious constraints or behaviors:
| Gotcha | Impact | Added |
|--------|--------|-------|
What to write:
Reuse Map — add if the session revealed Claude tried to build something that already existed:
- Source: retry patterns where the retried implementation was rejected in favor of an existing one
- Source: user corrections like "we already have X at path Y"
- Format:
| <what> | <file:line> | <one-line note> | <date> |
Anti-Patterns — add project-specific patterns from repeated signals (×2+):
- Only if NOT already in
.claude/rules/ (wiki is for project-specific, rules are for generic)
- Must include "better approach" — not just what to avoid
- Format:
| <what agent tried> | <why it fails here> | <what to use instead> | <date> |
Tips — add if the session had a notable approach that worked unexpectedly well.
Gotchas — add non-obvious constraints discovered (API quirks, ordering requirements, hidden dependencies).
Lint existing entries: For each path in Reuse Map, run:
ls <path> 2>/dev/null || echo "MISSING"
If missing: append ⚠️ stale — verify to the Notes cell. Do not remove the entry.