
literate-guide
Create a narrative guide to a codebase or feature in the style of Knuth's Literate Programming — code and prose interwoven as a single essay, ordered for human understanding rather than compiler needs. Use when the user asks to 'explain this codebase as a story', 'write a literate guide', 'create a narrative walkthrough', 'tell the story of this code', 'Knuth-style documentation', 'weave a guide for this feature', or when they want deep, readable documentation that treats the program as literature. Also trigger when someone wants a document that a thoughtful reader could follow from start to finish and come away understanding both WHAT the code does and WHY every design choice was made.
- Installs
- 118
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/petekp/claude-code-setup --skill literate-guide- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads literate-guide automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Literate Guide
Create a guide that tells the story of a codebase or feature the way Knuth intended programs to be read: as literature. The output is a single narrative essay where code excerpts and prose are interwoven, ordered by the logic of human understanding rather than file layout or execution order.
The Idea Behind This
Knuth's core observation was simple: programs are read far more often than they are written, yet we organize them for the compiler's convenience, not the reader's. A literate program reverses this — the author decides the order of presentation based on what a human needs to understand first, and the code appears within that narrative exactly where it becomes relevant.
For an existing codebase, this means:
- Don't follow the file tree. Follow the conceptual thread. Start where understanding starts, not where
main()lives. - Each section introduces one idea, shows the code that embodies it, and explains the reasoning behind the design. Sections are numbered with the section sign:
§1,§2,§3... (that's the§character, U+00A7 — not the letter "S"). Sections cross-reference each other using this same notation. - The prose does the heavy lifting. Code excerpts are windows into the implementation, not the primary content. A reader should be able to follow the narrative even if they skip over the code blocks.
- Design decisions are first-class content. "We use X instead of Y because..." is the heartbeat of a literate guide. Alternatives considered, tradeoffs accepted, constraints that shaped the design — these are what make the document valuable long after the code has changed.
Workflow
Step 1: Understand the Scope
Ask the user what they want the guide to cover:
question: "What should this literate guide cover?"
header: "Scope"
options:
- label: "Entire codebase"
description: "The full story of this project, end to end"
- label: "A specific feature or subsystem"
description: "Deep narrative on one part of the codebase"
- label: "A recent change or PR"
description: "The story of a specific set of changes and why they were made"
If they choose a feature or subsystem, clarify which one. If the codebase is large (50+ files), strongly recommend scoping to a subsystem — a good literate guide goes deep, and breadth dilutes that.
Also ask about audience:
question: "Who will read this?"
header: "Audience"
options:
- label: "A developer joining the team"
description: "Assumes general programming knowledge, no project-specific context"
- label: "A senior engineer reviewing the architecture"
description: "Assumes deep technical knowledge, wants to understand design rationale"
- label: "Future me"
description: "Personal documentation for a system I'll forget the details of"
- label: "Open source contributors"
description: "External developers who want to understand the project well enough to contribute"
Step 2: Deep Reading
Read the codebase thoroughly. This isn't a skim — you're looking for the story. Investigate in this order:
- The problem — What does this software exist to solve? Check README, docs, comments, commit messages, issue trackers.
- The domain model — What are the core abstractions? What do they represent in the real world?
- The architecture — How do the pieces fit together? What are the boundaries?
- The flows — Trace 2-3 primary operations end to end. These become narrative throughlines.
- The design decisions — Where are the interesting tradeoffs? Look for:
- Comments that explain "why" (not "what")
- Places where simpler approaches were avoided — there's usually a reason
- Abstractions that seem overbuilt — they often encode hard-won lessons
- Configuration and feature flags — they reveal the axes of variation the authors anticipated
- The history —
git logfor major refactors, pivots, or rewrites. These are plot points in the story.
Step 3: Find the Narrative Thread
Before writing, identify:
- The opening — What idea or problem should the reader encounter first? This is rarely the entry point of the code. It's the motivation: the problem that makes the rest of the code necessary.
- The arc — What's the natural progression of understanding? Usually: problem → domain → core abstraction → how it works → how edge cases are handled → how it connects to the rest of the system.
- The key decisions — 3-5 design choices that define the system's character. These are the moments in the narrative where you pause the code walkthrough and say "here's why."
- The sections — Break the narrative into numbered sections using the
§symbol:§1,§2, etc. (not "S1" or "Section 1" — the section sign§is a deliberate stylistic choice from Knuth's TeX tradition). Each section should have a name that describes the idea, not the file. "§4. Why events, not callbacks" is better than "§4. The EventEmitter class."
Step 4: Write the Guide
Follow the template in references/guide-template.md. Key principles:
Voice and tone:
- Write in a warm, direct, first-person-plural voice ("we," "our"). The guide is a conversation between the author and the reader, not a specification.
- Be specific and concrete. "This handles edge cases" is empty. "This catches the case where a user submits a form twice before the first request completes" is useful.
- Embrace the author's perspective. Knuth didn't pretend to be objective — he explained what he was thinking and why. Do the same. "I chose X over Y because..." or "The team decided to..." with real reasons.
Code excerpts:
- Show only the code relevant to the point being made. Trim aggressively. If a function is 40 lines but the interesting part is 8 lines, show the 8 lines with a note about what the rest does.
- Always include the file path and line range above the code block so the reader can find it.
- Annotate the code. Don't just show it and move on — point out the significant details. "Notice that
retriesis passed as a parameter, not read from config. This makes testing deterministic (§12)." - Use cross-references (
§N) when code in one section relates to concepts explained in another.
Section structure:
- Open with prose that explains the idea and its motivation
- Show the relevant code
- Explain the design reasoning — alternatives considered, constraints, tradeoffs
- Close with a transition that connects to the next section. Every section ending should bridge to what comes next — this is what makes the guide read as a continuous narrative rather than a series of isolated entries. Examples: "With this normalization in place, we can now trust that the reducer (§7) receives clean input." or "This raises a question: how does the system handle the case where...? That's the subject of §9."
Cross-references:
- Use the
§symbol for all cross-references: "as we saw in §3", "this connects to the retry logic in §12", "the transport layer (§8) hides this complexity". The§symbol is load-bearing — it's the visual cue that tells the reader "this refers to another section in this document." - Cross-references are what make the document a web rather than a linear sequence. Use them generously — a good literate guide has at least 2-3 cross-references per section, weaving backward to reinforce earlier ideas and forward to foreshadow upcoming ones.
Diagrams:
- Include Mermaid diagrams where they aid understanding — typically one system-level overview near the beginning, and sequence diagrams for complex flows
- Diagrams supplement the prose; they don't replace it
Step 5: Review the Draft
Before delivering, read the guide as if you've never seen the codebase:
- Does it tell a story? Can you follow the narrative from §1 to the end without getting lost? If any section feels like a non sequitur, it needs a better transition or should be reordered.
- Is every code excerpt earning its place? If a code block could be removed without losing understanding, remove it. Each excerpt should illustrate a specific point made in the surrounding prose.
- Are the design decisions explicit? The guide should answer "why" at least as often as "how." If you find yourself describing mechanics without motivation, pause and add the reasoning.
- Are the cross-references correct? Every
§Nreference should point to the right section. A broken cross-reference in a literate guide is like a broken hyperlink — it undermines the web of understanding. - Would Knuth approve? This is tongue-in-cheek, but useful: Knuth's literate programs read like essays by a thoughtful author explaining their craft. If the guide reads like generated documentation, revise until it sounds like a person talking to another person about something they care about.
Step 6: Deliver
Write the guide as a single Markdown file. Suggested locations:
.claude/docs/literate-guide.mdfor the full codebase.claude/docs/literate-guide-{feature}.mdfor a feature-specific guide
Tell the user what you've written and where it is. Mention the section count and the major themes covered so they know what to expect.
FAQ
What does the literate-guide skill do?
Create a narrative guide to a codebase or feature in the style of Knuth's Literate Programming — code and prose interwoven as a single essay, ordered for human understanding rather than compiler needs. Use when the user asks to 'explain this codebase as a story', 'write a literate guide', 'create a narrative walkthrough', 'tell the story of this code', 'Knuth-style documentation', 'weave a guide for this feature', or when they want deep, readable documentation that treats the program as literature. Also trigger when someone wants a document that a thoughtful reader could follow from start to finish and come away understanding both WHAT the code does and WHY every design choice was made.
How do I install literate-guide?
Run npx skills add https://github.com/petekp/claude-code-setup --skill literate-guide in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/literate-guide/ (personal) or .claude/skills/literate-guide/ (project).
Which AI agents can use literate-guide?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is literate-guide safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains literate-guide?
It is published by petekp in petekp/claude-code-setup. It has 118 recorded installs.
More from petekp/claude-code-setup
code-comments
petekp/claude-code-setup
Write, review, or remove code comments. Use when adding comments or doc comments, reviewing the comments in a diff, or cleaning up or removing comments.
deep-research
petekp/claude-code-setup
Investigate a question that requires sustained research across sources and produce cited findings. Use for deep research requests; skip ordinary lookups and single-document reviews.
exhaustive-systems-analysis
petekp/claude-code-setup
Open the skill to read its SKILL.md instructions.
typography
petekp/claude-code-setup
Open the skill to read its SKILL.md instructions.
claude-code-audit
petekp/claude-code-setup
Forensic audit of the user's recent Claude Code sessions to surface step-change workflow improvements — not marginal ones. Use when the user asks to "audit my Claude Code sessions", "analyze how I use Claude Code", "find patterns in my usage", "improve my Claude Code workflow", "review my sessions", "find leverage in my setup", or wants to understand where their Claude Code setup is leaking time. Samples dozens of real transcripts, extracts quantitative signal via scripts, uses parallel subagents for deep reads, then synthesizes into a short prioritized report with drafted implementations (new skills, CLAUDE.md rules, hooks, settings diffs) that the user can install directly. Trigger even when the user doesn't say the word "audit" — if they're asking about improving or reviewing their Claude Code habits at scale, use this skill.
catch-up
petekp/claude-code-setup
Give the human a fast, plain-English catch-up on what changed in the project: what the agents did, why, and what decisions need their input. Use when the user asks to "catch me up", "what changed", "where are we", "recap", "brief me", "give me the rundown", "what did you do", "summarize the session", or "fill me in", or otherwise wants to get back up to speed after being away.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.