amagi-democast
Make the demo GIF in your README from a real run of the commands in it, then fail CI when the tool's output stops matching the GIF. Pillow is the only dependency.
A README demo GIF goes stale the moment you rename a flag or reword an error. Nobody notices, because nothing checks it. amagi-democast reads the commands from a code block you mark in your README, runs them, draws the real output as a terminal GIF, and saves what each command printed next to the GIF. amagi-democast check runs them again and exits 1 with a diff when the output, an exit code or the GIF itself has changed.
Install
pipx install amagi-democast
Python 3.9 or newer. The one dependency is Pillow. No ffmpeg, ttyd, Go or Node.
Usage
Put a <!-- democast --> comment on the line above a code block of commands. GitHub does not render the comment, so readers see a normal code block:
<!-- democast -->
```console
$ mytool --help
$ mytool run example.txt
```
Then, from the folder with the README:
amagi-democast record # run the commands, write assets/demo.gif and assets/demo.democast.json
amagi-democast check # run them again; exit 1 if anything drifted
amagi-democast list # show the marked blocks and their commands
The GIF at the top of this page was made by amagi-democast record from this block in this README:
$ amagi-democast list examples/greet
$ amagi-democast check examples/greet
$ amagi-democast check examples/drifted
Real output of those three commands:
$ amagi-democast list examples/greet
block 1 (line 7)
$ python greet.py Ada
$ python greet.py Ada --shout
$ python greet.py
$ amagi-democast check examples/greet
OK 3 commands in examples/greet/README.md still match examples/greet/assets/demo.gif
$ amagi-democast check examples/drifted
DRIFT the demo GIF no longer matches what the commands print (2 problems)
- step 1 `python greet.py Ada`: output changed
--- in the GIF
+++ now
@@ -1 +1 @@
-Hello, Ada!
+Hi there, Ada.
- step 2 `python greet.py Ada --shout`: output changed
--- in the GIF
+++ now
@@ -1 +1 @@
-HELLO, ADA!
+HI THERE, ADA.
Fix: run `amagi-democast record` and commit the new GIF, or revert the change.
examples/drifted is a copy of examples/greet that was recorded, after which its greeting was changed from Hello, Ada! to Hi there, Ada. without recording again. That is the stale-GIF case check exists to catch.
Exit codes: 0 everything matches, 1 drift (or no recording yet), 2 usage error, such as a README with no marked block.
In CI
- run: pipx install amagi-democast
- run: amagi-democast check
Run check on the same operating system you recorded on, since command output often differs between Windows and Linux.
Options
| Option | What it does |
|---|---|
README |
Markdown file or folder to read (default README.md) |
-o, --output GIF |
Where the GIF goes (default assets/demo.gif next to the README). The sidecar is <name>.democast.json beside it. |
--ignore REGEX |
Text matching REGEX is treated as equal when checking, for timings, dates and temp paths. Repeatable. |
--timeout S |
Seconds each command may run (default 60). A timeout is shown in the GIF as exit code 124. |
--cols N |
Terminal width in characters (default 100). Long lines wrap. |
--rows N |
Terminal height for record (default: fit the output, 8 to 28 lines). Longer output scrolls. |
--theme dark|light |
Colours for record |
--title TEXT |
Window title for record (default: the README's folder name) |
Per-block options go in the comment itself: <!-- democast cwd=examples timeout=120 ignore="took [0-9.]+s" -->. The cwd option is relative to the README.
How it works
- Find. Every fenced block with a
<!-- democast -->comment above it, in order. In a block with$lines, those lines are the commands and the rest is treated as sample output. Otherwise every non-empty line that is not a#comment is a command. Several marked blocks make one GIF. - Run. Each command runs through your shell in the README's folder, with
NO_COLOR=1andTERM=dumbso colour codes stay out. Stdout and stderr are both captured. A nonzero exit is shown in the GIF as[exit code N]and is not treated as a failure, because a demo often shows an error on purpose. - Draw. The command is typed out, the output appears, and the last frame holds. The font is Consolas, Menlo or DejaVu Sans Mono, whichever the machine has, or Pillow's built-in font if none is found. Frames are stored with their own durations, so pauses cost nothing.
- Save. The sidecar JSON holds each command, its output with colour codes stripped, its exit code, and the GIF's SHA-256.
- Check.
checkcompares the README's commands with the sidecar, runs them again, and compares output and exit codes after normalising line endings and trailing spaces. It does not redraw the GIF, because fonts differ between machines. It checks the GIF file against the recorded hash instead.
How it differs from vhs and asciinema
vhs records a GIF from a .tape script you write, and needs ttyd and ffmpeg. asciinema records a terminal session to its own cast format. Both make better-looking recordings. Neither tells you when a recording no longer matches the tool. amagi-democast takes its commands from the README itself and adds the check step, at the cost of a plainer animation: no real terminal emulator, no colours, no interactive programs.
Limits
- Commands run with your current
PATH, so install the tool or activate its venv before you record.recordwarns when a command is not found. - Commands run without a terminal attached. Programs that need one (full-screen apps, prompts, progress bars that redraw) show their non-interactive output or hang until
--timeout. - Colour is stripped. The GIF is drawn in one foreground colour, with nonzero exit codes in red.
- Commands run through
cmd.exeon Windows and/bin/shelsewhere, so write the block for the shell you record on. The example usespython, which may bepython3on Linux. checkcompares text, not pixels. Changing--cols,--themeor fonts does not count as drift until you record again.
If this saved you time
A star helps other people find it.
More from AmagiLabs
- amagilabs: other small open source dev tools from the same lab.
- amagi-hookguard: Claude Code hooks that block
rm -rf ~, force pushes and.envreads. - amagi-docleak: checks a file you are about to send for tracked changes, metadata and badly redacted text.
- amagi-legal-review-skills: Claude Code skills for contract and lease review.
License
MIT, see LICENSE. Copyright (c) 2026 Amagisolutionsgroup, Inc. (AmagiLabs)
Metadata
Release files for amagi-democast 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| amagi_democast-0.1.0.tar.gz | 20.0 kB | Without provenance | Details for amagi_democast-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| amagi_democast-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for amagi_democast-0.1.0-py3-none-any.whl |
Total release size: 36.4 kB
Release files / amagi_democast-0.1.0.tar.gz
| Download URL | amagi_democast-0.1.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c33d4c6a2eccc8252874333de1fa17e7546950c6f344aaba4ac5753aaf9e8ad6
|
|
BLAKE2b-256 checksum How to use checksums |
af58a22bd4643343fbc3aff85a20820e7533e251580200c64cb689af73d55614
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / amagi_democast-0.1.0-py3-none-any.whl
| Download URL | amagi_democast-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
506ef5c998d4de910385138054d0fb766cfd882b1d28fb5e733c2a579d362cf5
|
|
BLAKE2b-256 checksum How to use checksums |
8c26ebecfdd1b44c648c348dca33e9627d636b4e394e5622e062ce767cbd25b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for amagi-democast 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.