Compile LLM Agent Prompts with MDS CLI
Job to be done: Manage and compile LLM agent prompts across different platforms from a single source
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Entrepreneur
As a tech entrepreneur, use MDS to organize and compile all the prompt templates for your AI-powered content generation tool, ensuring consistent brand voice for Instagram captions and WhatsApp product descriptions.
- Student
As a computer science student, use MDS to manage and compile the system and user prompts for your final year project's AI chatbot, ensuring consistent behavior when interacting with different LLM APIs.
- 9-5 employee
As a software developer, use MDS to manage and compile the various LLM prompts for your company's internal customer support AI, allowing for quick updates and consistent responses across different AI models.
What you’ll get
You will learn how to use a tool called MDS (Markdown Script) to write your AI agent prompts in one place and automatically convert them into different formats needed by various AI platforms. This saves you from copying and pasting prompts, reducing errors and making updates easier.
Tools you need
- mds-cli (free): A command-line tool that compiles your special Markdown prompts into formats AI models understand.
- Rust (free): A programming language used to build the mds-cli tool. You need it to install the tool.
- Makefile (free): A tool that helps automate build processes, often used with Rust projects.
Steps
-
Install the mds-cli tool: You need to install the command-line tool first. This requires having Rust installed on your computer.
- If you don’t have Rust installed, visit the official Rust website (rust-lang.org) and follow their installation instructions. This is a one-time setup.
- Once Rust is installed, open your terminal or command prompt and run the following command to install mds-cli:
cargo install mds-cliYou should see messages indicating the tool is being downloaded and installed. Once complete, the command prompt will return to a ready state.
-
Create your prompt file: Create a new file for your prompt. The author uses a
.mdsextension for these special Markdown files. Let’s call itreview.mds. -
Write your prompt using MDS syntax: Open
review.mdsin a text editor. You can use variables, functions, and imports. Here’s an example based on the author’s description:First, define a reusable persona in a separate file, for example,
_persona.mds:@define reviewer(lang): You are a senior {lang} code reviewer. Flag correctness bugs first, then style. Keep it concise. @endThen, in your main
review.mdsfile, import and use this persona. You can also define message blocks that will compile to JSON format for AI models:@import "./_persona.mds" as p @message system: {p.reviewer("TypeScript")} @end @message user: Review this diff: {diff} @endYou should see the text you typed appear in your editor. The special
@commands are how MDS understands your prompt structure. -
Compile your prompt: Go back to your terminal or command prompt, navigate to the directory where you saved your
.mdsfiles, and run the build command. The author showsmds build review.mds.mds build review.mdsIf your
review.mdsfile contains@messageblocks, this command will create areview.jsonfile in the same directory. This JSON file contains the structured messages ready to be sent to an AI model. If there were no@messageblocks, it would createreview.md.You should see a new file,
review.json, appear in your file explorer. Opening it will show a list of message objects, like this example:[ { "role": "system", "content": "You are a senior TypeScript code reviewer. Flag correctness bugs first, then style. Keep it concise." }, { "role": "user", "content": "Review this diff: \n ..." } ]If your file only contained Markdown elements (no
@messageblocks), it would createreview.mdwith the compiled Markdown content.
Original source
This workflow is based on a blog post by dean0x, explaining how to use their custom tool, MDS (Markdown Script), to simplify writing and managing prompts for AI agents. The goal is to write prompts once and have them work across different AI platforms.
Notes & variations
- Free tier alternatives: While MDS is a specific tool, the core idea of managing prompts can be approached by using simple text files and carefully organizing them, though it lacks the automation and error checking MDS provides.
- Common mistake: Forgetting to install Rust before trying to install
mds-cliwill cause thecargo installcommand to fail with an error message aboutcargonot being found. - Tip for better results: Use partial files (files starting with
_) for common prompt components like personas or instructions. This allows you to update a single file and have all prompts that import it automatically recompile with the changes.