Skill-Distill Turns Claude's Agent Traces Into Cheap Local AI Playbooks
A new open-source skill turns a successful Claude Code or Codex session into a reusable instruction manual that a local open-weight model can execute.
Takeaways
- skill-distill turns a successful Claude Code or Codex session into a reusable SKILL.md for open-weight models.
- A teacher-student loop drafts, tests in tmux, and patches the skill until three trials match the reference output.
- Ships adapters for omp, Codex, Claude Code, pi, and opencode; omp is the most battle-tested.
- Includes Playwright-based web capture so frontend tasks can be verified with screenshots and console errors.
- Install via git clone plus a symlink into
~/.claude/skills/or~/.agents/skills/; MIT licensed. - Frontier model is paid once to do the task and once to teach; subsequent runs stay fully local.
Skill-distill converts a completed coding-agent session into reusable instructions for a cheaper model. A frontier model such as Claude Opus or Codex reviews the session trace, which records prompts, tool calls, and outputs, then writes a task-specific SKILL.md. It runs an open-weight model against a clean copy of the same task and revises the instructions based on the result.
The repository packages this workflow as an Agent Skill. It targets recurring, well-specified work that teams want to move onto hardware they control. Repeated executions can remain local after distillation, although the original run and teacher-led revisions still use the configured model provider. Teams handling sensitive data should inspect session traces for secrets before sending them to a cloud-hosted teacher.
The loop: teach, run, compare, repair
Claude Code or Codex serves as the teacher, while a local agent harness serves as the student. The harness supplies the command-line tools and execution environment around the target model, such as omp running DeepSeek-V4.1-Flash. The repository’s distillation instructions define the following loop:
- The teacher reads the original prompt, starting state, successful session trace, and reference output.
- It drafts a skill containing the steps, decisions, checks, and likely failure points the student needs.
- An adapter launches the student under
tmuxwith the original prompt, generated skill, and a fresh copy of the starting state. - The evaluator compares the student’s files and other outputs with the reference, including screenshots and console errors for supported web tasks.
- The teacher finds the earliest meaningful divergence, revises the skill, and repeats the evaluation.
The repository’s operator skill remains reusable across distillation jobs. Each job produces a skill scoped to a particular task, model, and harness, along with the evidence collected during its trials. A human reviewer sees the reference and student outputs side by side and decides whether to accept the result.
Guardrails against false passes
- Context isolation: The student receives the reference prompt verbatim and a clean starting state. Global context files and unrelated skills are disabled where the harness permits it.
- Answer-leak prevention: The generated skill cannot embed the finished reference output or invoke a script that reproduces it. Brief snippets are reserved for details the student repeatedly fails to generate.
- Reference-calibrated checks: Every validator must pass against the reference output before it can judge the student. A failing reference check indicates a faulty test.
- Repeated trials: Each candidate skill runs three times, reducing the chance that a favorable stochastic result passes as stable behavior.
- Human approval: The workflow records evidence and verdicts, but only the reviewer can mark a skill as accepted.
A compact stack with uneven adapters
The implementation consists of a few Python scripts and harness-specific adapters:
| Component | Responsibility |
|---|---|
scripts/distill.py |
Manages runs through commands including init, trial, status, evidence, verdict, ledger, and accept. |
scripts/extract_session.py |
Converts Claude Code, Codex, or omp logs into readable references while removing system prompts and AGENTS.md content. |
scripts/capture_web.py |
Uses Playwright and headless Chromium to serve and operate web apps, then records screenshots and console errors. |
adapters/ |
Contains launch scripts for omp, pi, Codex, Claude Code, and opencode. |
One tested student path
| Harness | Current status | Configuration notes |
|---|---|---|
omp |
Tested | Provides the repository’s established student path. |
| Codex | Works as a teacher | Student use requires a provider configured through STUDENT_ARGS. |
| Claude Code | Adapter written | Open models require ANTHROPIC_BASE_URL to point to an Anthropic-compatible server. |
pi |
Written but untested | Requires validation before production use. |
| opencode | Written but untested | extract_session.py lacks a parser for its JSON log format. |
Installation consists of cloning the repository and symlinking its operator skill into ~/.claude/skills/ or ~/.agents/skills/. The core workflow requires tmux, git, Python 3.10 or later, and a supported student harness. Web evaluation adds Playwright and Chromium. The project uses the MIT license.
A clean working copy preserves experimental state between trials. Process and network isolation require a separate container or virtual machine when the student will execute untrusted code.
SKILL.md provides the portability layer
An Agent Skill is a folder containing a SKILL.md file with instructions and metadata. Claude loads a skill when its description matches the current task, keeping specialized guidance out of unrelated sessions.
Anthropic published the format as an open standard, and several coding agents recognize the same directory structure. Skill-distill therefore emits an ordinary skill directory that compatible harnesses can consume. Actual portability still depends on each harness’s adapter, tool permissions, context handling, and session-log parser.
Stable tasks set the boundary
Skill-distill performs task-level procedural distillation while leaving model weights unchanged. The teacher encodes one successful trajectory as explicit steps, decisions, failure checks, and verification commands, then repairs those instructions when the student diverges. Cloud inference costs accrue during the original task and every teacher revision; accepted repeat runs can use the local target model.
Recurring tasks with stable inputs, deterministic checks, and clear outputs provide the strongest candidates. Shifting requirements, subjective results, broad exploration, and hidden environmental dependencies require larger evaluation sets and more supervision. Three trials estimate run-to-run stability for one prompt, model, harness, and starting state. Transfer to new tasks, repositories, or models requires separate testing.