Writing Cheats
A cheat is a Markdown heading followed by a fenced code block. CheatMD parses the heading as the cheat’s title and the code block as the command template.
Minimal cheat
## Docker: list containers
```sh title:"Show all running containers"
docker ps
``` - The
##heading becomes the cheat’s searchable title. - The fenced block holds the command. The
title:"..."attribute is shown in the picker as a description. - That’s it - this cheat is runnable with no metadata.
Adding variables
When a command contains $name references, CheatMD prompts for values before
running. A <!-- cheat --> block below the code fence declares how each
variable is populated:
## Docker: exec into container
```sh title:"Execute shell in container"
docker exec -it $container /bin/sh
```
<!-- cheat
var container = docker ps --format "{{.Names}}" --- --header "Select container"
--> Variables are resolved in declaration order. See Variables for the three var forms and [Selector Options](/docs/selector options) for picker display control.
The <!-- cheat --> block
The metadata block is an HTML comment placed after the fenced code block under the same heading. Every line inside is one of:
| Line type | Example |
|---|---|
| Variable definition | var name = shell command |
| Import | import module_name |
| Export | export module_name |
| Chain step | chain release 1 |
| Conditional | if $var == value / fi |
| Comment | # this is ignored |
| Blank | (ignored) |
A trailing backslash \ continues a line:
var x = some-long-shell-command --with --many --flags --- --header "Pick" Heading levels
Any Markdown heading level works (#, ##, ###, etc.). CheatMD treats them
all the same for cheat detection. Use whatever hierarchy fits your document.
Code fence languages
The fence language hint (```sh, ```powershell, etc.) is used by the
linter for syntax-aware variable detection. It doesn’t affect execution - the
command always runs through your configured shell.
File organization
Put .md files anywhere under your cheats path. CheatMD recursively walks the
directory. Folder and file names automatically become searchable Tags.
~/cheats/
cloud/
aws/s3.md # tagged: cloud, aws, s3
azure/vm.md # tagged: cloud, azure, vm
docker.md # tagged: docker
git.md # tagged: git