Distill a session into a skill with skill-distill
Have a Claude Code or Codex teacher write a skill, test an open-weight student thrice, then stop only when you accept.
Published here · 1 source · Resume reading
A frontier model finished a task well. Copying the transcript into a smaller model is not a skill. skill-distill turns that session into instructions an open-weight student can follow, then proves the student on fresh runs before you accept. License: MIT. [1]
Related reading: rederive: defend AI-built code by redesigning it, Agent skill metadata and progressive loading and Constrain AI coding agent scope. Browse the AI agents topic.
Install the teacher skill
git clone https://github.com/sybil-solutions/skill-distill
ln -s "$PWD/skill-distill/skills/skill-distill" ~/.claude/skills/skill-distillFor Codex, the README uses ~/.agents/skills/skill-distill instead. Requirements: tmux, git, Python 3.10+, and the student agent installed and pointed at its model. For web results: pip install playwright pillow && playwright install chromium. [1]
You should see the skill path linked under your Claude Code or Codex skills directory before you ask the teacher to distill. [1]
Run the three-trial loop after a good session
At the end of a session that worked, ask the teacher in the form the README shows, for example: distill this session into a skill for omp with deepseek-v4.1-flash on my local server. [1]
The teacher loop, per the README:
- Read the session and write a skill for the student.
- Start the student in tmux on a fresh copy of the starting state with the original prompt and the skill.
- Compare what the student produced with the reference.
- Find the first place the student went wrong and fix the skill there.
- Run again, three trials per skill version, until the student matches the reference.
One lucky run proves nothing. Three trials per version is the gate before you even look at accept. Watch with tmux attach -t distill-<task>. [1]
Bookkeeping lives in skills/skill-distill/scripts/distill.py (init, trial, status, wait, evidence, verdict, ledger, report, accept). [1]
Fix the skill at the first wrong step, not at every difference you notice later. The README's loop is first-failure repair: rewrite the instruction that caused the miss, then re-run the three trials on that new version. Spreading edits across the whole skill between trials hides which change actually helped. [1]
Keep student isolation rules
The student gets the reference prompt verbatim, a clean starting state, and the skill. Nothing else. Where the student agent allows it, turn off that agent's own global context files and skills so the trial measures the produced skill, not leftover project memory. [1]
The skill may not contain the reference's finished output or a script that writes it. It teaches steps, decisions, traps and checks. Short snippets are allowed only where the student cannot get a part right otherwise. [1]
Checks are tested on the reference first. A check that fails on the reference is a broken check. Raw session logs stay in runs/, which is git-ignored, because they contain machine paths and context. [1]
| Rule | Pass | Fail |
|---|---|---|
| Inputs to the student | Prompt + clean start + skill only | Global skills or prior session context left on |
| Skill contents | Steps, traps, checks | Finished answer or a script that emits it |
| Trials per version | Three | One lucky success treated as done |
| Checks | Pass on the reference first | Fail on the reference, then blamed on the student |
| Done | You accept after side-by-side review | Teacher marks done without your accept |
Stop only at your accept gate
The teacher shows the reference and the student's best results side by side. The skill counts as done only when you accept it. The result is two artifacts: the reusable operator skill in the repo, and a produced skill for one task, one model and one student agent. [1]
Adapters listed in the README: omp (oh-my-pi) tested; Codex CLI tested as the teacher (as a student it needs a provider in STUDENT_ARGS); Claude Code written (open models need ANTHROPIC_BASE_URL to an Anthropic-compatible server); pi written, untested; opencode written, untested (its JSON log has no parser in extract_session.py yet). [1]
Useful paths inside the clone: skills/skill-distill/SKILL.md (the teacher loop), scripts/extract_session.py (Claude Code / Codex / omp logs to a readable reference, dropping system and AGENTS.md text), scripts/capture_web.py (serve a web app, drive headless Chromium, save screenshots and errors), adapters/ (one script per student agent), templates/student-skill/ (starting shape of a produced skill), and examples/ (finished runs with prompt, skill, ledger and screenshots). [1]
If the student agent adapter is listed as untested (pi, opencode), treat the first distill as an adapter smoke test: confirm tmux sessions start, logs parse, and accept can run before you invest in a long repair loop. The README marks omp as tested; start there when you want the documented path. [1]
Do not paste the frontier model's finished answer into the skill "just this once" to get a green trial. That breaks the isolation rules and teaches the student to emit a memorised artifact. Keep the skill as steps and checks, then spend the trials finding where the student actually diverges. [1]
Your next distill should stop at your accept step, not at the first lucky student trial.
Send this to the teammate who copies a frontier transcript into a smaller model and calls it a skill without a fail-and-fix loop.
Keep this guide
Filed under AI agents, Claude Code
Questions about this guide
What is skill-distill?
An MIT skill for Claude Code or Codex (the teacher). After a good session you name a student agent and model. The teacher writes a skill, runs the student on a fresh copy of the starting state, compares output, fixes the skill at the first failure, and repeats with three trials per version until you accept.
What does the student receive?
Per the README: the reference prompt verbatim, a clean starting state, and the skill. Nothing else. Global context files and skills on the student side are turned off where the student agent allows it.
Can the skill contain the finished answer?
No. The README says the skill may not contain the reference finished output or a script that writes it. It teaches steps, decisions, traps and checks.
Which student agents are listed?
Adapters listed: omp (oh-my-pi) tested; Codex CLI tested as teacher (as student needs STUDENT_ARGS); Claude Code written (open models need ANTHROPIC_BASE_URL); pi written untested; opencode written untested.
Sources
- sybil-solutions/skill-distill READMEgithub.com