Checks that every code block in a Gleam project's docs matches a tested snippet file.
dream_snippets
A code block with no tested snippet can be wrong, and nobody finds out until a reader tries it. dream_snippets is the check that every Dream repository runs in CI to stop that: each Gleam code block in the README, the guides and the doc comments must be a copy of a snippet file that the tests compile and run. It works in any Gleam project on GitHub.
Sent here by a "not in the exact format" message? Copy the heading and badges from Copy a badge in the Tested code blocks guide.
Features
- ✅ Proves every fenced code block in Markdown docs and in
///and////doc comments, each in the way that fits its kind, and skips none in silence - ✅ Checks each
gleamblock in Markdown docs and in///and////doc comments - ✅ Compares the block with the linked snippet file, or a line range of it, byte for byte
- ✅ Checks that each README example links to the guide section that shows it
- ✅ Compares each file, command and output block with the file that the tests or CI use, from the
tested_filessetting - ✅ Proves
gleam addlines andtomldependency lines withgleam.toml, with no file - ✅ Counts the blocks marked as an illustration, and finds Gleam code hidden in them
- ✅ Checks
diffblocks against the realgit difffrom a release tag - ✅ Checks code at an older release against the file at that release tag
- ✅ Checks the release notes and changelog sections of an older release against the files at its tag, so a version bump needs no change to them
- ✅ Checks that release notes follow the release notes template
- ✅ Reads the repository and the release tag from
gleam.toml, so it needs no setup - ✅ No network access
Installation
gleam add --dev dream_snippets
Quick Start
Run the check from the project root:
Run the check

gleam run -m dream_snippets
It prints one line for each problem and a summary line, and it stops with exit code 1 when it finds a problem. The same check is one Gleam call:
Check a project and read what the command prints

import dream_snippets
pub fn summary_of(directory: String) -> List(String) {
let output = dream_snippets.output(dream_snippets.check_project(directory))
output.standard_output
}
Guides
- Getting started: prove the code examples of a project, from the first snippet to the check in CI
- Tested code blocks: every badge to copy, line ranges, doc comments, README examples and their guide badge
- Fix a failed check: each message the check prints, what it means, and the fix
- Show an API change in an upgrade guide: diff blocks and code at an older release, proven against git
- Release notes template: write release notes that follow the template, with a complete example
- Use it from Gleam: run the check from your tests or your own tools
- Settings and checks reference: every setting with its default, and every check
Design Principles
dream_snippets follows Dream's design principles and contributing guide.
About Dream
This package was first built inside the Dream web toolkit, as the check behind its tested docs. It is standalone and can be used in any Gleam project. It follows Dream's design principles and will be maintained as part of the Dream ecosystem.
Contributing
See the Contributing Guide for guidelines.
License
MIT — see LICENSE.md