Quick Answer: Skill distillation is turning a successful session with a frontier model, such as Claude Code or Codex, into a written skill that a cheaper open-weight model can follow to reproduce the same task. The open-source skill-distill tool automates this. It writes the skill, runs the student model on a clean copy of the starting state, compares the result to the reference, fixes the first point of failure, and repeats until you accept the output.

Most people who get a great result from a coding agent throw the session away. The prompt sits in the scrollback, the corrections live in the chat history, and the next time you need the same task done, you pay the frontier model to rediscover every trap. Skill distillation asks a better question: can a cheaper model do this task if someone writes down what the good session knew?

What skill distillation actually means

Distillation here borrows the teacher-student idea from machine learning, but the thing transferred is instructions, not weights. The frontier model is the teacher. The open-weight model running inside an agent harness is the student. The output is a plain Markdown skill the student reads before it starts.

The skill-distill repo runs this as a loop with five steps:

  1. The teacher reads the finished session and writes a skill for the student.
  2. It starts the student in tmux, on a fresh copy of the starting state, with the original prompt and the skill.
  3. It compares the student's output with the reference output from the session.
  4. It finds the first place the student went wrong and fixes the skill at that point.
  5. It runs again, three trials per version, until the student matches the reference.

Most guides skip the obvious question: why not just paste the original prompt into the cheaper model? Here's the problem. The prompt records what you asked for, not the decisions you made along the way. A frontier model will often infer the missing steps from general knowledge. A student model with a weaker reasoning budget will skip them, and the output looks plausible while being wrong in ways you only catch on inspection.

Why the skill can't contain the finished output

The most useful rule in the repo is also the least intuitive one. The skill may not contain the reference's finished output, or a script that writes it. The teacher teaches the steps, decisions, traps, and checks. It includes short code snippets only where the student can't get a part right otherwise.

Here's the reasoning. If the skill hands the student the answer, the student learns to copy, and the test passes for the wrong reason. Move the same task to a slightly different starting state and the copied answer breaks. A skill that teaches the decision ("check the port is free before you start the server, because a stale process from the last trial will serve the old build") transfers. A skill that contains the final file does not.

This also protects the check itself. The teacher tests every check on the reference first. A check that fails on the reference is a broken check, not evidence that the student is wrong. Without that step, you can spend a week tuning a skill against a test that was never valid.

Why three trials per version beats one lucky run

Language models are stochastic. A student can pass a task once and fail the next time with the same skill. In a web-app task, one run might happen to create the database tables in the right order, while another run hits a race condition between the server start and the first request. A single green result tells you almost nothing about the skill.

That's why the repo runs three trials per skill version. This is a simple rule, and it's the one people most want to skip when they're in a hurry. Don't. The cost is three runs of a cheap model, and the payoff is knowing the skill works more than a third of the time, not just once.

Here's where it gets interesting: the trials also show you which failures repeat. If two of three runs break at the same step, that step is the first place to fix in the skill. If the three runs fail in three different places, the skill is probably too vague overall, and the fix is more structure, not more detail at one spot.

Choosing a student harness, and what's actually tested

A student is a harness plus a model. The harness is the agent shell that gives the model tools, reads the skill, and runs commands. The repo ships one adapter script per harness, and their status matters for planning. The table below reflects the project's current README.

HarnessStatusWhat you need to know
omp (oh-my-pi)TestedThe example run uses omp with DeepSeek-V4.1-Flash
Codex CLITested as teacherAs a student, it needs a provider set in STUDENT_ARGS
Claude CodeWrittenOpen models need ANTHROPIC_BASE_URL pointed at an Anthropic-compatible server
piWritten, untestedTreat results as unverified until you run your own trials
opencodeWritten, untestedIts JSON log has no parser in extract_session.py yet

The trade-off is practical. The omp path is the one with real trials behind it, so it's the safer choice if you want a reliable result on the first attempt. Claude Code as a student is attractive if you already run an Anthropic-compatible local server, but the teacher has to know the server handles the tool calls the same way the hosted API does. Where the repo says "untested," it means exactly that, so plan extra trials.

Where it breaks: the caveats a responsible operator checks

The loop depends on a few things outside its control, and each one can quietly corrupt your results.

  • The starting state must actually be clean. The student gets a fresh copy of the starting state each trial. If the copy script misses a cache, a lockfile, or a running process, the student inherits a machine the reference never saw.
  • Web tasks need a real browser. capture_web.py serves the app and drives it in headless Chromium through Playwright. You need pip install playwright pillow and playwright install chromium. Without them, a screenshot-based check fails for reasons that have nothing to do with the skill.
  • The student's global context is switched off, but only where the harness allows it. Some harnesses can't disable their own global skills or AGENTS.md files. Check which context leaked before you trust a pass.
  • Raw logs contain your machine's details. Session logs include paths and context. The repo keeps them in runs/, which is git-ignored. Keep it that way if you ever share a produced skill.

Most people stop here and assume the teacher's verdict is final. Don't. The teacher shows you the reference and the student's best results side by side, and the skill counts as done only when you accept it. That final human call is the part no loop can replace.

Installing and running skill-distill

The setup is short. Clone the repo, then symlink the skill into your teacher's skills folder. For Claude Code, link it into ~/.claude/skills/. For Codex, link it into ~/.agents/skills/. You need tmux, git, Python 3.10 or later, and the student harness installed and pointed at its model.

Then, at the end of a session that went well, ask the teacher something direct, like: "distill this session into a skill for omp with deepseek-v4.1-flash on my local server." The teacher follows the loop in skills/skill-distill/SKILL.md. To watch a student work, run tmux attach -t distill-<task>.

Two things to get right before you start. First, pick a task with a checkable reference, because a task with no clear finished state gives the loop nothing to compare against. Second, pick a session you'd actually want to repeat. Distilling a messy one-off just gives you a messy skill.

Frequently Asked Questions

What is skill distillation for AI agents?

Skill distillation is the process of converting a successful session with a frontier model into a written skill that a smaller open-weight model can follow to reproduce the same task. The skill records steps, decisions, traps, and checks rather than the final output. The student runs the task from scratch, and the result is compared against the original.

how does skill-distill know when the student has matched the reference?

The teacher runs the student three times per skill version and compares each output with the reference, using checks that were first validated on the reference itself. It then fixes the first point of failure and repeats. The skill is only marked done when you review the reference and the student's best results side by side and accept them.

Can I use Codex as the teacher with skill-distill?

Yes. The repo lists Codex CLI as tested as the teacher. As a student, Codex needs a provider configured in STUDENT_ARGS. Check the adapter status table before you plan a run, because adapters marked "written, untested" need extra trials.

Why doesn't skill-distill let the skill include the finished output?

If the skill contains the answer, the student learns to copy rather than reason, and the test can pass for the wrong reason. A copied answer also breaks when the starting state changes slightly. The skill teaches the decisions that produce the output, so the approach transfers to variations of the task.

Do I need to install anything extra for web tasks?

Yes. For web results, install playwright and pillow with pip, then run playwright install chromium. The capture_web.py script uses headless Chromium to serve the app, drive it, and save screenshots and errors. Without those tools, screenshot checks will fail for reasons unrelated to the skill.

Skill distillation pays off when you treat your best session as a reusable asset, not a disposable chat. Try distilling one task this week for the student harness you already run, then run three trials and check where the first failure appears. Pass this to someone who keeps paying a frontier model to redo the same task every week.