litprog-skill

Literate programming skill for agent harnesses like Claude Code, OpenCode and Hermes Agent

β˜… 91 TypeScript Updated 4/10/2026
View on GitHub β†’

Literate Programming Skill for Claude Code

A Claude Code skill that transforms codebases into literate programs. These are documents written for human comprehension that also generate the original source code.

What is Literate Programming?

Literate programming was invented by Donald Knuth in 1984. Knuth is the author of The Art of Computer Programming, creator of TeX, and winner of the 1974 Turing Award. He introduced literate programming as a paradigm where programs are written as essays for human readers, with code embedded in a narrative.

A literate program produces two outputs:

The key insight: present code in psychological order. That is, the order that makes it easiest to understand, not the order the compiler needs.

What This Skill Does

Installation

Copy SKILL.md into your project's .claude/skills/ directory:

git clone https://github.com/tlehman/litprog-skill.git
mkdir -p your-project/.claude/skills/
cp litprog-skill/SKILL.md your-project/.claude/skills/literate-programming.md

Claude Code automatically discovers skills from .claude/skills/ in your project root. After copying, the /literate-programming slash command will be available in any Claude Code session within that project.

Usage

Create a literate program

Ask Claude to create a literate program from your codebase:

/literate-programming

Claude will analyze your code, determine the best narrative order, and produce a .lit.md file with prose, diagrams, and named code chunks.

If a .lit.md already exists, running /literate-programming will just tangle and weave the existing file without recreating it.

Reverse-sync (automatic)

After creation, a PostToolUse hook is configured so that when you edit a source file directly, the changes are automatically synced back into the .lit.md and re-tangled. This keeps the .lit.md as the single source of truth.

The hook does NOT regenerate the PDF on every edit. To regenerate the PDF, run /literate-programming again.

Tangle (extract source code)

bun run scripts/tangle.ts project.lit.md --output-dir ./src/

This expands all root chunks and writes the source files. Verify by diffing against the original source.

Weave (generate PDF)

pandoc project.lit.md \
  -o project.pdf \
  --pdf-engine=xelatex \
  --filter mermaid-filter \
  --toc \
  --number-sections

Prerequisites for weave: pandoc, xelatex, mermaid-filter

For setup instructions, see references/pandoc-setup.md.

Why Use This?