xmd — executable markdown

LLMs as unix scripts. Write the prompt in markdown, run it like a command.

find-blue.md
#!/usr/bin/env xmd
$
install curl -sSL https://raw.githubusercontent.com/xmd-scripts/xmd/main/install.sh | sh
View on GitHub →

what it is

The LLM is the interpreter.

Write what you want in plain markdown. xmd sends it to any OpenAI-compatible model, gives it file and shell tools sandboxed to your working directory, streams output to stdout and reasoning to stderr.

find-blue.md
#!/usr/bin/env xmd
Find all images with a blue
background in this directory.

./find-blue.md

The read file tool supports multimodal models. Images are passed as file inputs.

variables

Declare inputs in frontmatter.

Variables are declared in a YAML block and listed in a preamble the model reads before your script. Pass them as key=value arguments.

hello.md
#!/usr/bin/env xmd
---
vars:
  name: required
---
Say hello to $NAME in a creative way.

./hello.md name=world

includes

Share prompts across scripts.

Include other markdown files as shared instructions. Reuse tone, format rules, or domain knowledge across any number of scripts. You decide exactly what context each script gets, instead of throwing hundreds of skills at every agent call.

blog-post.md
#!/usr/bin/env xmd
---
vars:
  topic: required
include:
  - tone.md
  - output-format.md
---
Write a blog post about $TOPIC.

./blog-post.md topic="the future of coding"

subagents

Scripts can call other scripts.

An xmd script can run another xmd script as a subprocess via shell tools. Each call gets a fresh model context: no shared state, no leakage. Subagent semantics from Unix process isolation.

write-and-review.md
#!/usr/bin/env xmd
---
vars:
  topic: required
---
Write a short essay about $TOPIC.
Then run ./critic.md and pass the essay through stdin.
Rewrite based on the feedback and output the final version.
critic.md runs in a clean context. It has no memory of writing the draft, so its critique is genuinely independent. Each subprocess is its own process, its own tool sandbox.

unix pipes

Compose scripts with pipes.

Declare a variable as stdin: true and it maps directly to a pipe. Chain scripts the same way you chain shell commands.

shell
cat pitch.md | ./architect.md | ./spec-writer.md > spec.md
review.md (stdin mapped to a variable)
---
vars:
  topic: required
  draft:
    stdin: true
---
Review how well this $DRAFT covers $TOPIC.
Rate it 1–10. Output:
## Rating
<n>/10
## Gaps
<one line>
## Suggestion
<one actionable fix>

debuggable ai workflows

See exactly what the model sees.

Pass --debug to dump the full rendered prompt to stderr: every include, every variable, exactly as sent to the model.

shell
cat essay.md | ./review.md --debug topic="the future of coding" 2>prompt.txt

backends

Bring your own model.

Point XMD_COMPLETION_URL at any backend. Defaults to localhost:11434 (ollama).

ollama / llama-server (default)
http://localhost:11434/v1/chat/completions
OpenAI
https://api.openai.com/v1/chat/completions
Anthropic, LM Studio, vLLM, …
any OpenAI-compatible endpoint
Cursor, Pi, …
Use agents as backends. They bring their own native tools on top of xmd's sandboxed file and shell access.
shell
XMD_COMPLETION_URL=https://api.openai.com/v1/chat/completions ./script.md

no reinventing the wheel

AI agents, the Unix way.

xmd maps familiar agent concepts to primitives you already know. stdout and exit codes mean it composes naturally with shell scripts for deterministic orchestration.

feature xmd — the unix way
subagents process isolation via shell calls
MCP servers CLI programs run by scripts
skills & rules markdown files, composable with includes
orchestration stdin / stdout, pipes, exit codes
discovery --help shows script usage
remote agents ssh for remote scripts

tell your agent

Let your agent write xmd scripts for you.

Read the quickstart yourself, or drop the agent skill directly into your coding agent.

Quickstart → Agent skill →

See what can be built.

Ready-to-run examples in the repo.

OCR
Reads an image and produces a title and description of its visual content.
Writer & critic
A writer script that calls a critic as a subagent and iterates until the critique passes.
Chat
A persistent assistant with memory across sessions. A Turing test where two agents face off, one trying to pass as human.
Games
Animal guess uses the question tool for script interactivity. Taboo pits two agents against each other.
Idea brainstormer
Generates ideas, deduplicates, expands, reviews, and files them into a ranked list.
Software dark factory
Pitch in, deployed product out. Architect → spec → build → QA → deploy notes, no humans in the loop.
Twitter thread author
Researches any topic and writes compelling threads based on a configurable persona. Deduplicates against previously published topics.
News digest
Consumes an RSS feed, filters posts relevant to a topic, and summarizes each one into a clean digest.
View examples on GitHub →