用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/leek/agent-skills --skill distill-sessions命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Run a bounded architectural refactor loop toward a stated design.
Drive an existing wayfinder map, spec, or set of tickets to completion through fresh top-level Claude Code, Codex, or Grok sessions.
Two-axis review of the diff since a fixed point: Standards (repo conventions) and Spec (ticket/PRD fidelity). Use when the user wants to review a branch, PR, WIP changes, or asks to "review since X".
正在显示 SKILL.md
| name | distill-sessions |
| description | Mine recent AI-coding session logs for reusable patterns and propose concrete improvements. |
| disable-model-invocation | true |
Turn raw session transcripts into a ranked list of concrete improvements. Read-only analysis of the logs; never modify the log files. Output a numbered proposal list with one verbatim (redacted) evidence line per finding, then let the user pick which to apply.
~/.claude/projects/<slug>/*.jsonl (top-level sessions). Per-session subagent transcripts are under <uuid>/subagents/agent-*.jsonl: skip these when counting "sessions"; they're part of a parent.~/.codex/sessions/<year>/<month>/<day>/rollout-*.jsonl.Both are JSONL, one event per line.
Default N = 50 unless the user gives a number. date/strftime may be missing from the shell, use perl for timestamps.
{ find ~/.claude/projects -name '*.jsonl' -type f | grep -v '/subagents/'; \
find ~/.codex/sessions -name 'rollout-*.jsonl' -type f; } \
| xargs stat -f '%m %z %N' | sort -rn | head -50 \
| perl -lane 'use POSIX qw(strftime); my($m,$s,@p)=@F; printf "%s %7dKB %s\n", strftime("%Y-%m-%d %H:%M",localtime($m)), $s/1024, join(" ",@p)'
Files are large and full of tool-output noise. jq is the right tool. Two schemas:
Claude Code
# human-typed messages (string form)
jq -rc 'select(.type=="user" and (.message.content|type=="string")) | .message.content' FILE
# human messages (array form; skip <command-name>/system-reminder noise by eye)
jq -rc 'select(.type=="user" and (.message.content|type=="array")) | .message.content[]? | select(.type=="text") | .text' FILE
# bash commands the assistant ran
jq -rc 'select(.type=="assistant") | .message.content[]? | select(.type=="tool_use" and .name=="Bash") | .input.command' FILE
# tool errors
jq -rc 'select(.type=="user") | .message.content[]? | select(.type=="tool_result" and .is_error==true) | (.content|if type=="array" then (map(.text//"")|join(" ")) else tostring end)' FILE
Codex
# human messages (the FIRST is an AGENTS.md preamble: ignore it)
jq -rc 'select(.type=="event_msg" and .payload.type=="user_message") | .payload.message' FILE
# shell commands
jq -rc 'select(.type=="response_item" and .payload.type=="function_call") | .payload.arguments' FILE
# command outputs (grep for errors)
jq -rc 'select(.type=="response_item" and .payload.type=="function_call_output") | (.payload.output|tostring)' FILE | grep -iE 'error|not found|exception|fatal|denied' | head
Surface corrections fast by grepping extracted human messages:
grep -iE "no,|actually|that.?s wrong|don.?t |stop |instead|you should have|i told you|revert|why did you|wrong"
50 sessions won't fit one context. Split the file list into ~7 round-robin batches (so big files spread out) and dispatch one subagent per batch in parallel, each with the jq cheat-sheet above and an identical brief. Each subagent returns a structured findings list; the orchestrator dedupes across batches and synthesizes. Round-robin assignment:
awk '{print $NF}' top.txt | awk '{ b=((NR-1)%7)+1; print > ("batch_" b ".txt") }'
You are proposing improvements to the agent's environment, so that future runs go better. Each lens below names what to look for and the moment that triggers it.
Evidence lenses: what the transcript shows happening:
Environment lenses: what should change so it stops happening:
CLAUDE.md / AGENTS.md (repo or global) that belong in coding standards or an automated check instead? Use when a steering file is large and unwieldy.In every quoted evidence line, replace emails, API keys, tokens, secrets, passwords, and bearer strings with [REDACTED]. Keep quotes short.
For each finding, give: the proposal, the one verbatim (redacted) evidence line it came from (with session basename), the destination, and a one-sentence why. Destinations:
CLAUDE.md / AGENTS.md (name the file)Do not change anything. Present the list and let the user choose which to apply. Lead with the cross-cutting themes (patterns that recurred across 3+ sessions are the highest-value to act on).
All work goes through two stages, and they carry very different context pressure. The implementation agent bears the most: it explores, writes code, and debugs failures. The reviewer bears the least, it receives a diff, so it needs no exploration and usually writes no code.
So standards belong to the reviewer, not the implementer. A proposal of the form "tell the agent to always do X while coding" is nearly always better placed as a review rule, where it costs nothing until there is a diff to check.
The destinations, ranked by what they cost:
CLAUDE.md / AGENTS.md sit in every agent's context in this repo. Spend lines here incredibly sparingly, and mostly on context pointers to other files.writing-for-agents.