Drop into any repo. Tell your AI agent one sentence. Get a license-clean, minimal, tested local re-implementation of a narrow library function — or a bounded framework capability — without copying the upstream code.
A drop-in directory of prompts, templates, references, and scripts that turns a coding agent (Claude Code, Codex, or any AGENTS.md-compatible agent) into a disciplined distiller. v2.0 ships two modes:
| Mode | Unit of reuse | Use when | Required proof |
|---|---|---|---|
| Function (Mode A) | one function/module | pure / local behavior; no external protocol; no state | contract + invariants + tests |
| Framework Function (Mode B) | function inside a framework lifecycle | config/hook/env/file layout matters; one entry point | contract + lifecycle context + protocol surface + side-effect invariants + tests |
| Capability (Mode C) | bounded subsystem | adapters / state machine / async / external processes / drift risk | boundary + protocol + state machine + adapters + fixtures + conformance tests + drift policy |
The unit of reuse is not a library.
For narrow code, it is a verified function contract. For framework capabilities, it is a verified behavior protocol.
Function = contract + mechanism + invariants + tests Framework Function = contract + lifecycle context + protocol surface + side-effect invariants + tests Capability = boundary + protocol + state machine + adapters + fixtures + conformance tests + drift policy
The kit ships two skills: function-distiller (Modes A/B) and capability-distiller (Mode C). Mode is decided in Gate 0 via prompts/11_mode_selection.md; the lint and scaffolder are mode-aware so simple targets stay simple.
# 1. install into your repo (one command, idempotent)
curl -fsSL https://raw.githubusercontent.com/AlexAnys/function-distiller-agent-kit/main/install.sh \
| FDK_REPO=AlexAnys/function-distiller-agent-kit bash
# 2. open Claude Code (or Codex) in the same directory
# 3. paste the brief from "TL;DR — for agents" belowReplace
AlexAnys/function-distiller-agent-kitwith the GitHub path you publish this kit at. The kit ships with everything needed to be the source repo for that URL — see "Publish to your GitHub" below.
What this gives you in your repo afterwards:
.claude/skills/function-distiller/ # Claude Code picks this up automatically
.agents/skills/function-distiller/ # Codex picks this up automatically
AGENTS.md # workflow rules, read by both agents
prompts/ templates/ references/ # the actual workflow content
scripts/ # preflight, lint, workspace generator, etc.
examples/markdown-table-parser/ # a complete worked end-to-end example
tests/ # 20 self-tests — run with `make ci`
Paste this into Claude Code (or Codex) in any repo. The agent will install the kit, learn the workflow, and stop ready for your task brief. No prior setup required.
Install the Function Distiller Agent Kit and learn its workflow.
Steps you will execute:
1. Run:
curl -fsSL https://raw.githubusercontent.com/AlexAnys/function-distiller-agent-kit/main/install.sh \
| FDK_REPO=AlexAnys/function-distiller-agent-kit FDK_SKIP_CI=1 bash
2. Read AGENTS.md and .claude/skills/function-distiller/SKILL.md (or
.agents/skills/function-distiller/SKILL.md if you are Codex).
3. Read docs/USAGE.md and references/distillation-principles.md.
4. Run `python3 scripts/preflight.py` and report the result.
5. Stop and ask me for the target brief. Do NOT proceed to research,
slice, spec, or implementation until I give you:
- target repo
- target capability
- local use case
- non-goals
- main motivation (dependency removal / performance / simplicity / learning)
When I do give you the brief, follow the workflow gates strictly:
Triage → Research → Slice → Spec → (human approval) → Implement → Verify → Review.
Never implement before slice-report.md and functional-spec.md exist and are
approved by me.
(For Codex, replace the .claude/skills/... path with .agents/skills/....)
That's it. The agent installs the kit, reads the rules, runs preflight, and waits for instructions.
Gate 0 Triage GO / SPIKE / NO-GO
Gate 1 Research DeepWiki + source verification + tests/docs
Gate 2 Slice slice-report.md (API, call graph, accidental complexity, hidden invariants)
Gate 3 Spec functional-spec.md (behavior, errors, oracle, non-goals) ← human gate
Gate 4 Implement original, minimal, project-style, no source copy
Gate 5 Verify contract + differential + edge + property + benchmark tests
Gate 6 Review verification-report.md + license + security + maintenance plan
Each gate has a prompt in prompts/ and a template in templates/. References under references/ document the principles each gate enforces. scripts/lint_distillation.py is a CI-ready gate that fails if any artifact is missing, decisions are absent, stub tests are still in the suite, or closed-source role separation is undocumented.
A successful run leaves you with:
.distillations/<target>/target-brief.yaml
.distillations/<target>/research-notes.md
.distillations/<target>/slice-report.md
.distillations/<target>/functional-spec.md
.distillations/<target>/implementation-plan.md
.distillations/<target>/verification-report.md
.distillations/<target>/risk-register.md
src/<local_module>.*
tests/test_<local_module>_{contract,differential,edge,property}.*
examples/markdown-table-parser/ is a fully runnable, 218-test distillation that replaces a 2.5 MB markdown library with a 70-line GFM table parser. To see the workflow in action:
cd examples/markdown-table-parser
python3 -m pytest -q # 218 passedRead examples/markdown-table-parser/distillation/ to see what every gate's artifact looks like in a real run.
# from a local checkout of this repo
cd /your/target/repo
bash /path/to/function-distiller-agent-kit/install.sh
# or even more manual:
mkdir -p .claude/skills .agents/skills
cp -R /path/to/kit/skills/claude-code/function-distiller .claude/skills/
cp -R /path/to/kit/skills/codex/function-distiller .agents/skills/
cp /path/to/kit/AGENTS.md ./AGENTS.md
ln -s /path/to/kit/templates . # or copy
ln -s /path/to/kit/references .
ln -s /path/to/kit/prompts .
ln -s /path/to/kit/scripts .
make ci # verifyOr, install from the bundled release zip (also shipped in dist/):
unzip function-distiller-agent-kit-1.2.0.zip -d ./_kit
bash ./_kit/install.shThis kit is published as a self-contained directory plus an install.sh. To make the curl | bash flow work, push this kit's contents to a GitHub repo:
# from inside the kit directory
cd improved-kit/ # or the unpacked dist/ zip
git init
git add .
git commit -m "function-distiller-agent-kit v1.2.0"
gh repo create AlexAnys/function-distiller-agent-kit --public --source=. --pushAfter push, the install URL becomes:
curl -fsSL https://raw.githubusercontent.com/AlexAnys/function-distiller-agent-kit/main/install.sh \
| FDK_REPO=AlexAnys/function-distiller-agent-kit bashYou can then paste that URL into your team docs, agent prompts, or CI scripts. The kit is MIT-licensed (see LICENSE), so you can fork freely; only the upstream code you study with the kit must respect its license.
README.md # this file
LICENSE # MIT — kit only, NOT upstream code studied
CHANGELOG.md # version history
AGENTS.md # bootstrap rules for AGENTS.md-compatible agents
INSTALL.md # detailed install options
Makefile # `make ci` runs the full verify suite
install.sh # one-shot installer (curl-able)
kit_manifest.json # full file list + sha256 for tamper detection
docs/
USAGE.md # full usage guide (humans + agents)
ONE_PAGE_PLAYBOOK.md
REVIEWED-METHOD.md
CLOSED_SOURCE_GUARDS.md # concrete allowed-vs-forbidden examples
IMPROVEMENT_BACKLOG.md # roadmap for v1.3+
prompts/ # 11 step-by-step agent prompts
00_target_brief.md ... 10_subagent_clean_room_implementer.md
templates/ # 12 canonical templates (single source of truth)
references/ # principles, checklists, rubrics
scripts/
preflight.py # verify install (sha256 + size + undeclared)
make_distillation_workspace.py # scaffold .distillations/<target>/
lint_distillation.py # CI gate: artifacts + ordering + stubs + closed-source
distillation_index.py # write .distillations/INDEX.md
spec_to_test_stub.py # functional-spec.md → pytest skeleton (fails loudly)
import_usage.py / callgraph_static.py # Python source helpers
python_dep_footprint.py # dep size + transitive deps
benchmark_command.py # warm-up + median + p95 benchmark
compare_jsonl_outputs.py # tolerant JSONL diff for differential tests
clone_and_scan.sh # gh / git clone + ripgrep one-shot
examples/markdown-table-parser/ # COMPLETE end-to-end worked example
tests/ # kit's own regression tests (run with `make ci`)
skills/claude-code/function-distiller/ # Claude Code skill source
skills/codex/function-distiller/ # Codex skill source
This kit is not a license to copy upstream code.
- Open-source target: study and re-implement. Honor the upstream license. Do not copy comments, file structure, or non-API names.
- Closed-source / contract-restricted target: observation only. Public docs, public APIs, authorized inputs/outputs. No decompilation, no leaked code, no NDA material, no bypassed access controls. Use
prompts/08_closed_source_clean_room.mdand the role separation inreferences/closed-source-clean-room.md. - Security / cryptography / payment / authentication / medical / legal critical paths: stop. These need human review beyond what an agent kit can provide.
When in doubt, mark NO-GO and explain alternatives.
Every time you finish a real distillation, append to your repo's iteration-log.md (template in this kit's parent folder). Open issues against docs/IMPROVEMENT_BACKLOG.md. Bump kit_manifest.json version + regenerate sha256s + update CHANGELOG.md. Run python3 scripts/preflight.py to confirm nothing was lost.
The protocol compounds: each distillation strengthens the kit, not just the project that needed it.
make ci
# preflight → 81 declared files, sha256 verified
# selftest → 20 regression tests, all green
# example → 218 example tests, all greenIf any of those is red, the kit is not fit to ship. The point of make ci is to be a single boolean: green = good to use.