Mojo Cheat Sheets
Documentsmojo-cheat-sheetsMojo Cheat Sheets is an Agent Skill for documents published in the modular/modular repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Build and update a Mojo language cheat sheet in this folder. Use when editing a card's content, adding a card, or rebuilding its PDF/PNG/SVG outputs.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/modular/modular/blob/HEAD/mojo/docs/cheatsheet-tooling/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/mojo-cheat-sheets, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Update a Mojo cheat sheet
One-page reference cards for the Mojo language, rendered from HTML sources to PDF, PNG, and SVG (light + dark). Use this skill to update an existing card or add a new one.
Where things are
src/body-<topic>.html— the content of one card; this is what you edit.src/_head.html,src/_foot.html— shared CSS, palette, header.bin/build.py— assembles a card and renders all formats. It discovers cards from the body files present; there is no card list to edit.dist/— produced files. Generated; never edit by hand.
Workflow
-
Anchor to the reference. Every behavioral claim on a card must match the Mojo reference docs under
mojo/docs/reference/, or a short program you compile to confirm it. Do not rely on memory or older syntax. -
One card at a time.
-
Edit the source, never the output. Change
src/body-<topic>.html. -
A card's title, subtitle, and optional layout live in comment lines at the top of its body file:
<!-- title: ... --> <!-- subtitle: ... --> <!-- layout: portrait | landscape --> # optional; default portraitportraitis 2 columns / ~900px;landscapeis 3 columns / ~1100px. Fine-tune with<!-- columns: N -->and<!-- width: W -->. -
Rebuild and look:
python3 bin/build.py <topic>, then opendist/mojo-cheat-sheet-<topic>-light.png. -
Compiler-check new claims with a tiny snippet before asserting them.
-
Discuss restructuring a card or adding a new one before doing it.
Conventions
- Each card stands alone. No cross-references between cards.
- One space before a trailing
#comment; keep all trailing comments. - No em-dashes in prose.
- Keep code lines short enough not to wrap.
- Current Mojo syntax only:
def(nofn),comptime(notalias),read/mut/out/var/refconventions,t"..."template strings. - The legend on each card is a fixed full palette, identical across all cards; it is generated by the build, not maintained by hand.
Build everything
python3 bin/build.py all rebuilds every card present and the combined PDFs.
The build shrinks SVGs with svgo so they stay under the repo's 2 MB file cap.
Required tools
See README.md.