Open Source • PolyForm Shield 1.0.0

Books to Agent Context, One Command

Compact technical books, docs, and references into agent-optimized markdown. Template-driven AI compaction with incremental updates. Works with Claude, GPT, and Codex.

4
Built-in Templates
6
Source Types
Go
Single Binary

Turn 400-page books into 4000-token agent context

Template-driven compaction that produces consistent, structured output every time

Rules
Numbered Imperatives
Principles
Chapter-Based
Patterns
Problem / Solution
Incremental
Content Hashing

Built for Agent-Driven Development

Every feature exists to make agent context production repeatable and maintainable

Template-Driven Compaction

Four built-in templates (rules, principles, patterns, raw) enforce consistent output structure. Custom templates supported via markdown files.

Multi-Source Ingestion

Read from PDFs, markdown files, Notion pages, web URLs, EPUBs, and GitHub repos. All normalized into uniform chunks.

Content Hashing

SHA-256 tracks source content, template, and agent identity. Changed sources are re-compacted automatically. Unchanged sources are skipped.

Pluggable Agents

Claude CLI, Codex CLI, Anthropic API, and OpenAI API. Same interface, swap with --agent. Claude CLI is zero-config default.

Hierarchical Indexes

Auto-generated index.md files at every level. Agents know what to load and when — no token waste from loading everything.

Incremental Updates

distill update skips clean sources. Improve a template? All sources using it are automatically re-compacted.

Chapter Splitting

Split books by chapter with split_by: chapter. Each chapter becomes a separate output file with its own entry in the index.

Precedence Control

Configure priority order for subdirectories. Org-specific principles override framework guidelines, which override reference books.

Publish + Install

distill publish pushes to a context repo. distill install clones it into ~/.claude/docs/. Full producer → consumer pipeline.

Single Binary CLI

Written in Go with Cobra. Cross-compiles to macOS and Linux. Install via go install, Homebrew, or GitHub Release.

How It Works

Three steps from source material to agent context

1

Add a Source

Point distill at a PDF, markdown file, Notion page, or URL. Choose a compaction template (rules, principles, patterns, or raw).

2

Compact

Run distill <name>. The AI reads the source, applies the template, and writes agent-optimized markdown to your output directory.

3

Use It

Output plugs directly into ~/.claude/docs/, Cursor rules, or any agent that reads markdown. Hierarchical indexes guide selective loading.

Code Examples

See distill in action — CLI commands, configuration, and output format

bash
# Add a source and compact it
$ distill add pdf ~/Books/tao-of-react.pdf \
    --name tao-of-react --template rules --output-dir tao
✓ Added source "tao-of-react" (pdf)

$ distill tao-of-react
→ source:   tao-of-react (pdf)
→ template: rules
→ agent:    claude-cli (sonnet)
→ Compacting (1 chunk)...

✓ Compaction complete.
→ tokens:  2847 (budget: 4000)
→ output:  ./output/tao/tao-of-react-minified.md

# Re-compact everything after improving a template
$ distill update --force
→ Re-compacting 4 sources...
4 sources updated.

# List tracked sources
$ distill list
  tao-of-react    pdf     rules     tao/     2847 tok   ✓ current
  ddia            pdf     principles ddia/   -          ✗ not yet

# Install a shared context repo for agents
$ distill install https://github.com/myteam/context.git
✓ Context repo installed at ~/.claude/docs/

Use Cases

distill turns any technical knowledge into agent-ready context

Framework Guides

Compact Tao of React, Tao of Node, or any framework guide into numbered rules your agents follow when writing code.

Architecture Books

Distill DDIA, Clean Architecture, or domain-driven design books into chapter-based principles for data and system design decisions.

Internal Style Guides

Turn your team's coding conventions doc into agent-readable rules. Agents produce code that matches your patterns.

Shared Team Context

Publish compacted docs to a shared git repo. Every teammate's agent loads the same rules — consistent AI behavior across the team.

Living Documentation

When source material updates or you improve a template, distill update re-compacts automatically. Context stays current.

Design Pattern References

Extract named patterns (Problem/Solution/Rationale) from pattern catalogs. Agents apply the right pattern for the right situation.

Quick Start

Install distill and compact your first source in under a minute

1. Install

bash
go install github.com/smeltery/distill@latest

2. Compact

bash
# Initialize config
distill config init

# Add a source
distill add pdf ~/Books/tao-of-react.pdf \
  --name tao-of-react --template rules

# Compact it
distill tao-of-react

# Check agents
distill agents

Tip: The default agent is claude-cli — no API key needed if you have Claude Code installed.

Technical Paper

The Design Behind distill

A deep-dive into the four technical contributions that make repeatable knowledge compaction possible

Technical Paper

distill: A Template-Driven Knowledge Compaction Pipeline for AI Agents

Nicholas Adamou — smeltery

AI agents are constrained by their context windows. Technical books contain critical guidance but at 200-600 pages they are too verbose to load. This paper presents distill and the four design decisions that make knowledge compaction repeatable, consistent, and cheap to maintain.

Read the Paper
(1)

Template-Driven Compaction

Four built-in output formats enforce consistent structure across heterogeneous source material. Custom templates supported.

(2)

Multi-Source Ingestion

Reads from PDFs, markdown, Notion, web URLs, EPUBs, and GitHub repos — all normalized into uniform text chunks.

(3)

Content-Hashing State Tracker

SHA-256 tracks source, template, and agent identity. Changed inputs trigger re-compaction; unchanged sources are skipped.

(4)

Pluggable Agent Architecture

CLI-based (Claude, Codex) and API-based (Anthropic, OpenAI) providers with the same registry pattern as prr.